Object picking & Terrain picking on jME Alpha-4


I’m new to jME.

I want to move a selected object by dragging it on the map. The object’s new position would be the position on the terrain pointed by the mouse after having released the button (-> drag & drop). I first did the “hello picking” and “Terrain Collision” tutorials, and played a bit with jME. The “Terrain Collision” tutorial seems to be outdated, since in the latest version of jME that I’ve downloaded, PhysicsNode is deprecated. I’m not quite sure which control to use in order to achieve a good collision test. That may be a first issue.

Also, in order to “transform” the screen coordinates into world coordinates, I suppose I have to do something like:

[java]Vector2f pos = new Vector2f(e.getX(), e.getY());

Vector3f worldCoords = TestApplication.this.cam.getWorldCoordinates(pos, zPos); //


e being the mouse event. I guess I also have an issue here.

I’m able to pick an object when I haven’t moved my camera, which is looking directly at (0.0, 0.0, 0.0) from above (0.0, 30.0, 0.0), y being the “up” component. However I don’t know yet how to manage picking after having translated the camera position (For example, I click on the terrain (actually I click somewhere there’s no object), and if I drag the camera position is translated)

Help would be appreciated. Thanks in advance !

Ok… I was really exhausted the other day, and I missed a whole part of a documentation… Which enlightens me on how to use the api. I should be fine,


1 Like