Example #1
0
        /// <summary>
        /// Creates Unity 4x4 matrix from native transform.
        /// </summary>
        /// <param name="transform">A native transform.</param>
        /// <param name="transformToRUF">(Optional) If false, prevents conversion to Unity's coordinate system.</param>
        /// <param name="applyScale">(Optional) If false, prevents scaling to Unity's unit per meter scale.</param>
        /// <returns>A Unity matrix.</returns>
        public static Matrix4x4 ToUnity(MagicLeapNativeBindings.MLTransform transform, bool transformToRUF = true, bool applyScale = true)
        {
            Vector3    position = ToUnity(transform.Position, transformToRUF, applyScale);
            Quaternion rotation = ToUnity(transform.Rotation, transformToRUF);

            return(Matrix4x4.TRS(position, rotation, Vector3.one));
        }
Example #2
0
        /// <summary>
        /// Creates native transform from a Unity matrix.
        /// </summary>
        /// <param name="mat">A Unity matrix.</param>
        /// <param name="transformFromRUF">(Optional) If false, prevents conversion to the native SDK coordinate system.</param>
        /// <param name="applyScale">(Optional) If false, prevents scaling to the native SDK's unit per meter scale.</param>
        /// <returns>A native transform.</returns>
        public static MagicLeapNativeBindings.MLTransform FromUnity(Matrix4x4 mat, bool transformFromRUF = true, bool applyScale = true)
        {
            MagicLeapNativeBindings.MLTransform transform = new MagicLeapNativeBindings.MLTransform();

            transform.Position = FromUnity(GetPositionFromTransformMatrix(mat), transformFromRUF, applyScale);
            transform.Rotation = FromUnity(GetRotationFromTransformMatrix(mat), transformFromRUF);

            return(transform);
        }