void OffsetedRollObject_PivotTop(const FLOAT fUnits)
{
D3DXMATRIX matWorld, matTrans ;
D3DXVECTOR3 vec3Pos ;
m_TheWorld.GetWorldMatrix(&matWorld) ;
vec3Pos.x = matWorld._41 ; vec3Pos.y = matWorld._42 + m_fRadius ; vec3Pos.z = matWorld._43 ;
D3DXMatrixTranslation(&matTrans, -vec3Pos.x, -vec3Pos.y, -vec3Pos.z) ;
D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans) ;
D3DXMatrixRotationZ(&matTrans, fUnits) ;
D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans) ;
D3DXMatrixTranslation(&matTrans, vec3Pos.x, vec3Pos.y, vec3Pos.z) ;
D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans) ;
m_TheWorld.SetWorld(&matWorld) ;
}
Mesh Roll With Pivot at Top
I was trying to rotate a mesh about its z-axis with the pivot of rotation being the top most part of the mesh. In other words, I want the mesh to move about a circle with the center at origin(0,0,z) and radius being the bounding radius of the mesh. I translated the mesh to the (y-offseted by the bounding radius) world origin. Apllied rotation about Z axis and then translated it back to its previous position. Instead of moving about a circle, the mesh kept rolling in a wierd manner. I hope the code below gives a better picture as to what I tried to do. Any help will be deeply appreciated.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement