# Mesh Roll With Pivot at Top

This topic is 4001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.
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) ;
}


1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631712
• Total Posts
3001849
×