I have a need to select an item and move it with the mouse.
I can get mouse coord and get screen coords and then do a ray and get the closet object it is clicking on.
My real problem is when I hold down the mouse I want to drag the object (Box) around the screen.
But the getWorldCoordinates basically returns -1 - 1 no matter where the camera is at
Vector2f click2d = inputManager.getCursorPosition();
Vector3f click3d = GuiGlobals.camera.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f);
System.out.println("spatial "+spatial.getWorldTranslation()+" Cursor 2d pos:"+ click2d +" 3d space "+click3d+" cam "+GuiGlobals.camera.getLocation());
So if I’m in the upper left corner of the screen I see
Upper Left corner of screen
spatial (-0.73191965, 0.41421354, 1.0) Cursor 2d pos:(6.0, 1938.0) 3d space (-0.73191965, 0.4133595, 1.0) cam (0.0, 0.0, 10.0)
spatial (-0.73191965, 0.4133595, 1.0) Cursor 2d pos:(5.0, 1938.0) 3d space (-0.7323467, 0.4133595, 1.0) cam (0.0, 0.0, 10.0)
Lower right corner of the screen output
spatial (0.73063856, -0.41165137, 1.0) Cursor 2d pos:(3431.0, 5.0) 3d space (0.73063856, -0.41207844, 1.0) cam (0.0, 0.0, 10.0)
spatial (0.73063856, -0.41207844, 1.0) Cursor 2d pos:(3432.0, 5.0) 3d space (0.7310656, -0.41207844, 1.0) cam (0.0, 0.0, 10.0)
Spatial original location:
spatial (-2.0, 0.0, 1.0)
The spatial is basically in the middle of the screen based on camera location. But when I click on the screen I’m getting x of basically -1 to 1 and also for y.
How do I convert that to world coordinates.
Thanks,