I’m using the code from the sdk tutorial for mouse picking but it’s not working.
Vector2f click2d = app.getInputManager().getCursorPosition();
Vector3f click3d = app.getCamera().getWorldCoordinates(
new Vector2f(click2d.x, click2d.y), 0f).clone();
Vector3f dir = app.getCamera().getWorldCoordinates(
new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
ray = new Ray(click3d, dir);
This always returns zero results. However it works fine if I use the camera direction for the ray like in a first person shooter.
ray = new Ray(gameManager.cameraManager.camera.getLocation(), gameManager.cameraManager.camera.getDirection());
What am I doing wrong here ?
Disregard , something was bugged in the SDK. I restarted it and it worked fine.
Note: Lemur has mouse picking built into it and it works in 3D or 2D… with any JME Spatial. Could be easier in the long run depending on what you will do with it.
Isn’t Lemur’s just for GUI picking ? I’m picking spatials from my scene.
No… as I said directly already:
More to the point, you could simply click on the Lemur Gems 3 and see that it is being used to pick 3D objects in a scene.
…but maybe never mind.