Original Post
hello,
I am trying to get my mesh rotations working but my following code doesn''t work as I expected. It works fine if I change just the yaw pitch or roll, but not if I change more than one at a time. If I cange more than the one the mesh moves erratically even when I stop changing the values.
In my render function I set the world matric to &m_MTransform, but I think I might be multiplying my marices wrong or something.
Sny help is appreciated
D3DXVec3Normalize( &m_LookAt, &m_LookAt ); D3DXVec3Cross( &m_Right, &m_Up, &m_LookAt ); D3DXVec3Normalize( &m_Right, &m_Right ); D3DXVec3Cross( &m_Up, &m_LookAt, &m_Right ); D3DXVec3Normalize( &m_Up, &m_Up ); D3DXMATRIX mPitch, mRoll, mYaw; // Set up the y-axis rotation D3DXMatrixRotationAxis( &mYaw, &m_Up, m_Yaw ); D3DXVec3TransformCoord( &m_LookAt, &m_LookAt, &mYaw ); D3DXVec3TransformCoord( &m_Right, &m_Right, &mYaw ); // Set up the x-axis rotation D3DXMatrixRotationAxis( &mPitch, &m_Right, m_Pitch ); D3DXVec3TransformCoord( &m_LookAt, &m_LookAt, &mPitch ); D3DXVec3TransformCoord( &m_Up, &m_Up, &mPitch ); // Set up the z-axis rotation D3DXMatrixRotationAxis( &mRoll, &m_LookAt, m_Roll ); D3DXVec3TransformCoord( &m_Right, &m_Right, &mRoll ); D3DXVec3TransformCoord( &m_Up, &m_Up, &mRoll ); m_Velocity = m_LookAt * m_Speed; m_Position += m_Velocity; D3DXMatrixMultiply(&m_MTransform, &mRoll, &mPitch); D3DXMatrixMultiply(&m_MTransform, &m_MTransform, &mYaw);