Ray picking - get direction from pitch and yaw

Posted by Isaac Waller on Game Development See other posts from Game Development or by Isaac Waller
Published on 2011-11-21T03:26:31Z Indexed on 2011/11/21 10:23 UTC
Read the original article Hit count: 615

Filed under:
|
|
|

I am attempting to cast a ray from the center of the screen and check for collisions with objects.

When rendering, I use these calls to set up the camera:

GL11.glRotated(mPitch, 1, 0, 0);
GL11.glRotated(mYaw, 0, 1, 0);
GL11.glTranslated(mPositionX, mPositionY, mPositionZ);

I am having trouble creating the ray, however. This is the code I have so far:

ray.origin = new Vector(mPositionX, mPositionY, mPositionZ);
ray.direction = new Vector(?, ?, ?);

My question is: what should I put in the question mark spots? I.e. how can I create the ray direction from the pitch and roll?

Any help would be much appreciated!

© Game Development or respective owner

Related posts about opengl

Related posts about java