Beispiel #1
0
        private Matrix4D createTransformFor(FBXElem globalSettings, out Quaternion.RotationOrder order)
        {
            order = Quaternion.RotationOrder.OrderXYZ;

            int frontAxis     = (int)globalSettings.Children.GetProperty("FrontAxis").Properties[4].Value;
            int frontAxisSign = (int)globalSettings.Children.GetProperty("FrontAxisSign").Properties[4].Value;
            int upAxis        = (int)globalSettings.Children.GetProperty("UpAxis").Properties[4].Value;
            int upAxisSign    = (int)globalSettings.Children.GetProperty("UpAxisSign").Properties[4].Value;
            int coordAxis     = (int)globalSettings.Children.GetProperty("CoordAxis").Properties[4].Value;
            int coordAxisSign = (int)globalSettings.Children.GetProperty("CoordAxisSign").Properties[4].Value;

            int front = (frontAxis * 2) + Math.Max(frontAxisSign, 0);
            int up    = (upAxis * 2) + Math.Max(upAxisSign, 0) << 3;
            int coord = (coordAxis * 2) + Math.Max(coordAxisSign, 0) << 6;

            CoordinateSystem coords = (CoordinateSystem)(front + up + coord);

            switch (coords)
            {
            // Blender 2.71 tells us that -Y is forward but the UI suggest +Y is forward.
            case CoordinateSystem.nYpZpX:
                order = Quaternion.RotationOrder.OrderXYZ;
                return(Matrix4D.CreateRotationX(Maths.DegreesToRadians(-90)));

            case CoordinateSystem.pZpYpX:
                order = Quaternion.RotationOrder.OrderXYZ;
                return(Matrix4D.Identity);

            case CoordinateSystem.nZpYnX:
                order = Quaternion.RotationOrder.OrderXYZ;
                return(Matrix4D.Identity);

            default:
                throw new NotImplementedException($"Unsupported World Transformation Matrix: {coords}");
            }
        }