I am having a problem putting an object into the scene in the corect location.
Let’s say I have a cube, my camera hits the front z side, I would like to attach an object to the front z side, to keep it simple, lets say another cube. Currently I am having issues getting the location as to where the new object should be placed.
Does anyone have any tutorials, or can anyone point me in the right direction?
Thanks
i may have got the syntax wrong but I think you would do something like this, which should (i think) move cube1 infront of the Z axis of cube, if they are the same size:
[java]cube1.setLocalTranslation(cube1.worldToLocal(cube.getWorldTranslation().add(
new Vector3f(0,0, ((BoundingBox)cube.getWorldBound()).getZextent*2),null);[/java]
Thanks,
But my questions is more, how do I know I have hit the Z side vs the x and y? And if the original cube has been rotated how does that all play in?
I think you can use a ray and find the point which the ray intersects the cube and then relate that to the origin of the cube and you can work out what side was hit. https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_picking
I also suggest looking at the script-blocks source code, it’s written in jme: Google Code Archive - Long-term storage for Google Code Project Hosting.
Script Blocks Alpha 11 Copy and Paste - YouTube