예제 #1
0
        public static Quaternion ParseQuaternion(Matrix4x4 mat)
        {
            Vector3 targetDir = mat.MultiplyVector(Vector3.forward);
            Vector3 targetUp  = mat.MultiplyVector(Vector3.up);

            return(UnityParser.ParseQuaternion(targetDir, targetUp));
        }
예제 #2
0
        public static Quaternion ParseQuaternion(ARTMatrix artM)
        {
            Matrix4x4 mat       = UnityParser.ParseMatrix(artM, true);
            Vector3   targetDir = mat.MultiplyVector(Vector3.forward);
            Vector3   targetUp  = mat.MultiplyVector(Vector3.up);

            return(UnityParser.ParseQuaternion(targetDir, targetUp));
        }
예제 #3
0
        /// <summary>
        /// This method parses various input objects and computes a quaternion to use with a camera object in Unity3d.
        /// E.g. mapping the rotation of a ART 6d object to the camera.
        ///
        /// If you wish to inverse an axis just change the correspondent boolean to true.
        /// </summary>
        /// <param name="artM">Input ARTMatrix</param>
        /// <param name="invX">Boolean used to inverse X axis</param>
        /// <param name="invY">Boolean used to inverse Y axis</param>
        /// <param name="invZ">Boolean used to inverse Z axis</param>
        /// <returns>Returns a quaternion</returns>
        public static Quaternion ParseCameraQuaternion(ARTMatrix artM, bool invX, bool invY, bool invZ)
        {
            Quaternion target = UnityParser.ParseQuaternion(artM);
            float      angle  = 0;
            Vector3    axis   = Vector3.zero;

            target.ToAngleAxis(out angle, out axis);
            if (invX)
            {
                axis.x *= -1;
            }
            if (invY)
            {
                axis.y *= -1;
            }
            if (invZ)
            {
                axis.z *= -1;
            }
            return(target = Quaternion.AngleAxis(angle, axis));
        }