This project is read-only.

Marker Rotation

Oct 6, 2009 at 8:07 PM

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

Coordinator
Oct 6, 2009 at 8: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. 

Ohan

Oct 6, 2009 at 9: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);
                }
                else
                {
                    Console.WriteLine("Hopeless !!!\n" + mat);
                    return false;
                }
            }
            return true;
        }