Problem in Object Rotation
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?
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!!!
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!!!
The matrix multiplication must be done in certain order to work as predicted. Find the matrix multiplication formula for explanation as to why.
kind rgds Nik
kind rgds Nik
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement