direction in directx
i'm writing a first person perspective demo in directx 8, and i was wondering if anyone could give me any ideas on how they go about finding out which direction the user is facing...right now, if the user presses the up key, i increment both Z axis coordinates, etc, so the user "walks" forward. but if they turn and press up, there is an obvious problem...can anyone tell me the best way to know which way they are facing and also which axis' to increment/decrement based on this direction? thanks!
You can set up a translation matrix for the amount of z-axis units moved. Set up a rotation matrix for the amount of y-axis rotation. Multiply these two together and translate your View Translation matrix by the result. This code updates the view matrix by the change in x-axis,z-axis and y rotation (strafing,walking backwards/forwards and turning) -
x1 = x;
This assumes you already have your View Translation matrix set up in the D3DXMATRIX view_matrix and that x,z and r are the total amounts to translate/rotate and x1,z1 and r1 are static variables.