Reprojection in world space down camera axis

Started by ErDetEnAnd?, May 21, 2008, 06:24:38 PM

Previous topic - Next topic

ErDetEnAnd?

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.

EgonOlsen


ErDetEnAnd?

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.

EgonOlsen

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());