how can i get rotation vector from matrix4x4 in xna?
- by mr.Smyle
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