Archived

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

3dZmaster

Problem in Object Rotation

Recommended Posts

This is the code I''m using a = m_fWorldRotX * sin(0-m_fWorldRotY); b = m_fWorldRotX * cos(0-m_fWorldRotY); // Matrix for the Main Character D3DXMATRIX matT, matR, matObj1; D3DXMatrixRotationY(&matR, 0-m_fWorldRotY); D3DXMatrixTranslation(&matT, 0-a, 0.0f, 0-b); D3DXMatrixMultiply(&m_matObj1, &matR, &matT); It moves fine, but it rotates around 0.0.0 I''d like to get it to rotate around it''s own axis. Anyone got solution?

Share this post


Link to post
Share on other sites
ok... Just finded out the rotation is fine. Something''s up with the translation.

here is the perfect code including the input statements:


if( m_UserInput.fAxisRotateLR )
m_fWorldRotY += m_fElapsedTime * m_UserInput.fAxisRotateLR;

if( m_UserInput.fAxisRotateUD )
m_fWorldRotX += m_fElapsedTime * m_UserInput.fAxisRotateUD;



a = m_fWorldRotX * sin(0-m_fWorldRotY);
b = m_fWorldRotX * cos(0-m_fWorldRotY);


// Matrix for the Main Character
D3DXMATRIX matObj1,matT, matR;
//D3DXMatrixTranslation(&matT, 0-a, 0.0f, 0-b);
D3DXMatrixTranslation(&matT, 3.0f, 0.0f, 0.0f);
D3DXMatrixRotationY(&matR, 0-m_fWorldRotY);
D3DXMatrixMultiply(&m_matObj1, &matR, &matT);


It is somehting in the sin and cos thing... SOMEONE PLZ!!!

Share this post


Link to post
Share on other sites