1
\$\begingroup\$

i want to get rotation vector from matrix to realize some parent-children system for models.


 Matrix bonePos = link.Bone.Transform * World;
 Matrix m = Matrix.CreateTranslation(link.Offset)
       * Matrix.CreateScale(link.gameObj.Scale.X, link.gameObj.Scale.Y, 
                 link.gameObj.Scale.Z)
       * Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(link.gameObj.Rotation.Y),
                 MathHelper.ToRadians(link.gameObj.Rotation.X),
                 MathHelper.ToRadians(link.gameObj.Rotation.Z))
//need rotation vector from bone matrix here (now it's global model rotation vector)
        * Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(Rotation.Y),
                  MathHelper.ToRadians(Rotation.X),
                  MathHelper.ToRadians(Rotation.Z))
         * Matrix.CreateTranslation(bonePos.Translation);
link.gameObj.World = m;

where : link - struct with children model settings, like position, rotation etc.
And link.Bone - Parent Bone

\$\endgroup\$
  • \$\begingroup\$ there is a Matrix.Decompose method, if thats what you are looking for \$\endgroup\$ – Kikaimaru Oct 15 '12 at 9:26
2
\$\begingroup\$
Matrix.Decompose

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.matrix.decompose.aspx

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.