www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: ErDetEnAnd? on May 21, 2008, 06:24:38 pm
-
Hello.
A click on the awt frame gives me a screen coordinate. How do I reproject that coordinate into world space simplevector, and move it down the camera z-axis?
Tried long time now multiply the reprojected vector with a world matrix with no luck.
Thank you.
-
In Interact2D, there are two methods that may be helpful: http://www.jpct.net/doc/com/threed/jpct/Interact2D.html... (http://www.jpct.net/doc/com/threed/jpct/Interact2D.html#reproject2D3D(com.threed.jpct.Camera,%20com.threed.jpct.FrameBuffer,%20int,%20int))
-
If I click right in the center of the awt frame, the coordinates are 0;0;0. This is not world coordinates, rather the camera's. I know where the world origin lies, and according to that position the coordinates should be ca. -50;0;-300, since the camera is 300 away down the axis.
The camera z-axis is a new axis in the world, and I want to move up this axis.
-
Yes, it's camera space. You have to transform it back into world space. Somehow like this (untested!):
SimpleVector ray=Interact2D.reproject2D3D(world.getCamera(), fb, x, y);
SimpleVector ws=new SimpleVector(ray);
ws.matMul(world.getCamera().getBack().invert3x3());
ws.add(world.getCamera().getPosition());