Sign in to follow this  

My X Mesh won't rotate c++ directx

Recommended Posts

I have two objects. The problem is that i can't scale and rotate objects, i can only do one of them. if i put scaling code after rotating it will scale. if i rotating code is after scaling it will rotate. I don't really know why this is happening.
here is my code

void AnimatedMesh::UpdateFrameMatrices(const D3DXFRAME *frameBase, D3DXMATRIX *parentMatrix, Transformation trans)

// If parent matrix exists multiply our frame matrix by it
if (parentMatrix != NULL)
D3DXMatrixMultiply(&currentFrame->exCombinedTransformationMatrix, &currentFrame->TransformationMatrix, parentMatrix);
D3DXMatrixRotationYawPitchRoll(&currentFrame->exCombinedTransformationMatrix, trans.Rx, trans.Ry, trans.Rz);
D3DXMatrixScaling(&currentFrame->exCombinedTransformationMatrix, trans.Sx, trans.Sy, trans.Sz);
currentFrame->exCombinedTransformationMatrix = currentFrame->TransformationMatrix;

// If we have a sibling recurse
if (currentFrame->pFrameSibling != NULL)
UpdateFrameMatrices(currentFrame->pFrameSibling, parentMatrix, trans);

// If we have a child recurse
if (currentFrame->pFrameFirstChild != NULL)
UpdateFrameMatrices(currentFrame->pFrameFirstChild, &currentFrame->exCombinedTransformationMatrix, trans);

I Know the problem won't be there but i don't know where it would be

Share this post

Link to post
Share on other sites
You need to create a separate matrix each for scaling and rotation. Then multiply all of the matrices together - combined, rotation and scaling.

The way you have it, you're overwriting the combined.

Share this post

Link to post
Share on other sites
it didn't work. I still have same result.
here is my new code

D3DXMatrixRotationYawPitchRoll(&w, trans.Rx, trans.Ry, trans.Rz);
D3DXMatrixScaling(&s, trans.Sx, trans.Sy, trans.Sz);
D3DXMatrixMultiply(&currentFrame->exCombinedTransformationMatrix, &w, &s);[/code]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this