Marker Rotation

Oct 6, 2009 at 7:07 PM

I know its probably a simple question. But how would i get the rotation of Marker. 

Oct 6, 2009 at 7:26 PM

If you're using a MarkerNode (which is the simplest way), then you can get the transformation of the marker by accessing MarkerNode.WorldTransformation property.

To get the rotation from the matrix, you can use Matrix.Decompose(....) method supported by XNA. 


Oct 6, 2009 at 8:31 PM

I found this little bit of code in the XNA forums. Works great.


        public static bool GetRotation(Matrix mat, out Quaternion qRot)
            Vector3 scale, translation;
            if (!mat.Decompose(out scale, out qRot, out translation))
                Console.WriteLine("XNA failed ! Ninjutsu !");

                if (Matrix.Invert(mat).Decompose(out scale, out qRot, out translation))
                    qRot = Quaternion.Inverse(qRot);
                    Console.WriteLine("Hopeless !!!\n" + mat);
                    return false;
            return true;