Jump to content
  • Advertisement
Sign in to follow this  

My X Mesh won't rotate c++ directx

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

If you intended to correct an error in the post then please contact us.

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!