I suppose you shoot a ray from the cam to somewhere and find the collision?
for jme3 (I assume), this example does it:
Ugh how stupid of me… I forgot that the cam has a Direction property. On a different note, does the mouse have a location?
something along these lines:
//mouse position on screen (bottom left is 0,0, increases to top right)
Vector2f screenPos = inputManager.getCursorPosition();
//above mouse cursor’s position in 3D
Vector3f origin = cam.getWorldCoordinates(screenPos, 0.0f);
//A point deeper into the screen (positive zPos):
Vector3f pointOnNormal= cam.getWorldCoordinates(screenPos, 0.3f);
//the Ray from those:
Ray ray = new Ray(origin, direction);[/java]
(by default is false)
EDIT: I wrongly named “pointOnNormal” like that, it’s not a point on a normal because that (Ray really) is not perpendicular on anything, though it can be when in the middle of the screen only
Here is the method I use to pick with the mouse: http://hub.jmonkeyengine.org/groups/general-2/forum/topic/picking-with-the-mouse/
[java]Vector2f mouseCoords = new Vector2f(inputManager.getCursorPosition());
Ray ray = new Ray(cam.getWorldCoordinates(mouseCoords, 0),
CollisionResults results = new CollisionResults();
//you picked something
I suggest putting the objects you want to pick in a separate node. If you have a skybox in rootNode it will always be in results in this example.
Thanks that helps me alot.