I have a rigged (biped) and animated model in 3D Studio Max which I've exported as a .x file.
When I use it the animations run fine, however I've been trying to get the model itself to lean and turn from the hip but I'm having difficulty in finding where in the bone hierarchy I should apply the rotation matrices.
In 3D Studio Max there is a bipe object on the model called Bip01, when I select and rotate it the rotation cascades on all bones above the hip so I assumed that applyhing rotation matrices to the same D3DXFRAME (which has the same name, Bip01) would have the same effect but it does not. What happens is the effect ends up applying to everything in the bone hierarchy so applying transformations to Bip01 is like applying it to the route bone (which it might be as I'm not sure how to tell one bone from the other).
Here's the code where frame transformations are updating and I've added a bit of code attempting to apply the matrix transformation to Bip01, I'm not sure if there is any other relevant code I can show... (the rotation value is just a random value I threw in)
void CAnimInstance::UpdateFrames( MultiAnimFrame* pFrame, D3DXMATRIX* pmxBase )
{
assert( pFrame != NULL );
assert( pmxBase != NULL );
if(strcmp(pFrame->Name, "Bip01") == 0 ) { D3DXMATRIX rot;D3DXMatrixRotationY(&rot, 3.141); D3DXMatrixMultiply( &pFrame->TransformationMatrix, &pFrame->TransformationMatrix, &rot ); }
D3DXMatrixMultiply( &pFrame->TransformationMatrix,
&pFrame->TransformationMatrix,
pmxBase );
// transform siblings by the same matrix
if( pFrame->pFrameSibling )
UpdateFrames( ( MultiAnimFrame* )pFrame->pFrameSibling, pmxBase );
// transform children by the transformed matrix - hierarchical transformation
if( pFrame->pFrameFirstChild )
{
UpdateFrames( ( MultiAnimFrame* )pFrame->pFrameFirstChild,
&pFrame->TransformationMatrix );
}
}
*What I think I should be doing is finding all the children frames for Bip01 and apply the transform to them but how do I do that?