I've been implementing picking in my jPCT application, and I've come across the following problem: a ray created with reproject2D3D(...) from X and Y screen coordinates chosen by the mouse does not take into account the camera's transform. I have to manually multiply the ray by the camera's front matrix like so:
Camera cam;
FrameBuffer buffer;
.
.
.
SimpleVector rayTemp = Interact2D.reproject2D3D(cam, buffer, mX, mY);
rayTemp.normalize();
Matrix orient = cam.getFront();
float[] dump = orient.getDump();
SimpleVector ray = new SimpleVector();
ray.x = dump[0]*rayTemp.x + dump[1]*rayTemp.y + dump[2]*rayTemp.z + dump[3]*1;
ray.y = dump[4]*rayTemp.x + dump[5]*rayTemp.y + dump[6]*rayTemp.z + dump[7]*1;
ray.z = dump[8]*rayTemp.x + dump[9]*rayTemp.y + dump[10]*rayTemp.z + dump[11]*1;
If I don't do this, the ray has entirely the wrong orientation. Is this intentional behavior, or am I just doing something wrong?
Thanks,
-Nick