How to get 3D position by clicking 2d position?

Started by jumong, September 07, 2010, 05:50:03 AM

Previous topic - Next topic

jumong

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?

EgonOlsen

#1
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.

jumong