vEyePt = MakeVector(vx, vy, vz);vLookatPt = MakeVector(vx + (float)cos(XAxisRotate * g_DEGTORAD) * (float)sin(YAxisRotate * g_DEGTORAD), vy + (float)sin(XAxisRotate * g_DEGTORAD), vz + (float)cos(XAxisRotate * g_DEGTORAD) * (float)cos(YAxisRotate * g_DEGTORAD));vUpVec = MakeVector(0,1,0);D3DUtil_SetViewMatrix( matView, Camera->vEyePt, Camera->vLookatPt, Camera->vUpVec);g_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_VIEW, &matView);//I just keep track of my camers X/Y/Z position, and it's //rotation around the X and Y axis (this is a simple //implementation of an fps camera movement).//Then to move forwards/backwards etc just do something like vx +=(float)cos(XAxisRotate * g_DEGTORAD) * (float)sin(YAxisRotate * g_DEGTORAD) * distance; vy +=(float)sin(XAxisRotate * g_DEGTORAD) * distance; vz +=(float)cos(XAxisRotate * g_DEGTORAD) * (float)cos(YAxisRotate * g_DEGTORAD) * distance;
This will move in the direction the camera is facing. Just drop the line which updates the VY coord if you want to ignore movement up or down.
(This is some old code I had lying around, and is by no means guarenteed working anymore =)
HTH
Adam "Nutz" Hoult
VB Gaming Central
Edited by - daedalusd on July 13, 2000 6:36:24 PM