Author Topic: How to get 3D position by clicking 2d position?  (Read 1642 times)

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
How to get 3D position by clicking 2d position?
« on: September 07, 2010, 05:50:03 am »
How to get 3D position by click 2d position?
I did follow
Vector3f rayTo = new Vector3f(renderer.getRayTo((int) event.getX(), (int) event.getY()));

CollisionWorld.ClosestRayResultCallback rayCallback = new CollisionWorld.ClosestRayResultCallback(cameraPosition, rayTo);
dynamicWorld.rayTest(cameraPosition, rayTo, rayCallback);
if (rayCallback.hasHit()) {
  Vector3f vec = rayCallback.hitPointWorld;
}

but position is incorrect, What am I doing wrong?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: How to get 3D position by clicking 2d position?
« Reply #1 on: September 07, 2010, 07:43:34 am »
What should i say...this isn't a jPCT related question initially posted in an unrelated forum backed up by a private message with the same content...that won't get you anywhere...

You should actually ask this in a forum that deals with whatever you are using there.

IF this is using some data provided by jPCT somehow (albeit that's not visible in your code), make sure that the coordinate systems match...but i've already mentioned that in another post IIRC.
« Last Edit: September 07, 2010, 07:46:07 am by EgonOlsen »

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
Re: How to get 3D position by clicking 2d position?
« Reply #2 on: September 07, 2010, 08:36:54 am »
Then, how to get 3d position in JPCT?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: How to get 3D position by clicking 2d position?
« Reply #3 on: September 07, 2010, 08:57:31 am »