Author Topic: Reprojection in world space down camera axis  (Read 2263 times)

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Reprojection in world space down camera axis
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Reprojection in world space down camera axis
« Reply #1 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...

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Re: Reprojection in world space down camera axis
« Reply #2 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Reprojection in world space down camera axis
« Reply #3 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());