I have been searching everywhere for this but just cannot get it.

I need to get the direction vector that my view is facing.

I know my current x, y and z position and the angles of rotation on the x and y axis.

But I just cannot get the vector of which way I am facing. I need the vector in x,y,z form so that I can simulate throwing an object.

Thankyou

In this thread,

http://www.opengl.org/discussion_boards/ubb/ultimatebb.php?ubb=get_topic;f=2;t=020327;p=1#000006

I posted the following code,

void cj3DMTO_CSystemToCameraMatrix(cj3DMTO_cSystem4v *subject, cj3DMTO_OGLMatrix result)

{

result[0]=(subject->X).x;

result[1]=(subject->Y).x;

result[2]=(subject->Z).x;

result[3]=0.0;

result[4]=(subject->X).y;

result[5]=(subject->Y).y;

result[6]=(subject->Z).y;

result[7]=0.0;

result[8]=(subject->X).z;

result[9]=(subject->Y).z;

result[10]=(subject->Z).z;

result[11]=0.0;

result[12]=-dotProduct(subject->X,subject->O);

result[13]=-dotProduct(subject->Y,subject->O);

result[14]=-dotProduct(subject->Z,subject->O);

result[15]=1.0;

}

which is a function that takes a camera class (an origin and three axes at right angles to each other) and creates a modelview transform so that the world is seen from the point of view of the camera.

This works fine.

I’d suggest that you could treat the modelview matrix as your viewing transform, and simply do the reverse of the above code, ie. obtain a copy of the matrix into an array of floats, and then treat entries {2,6,10} as a vector describing your view direction.

PPS - if you have a camera that isn’t allowed to rotate around z (like in Quake, ie yaw around world Y axis, then pitch around camera’s yawed X axis), then there’s a simpler way, involving trigonometry.

Thanks, I had looked into using the Modelview Matrix, but was using the wrong entries