Jump to content
  • Advertisement

Archived

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

EagleWarrior

Small problem

This topic is 6027 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

when i rotate my object it keeps rotating even when i stop pressing the key but when i translate it moves fine only the rotate. have no idea y it does that if any of u have any ideas plz tell me

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by EagleWarrior
i perfomr it every iteration of the process and no im not resetting my matrix to identity


Are you concetrating your current transformation matrix with the new one?

[ my engine ][ my game ][ my email ]
SPAM

Share this post


Link to post
Share on other sites
yes
// Normalizing Axis
D3DXVec3Normalize(&m_oFighter.vLook,&m_oFighter.vLook);
D3DXVec3Cross(&m_oFighter.vRight,&m_oFighter.vUp,&m_oFighter.vLook);
D3DXVec3Normalize(&m_oFighter.vRight,&m_oFighter.vRight);
D3DXVec3Cross(&m_oFighter.vUp,&m_oFighter.vLook,&m_oFighter.vRight);
D3DXVec3Normalize(&m_oFighter.vUp,&m_oFighter.vUp);

//**********************************************************
// Fighter object
//**********************************************************
if (m_bKey['D']) m_oFighter.fRoll -= 3.0f*m_fTimeElapsed/5000; //rotate right
if (m_bKey['A']) m_oFighter.fRoll += 3.0f*m_fTimeElapsed/5000; //rotate left
if (m_bKey['Q']) m_oFighter.fPitch -= 2.0f*m_fTimeElapsed/1000; //pitch down
if (m_bKey['E']) m_oFighter.fPitch += 2.0f*m_fTimeElapsed/1000; // pitch up
if (m_bKey['R']) m_oFighter.fYaw -= 2.0f*m_fTimeElapsed/1000; // YAW left
if (m_bKey['F']) m_oFighter.fYaw += 2.0f*m_fTimeElapsed/1000; // YAW right




D3DXMATRIX matRoll,matYaw,matPitch,matWorld,matTrans,matRot1;
D3DXMatrixIdentity(&matWorld);

D3DXMatrixRotationAxis(&matRoll,&m_oFighter.vLook,m_oFighter.fRoll);
//Rotate the Right & Up vectors on the Look vector ROLL
D3DXVec3TransformCoord(&m_oFighter.vRight,&m_oFighter.vRight,&matRoll);
D3DXVec3TransformCoord(&m_oFighter.vUp,&m_oFighter.vUp,&matRoll);

D3DXMatrixRotationAxis(&matYaw,&m_oFighter.vUp,m_oFighter.fYaw);
//Rotate the LOOK & Right vectors on the UP vector YAW
D3DXVec3TransformCoord(&m_oFighter.vLook,&m_oFighter.vLook,&matYaw);
D3DXVec3TransformCoord(&m_oFighter.vRight,&m_oFighter.vRight,&matYaw);


D3DXMatrixRotationAxis(&matPitch,&m_oFighter.vRight,m_oFighter.fPitch);
//Rotate the LOOK & Up vectors on the Right vector PITCH
D3DXVec3TransformCoord(&m_oFighter.vLook,&m_oFighter.vLook,&matPitch);
D3DXVec3TransformCoord(&m_oFighter.vUp,&m_oFighter.vUp,&matPitch);

if (m_bKey['S']) // Back
{
m_oFighter.vPos.x+=fspeed*m_oFighter.vLook.x;
m_oFighter.vPos.y+=fspeed*m_oFighter.vLook.y;
m_oFighter.vPos.z+=fspeed*m_oFighter.vLook.z;
}


if (m_bKey['W']) // Forward
{
m_oFighter.vPos.x-=fspeed*m_oFighter.vLook.x;
m_oFighter.vPos.y-=fspeed*m_oFighter.vLook.y;
m_oFighter.vPos.z-=fspeed*m_oFighter.vLook.z;
}


D3DXMatrixTranslation(&matTrans, m_oFighter.vPos.x, m_oFighter.vPos.y, m_oFighter.vPos.z);
D3DXMatrixLookAtLH(&matRot1, &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &m_oFighter.vLook, &m_oFighter.vUp);
D3DXMatrixInverse(&matRot1, NULL, &matRot1);
matWorld=matRot1*matTrans;

m_oFighter.matLocal = matWorld;

i divided it by 5000 cause when i press any button it rotates to dam fast

[edited by - EagleWarrior on March 21, 2002 4:33:46 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!