www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: ErDetEnAnd? on May 21, 2008, 06:24:38 pm

Title: Reprojection in world space down camera axis
Post 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.
Title: Re: Reprojection in world space down camera axis
Post by: EgonOlsen on May 21, 2008, 06:57:27 pm
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))
Title: Re: Reprojection in world space down camera axis
Post by: ErDetEnAnd? on May 22, 2008, 09:52:41 am
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.
Title: Re: Reprojection in world space down camera axis
Post by: EgonOlsen on May 22, 2008, 10:29:35 am
Yes, it's camera space. You have to transform it back into world space. Somehow like this (untested!):

Code: [Select]
   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());