Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mwilson

Removing roll in camera rotation

This topic is 6935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've been playing with the D3DX Tentacle example in the DX7 SDK. I'd REALLY like to remove the roll when pitching and turning, so its more like a FPS kind of control/view. I thought perhaps the solution was in this piece of code in the Draw() function: // // Update position and view matricies // D3DXMATRIX matT, matR; D3DXQUATERNION qR; vecT = g_vecVelocity * g_pFrameTimer->GetSecsPerFrame() * g_fSpeed; vecR = g_vecAngularVelocity * g_pFrameTimer->GetSecsPerFrame() * g_fAngularSpeed; D3DXMatrixTranslation(&matT, vecT.x, vecT.y, vecT.z); D3DXMatrixMultiply(&g_matPosition, &matT, &g_matPosition); D3DXQuaternionRotationYawPitchRoll(&qR, vecR.y, vecR.x, vecR.z); D3DXMatrixRotationQuaternion(&matR, &qR); D3DXMatrixMultiply(&g_matPosition, &matR, &g_matPosition); if(g_matPosition.m31 < 1.0f) g_matPosition.m31 = 1.0f; D3DXMatrixInverse(&g_matView, NULL, &g_matPosition); Anyways, I've been screwing with this for the last 2 days, and I'm getting to the point where I'd like to throw my monitor out the window Any tips would be greatly appreciated Edited by - mwilson on 4/28/00 10:30:04 AM

Share this post


Link to post
Share on other sites
Advertisement
Quaternions is a bit overkill for a FPS. I suggest you create your Viewmatrix like this:

D3DXMATRIX RotX, RotY, Trans;
D3DXMatrixRotationX(&RotX, -Pitch);
D3DXMatrixRotationY(&RotY, -Yaw);
D3DXMatrixTranslation(&Trans, -Camera.x, -Camera.y, -Camera.z);

D3DXMATRIX View;
D3DXMatrixMultiplication(&View, &RotX, &RotY);
D3DXMatriXMultiplication(&View, &View, &Trans);

pD3DDev->SetTransform(D3DTRANSFORMSTATE_VIEW, (D3DMATRIX*)&View);


Edited by - WitchLord on 4/28/00 10:51:04 AM

Share this post


Link to post
Share on other sites
Thanks for your reply.
I did dry that method, but now I just see part of the scene
and when I try to move, it moves slightly, then "snaps" back to its original position. Now I''m thinking the answer might lie elsewhere in the code

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!