From dc3442ca24a0cab46bf05f94b15c385be39eab50 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:06:43 +0200 Subject: [PATCH 01/11] remove unused method GetTransform(...) --- .../OpenAssetImporter.cs | 50 +------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index d7037623d64..0b3d81b40d7 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -211,42 +211,6 @@ public Matrix GetTransform() else return Matrix.Identity; } - - public Matrix GetTransform(Vector3 scale, Quaternion rotation, Vector3 translation) - { - Matrix result = Matrix.Identity; - - if (this.Type == PivotType.GeometricScaling - || this.Type == PivotType.GeometricRotation - || this.Type == PivotType.GeometricTranslation - || this.Type == PivotType.ScalingPivotInverse) - result = result * this.Transform; - - result = result * Matrix.CreateScale(scale); - if (this.Type == PivotType.Scaling) - result = result * this.Transform; - - if (this.Type == PivotType.ScalingPivot - || this.Type == PivotType.ScalingOffset - || this.Type == PivotType.RotationPivotInverse - || this.Type == PivotType.PostRotation) - result = result * this.Transform; - - result = result * Matrix.CreateFromQuaternion(rotation); - if (this.Type == PivotType.Rotation) - result = result * this.Transform; - - if (this.Type == PivotType.PreRotation - || this.Type == PivotType.RotationPivot - || this.Type == PivotType.RotationOffset) - result = result * this.Transform; - - result = result * Matrix.CreateTranslation(translation); - if (this.Type == PivotType.Translation) - result = result * this.Transform; - - return result; - } } #endregion @@ -301,6 +265,8 @@ public override NodeContent Import(string filename, ContentImporterContext conte using (AssimpContext importer = new AssimpContext()) { + // TODO: check if we can set FBXPreservePivotsConfig(false) and clean up the code. + // FBXPreservePivotsConfig(false) can be set to remove transformation // pivots. However, Assimp does not automatically correct animations! // --> Leave default settings, handle transformation pivots explicitly. @@ -1088,19 +1054,7 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName } } - // Apply transformation pivot. - //if (scale.HasValue) - // scale = Vector3.One; - //if (rotation.HasValue) - // rotation = Quaternion.Identity; - //if (translation.HasValue) - // translation = Vector3.Zero; - //Matrix transform = pivot.GetTransform(scale.Value, rotation.Value, translation.Value); - // Apply transformation. - // Assimp now seems to fix animation by default. pivot transformation - // doesn't seem to be needed. - // TODO: check if we can set FBXPreservePivotsConfig(false) and clean up the code. Matrix transform = Matrix.Identity; if (scale.HasValue) transform *= Matrix.CreateScale(scale.Value); From 0033315656bb43734f737dfc070dab9e80936ada Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:08:13 +0200 Subject: [PATCH 02/11] remove FbxPivot.Default --- .../OpenAssetImporter.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 0b3d81b40d7..2d300369e3f 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -144,8 +144,6 @@ public class OpenAssetImporter : ContentImporter /// private class FbxPivot { - public static readonly FbxPivot Default = new FbxPivot(); - public enum PivotType { Invalid, @@ -912,7 +910,7 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName // Get transformation pivot for current bone. FbxPivot pivot; if (!_pivots.TryGetValue(boneName, out pivot)) - pivot = FbxPivot.Default; + pivot = new FbxPivot(); List scaleKeys = EmptyVectorKeys; List rotationKeys = EmptyQuaternionKeys; From 13575b77e96bc36d689c099e5ce770eab3d5fe61 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:10:39 +0200 Subject: [PATCH 03/11] refactor _pivots.TryGetValue(...) --- .../OpenAssetImporter.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 2d300369e3f..d24e9df330e 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -550,8 +550,7 @@ private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, N // PostRotation, RotationPivotInverse, ScalingOffset, ScalingPivot, // Scaling, ScalingPivotInverse string originalName = GetNodeName(aiNode.Name); - FbxPivot pivot; - if (!_pivots.TryGetValue(originalName, out pivot)) + if (!_pivots.TryGetValue(originalName, out FbxPivot pivot)) { pivot = new FbxPivot(); _pivots.Add(originalName, pivot); @@ -825,8 +824,7 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent) { // The current bone is the first in the chain. // The parent offset matrix is missing. :( - FbxPivot pivot; - if (_pivots.TryGetValue(node.Name, out pivot)) + if (_pivots.TryGetValue(node.Name, out FbxPivot pivot)) { // --> Use transformation pivot. node.Transform = pivot.GetTransform(); @@ -908,8 +906,7 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName AnimationChannel channel = new AnimationChannel(); // Get transformation pivot for current bone. - FbxPivot pivot; - if (!_pivots.TryGetValue(boneName, out pivot)) + if (!_pivots.TryGetValue(boneName, out FbxPivot pivot)) pivot = new FbxPivot(); List scaleKeys = EmptyVectorKeys; From 112c7969d56c5e2b657d090404fe12fcf56c5354 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:32:52 +0200 Subject: [PATCH 04/11] FbxPivot.GetPivotType(...) --- .../OpenAssetImporter.cs | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index d24e9df330e..5c9622b3b6e 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -169,37 +169,43 @@ public enum PivotType public void Update(Node aiNode, ContentIdentity identity) { this.Transform = ToXna(aiNode.Transform); + this.Type = FbxPivot.GetPivotType(aiNode.Name); + if (this.Type == PivotType.Invalid) + throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), identity);) + } - if (aiNode.Name.EndsWith("_Translation")) - Type = PivotType.Translation; - else if (aiNode.Name.EndsWith("_RotationOffset")) - Type = PivotType.RotationOffset; - else if (aiNode.Name.EndsWith("_RotationPivot")) - Type = PivotType.RotationPivot; - else if (aiNode.Name.EndsWith("_PreRotation")) - Type = PivotType.PreRotation; - else if (aiNode.Name.EndsWith("_Rotation")) - Type = PivotType.Rotation; - else if (aiNode.Name.EndsWith("_PostRotation")) - Type = PivotType.PostRotation; - else if (aiNode.Name.EndsWith("_RotationPivotInverse")) - Type = PivotType.RotationPivotInverse; - else if (aiNode.Name.EndsWith("_ScalingOffset")) - Type = PivotType.ScalingOffset; - else if (aiNode.Name.EndsWith("_ScalingPivot")) - Type = PivotType.ScalingPivot; - else if (aiNode.Name.EndsWith("_Scaling")) - Type = PivotType.Scaling; - else if (aiNode.Name.EndsWith("_ScalingPivotInverse")) - Type = PivotType.ScalingPivotInverse; - else if (aiNode.Name.EndsWith("_GeometricTranslation")) - Type = PivotType.GeometricTranslation; - else if (aiNode.Name.EndsWith("_GeometricRotation")) - Type = PivotType.GeometricRotation; - else if (aiNode.Name.EndsWith("_GeometricScaling")) - Type = PivotType.GeometricScaling; + public static PivotType GetPivotType(string nodeName) + { + if (nodeName.EndsWith("_Translation")) + return PivotType.Translation; + else if (nodeName.EndsWith("_RotationOffset")) + return PivotType.RotationOffset; + else if (nodeName.EndsWith("_RotationPivot")) + return PivotType.RotationPivot; + else if (nodeName.EndsWith("_PreRotation")) + return PivotType.PreRotation; + else if (nodeName.EndsWith("_Rotation")) + return PivotType.Rotation; + else if (nodeName.EndsWith("_PostRotation")) + return PivotType.PostRotation; + else if (nodeName.EndsWith("_RotationPivotInverse")) + return PivotType.RotationPivotInverse; + else if (nodeName.EndsWith("_ScalingOffset")) + return PivotType.ScalingOffset; + else if (nodeName.EndsWith("_ScalingPivot")) + return PivotType.ScalingPivot; + else if (nodeName.EndsWith("_Scaling")) + return PivotType.Scaling; + else if (nodeName.EndsWith("_ScalingPivotInverse")) + return PivotType.ScalingPivotInverse; + else if (nodeName.EndsWith("_GeometricTranslation")) + return PivotType.GeometricTranslation; + else if (nodeName.EndsWith("_GeometricRotation")) + return PivotType.GeometricRotation; + else if (nodeName.EndsWith("_GeometricScaling")) + return PivotType.GeometricScaling; else - throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), identity); + return PivotType.Invalid; } public Matrix GetTransform() From ab4069459182a2b5420139b58d3b2e0f030a043b Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:40:30 +0200 Subject: [PATCH 05/11] inline FbxPivot.Update() --- .../OpenAssetImporter.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 5c9622b3b6e..53bd595bd57 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -164,15 +164,7 @@ public enum PivotType } public PivotType Type; - Matrix Transform; - - public void Update(Node aiNode, ContentIdentity identity) - { - this.Transform = ToXna(aiNode.Transform); - this.Type = FbxPivot.GetPivotType(aiNode.Name); - if (this.Type == PivotType.Invalid) - throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), identity);) - } + public Matrix Transform; public static PivotType GetPivotType(string nodeName) { @@ -561,7 +553,10 @@ private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, N pivot = new FbxPivot(); _pivots.Add(originalName, pivot); } - pivot.Update(aiNode, _identity); + pivot.Transform = ToXna(aiNode.Transform); + pivot.Type = FbxPivot.GetPivotType(aiNode.Name); + if (pivot.Type == FbxPivot.PivotType.Invalid) + throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), _identity); } else if (!_bones.Contains(aiNode)) // Ignore bones. { From 267c4e91c9c8457872e8a0746ea553e2726139d0 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:42:03 +0200 Subject: [PATCH 06/11] remove unused code --- .../OpenAssetImporter.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 53bd595bd57..1b562b97a46 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -906,10 +906,6 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName string boneName = channelGroup.Key; AnimationChannel channel = new AnimationChannel(); - // Get transformation pivot for current bone. - if (!_pivots.TryGetValue(boneName, out FbxPivot pivot)) - pivot = new FbxPivot(); - List scaleKeys = EmptyVectorKeys; List rotationKeys = EmptyQuaternionKeys; List translationKeys = EmptyVectorKeys; @@ -920,7 +916,6 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName { scaleKeys = aiChannel.ScalingKeys; - Debug.Assert(pivot.Type == FbxPivot.PivotType.Scaling); Debug.Assert(!aiChannel.HasRotationKeys || (aiChannel.RotationKeyCount == 1 && (aiChannel.RotationKeys[0].Value == new Assimp.Quaternion(1, 0, 0, 0) || aiChannel.RotationKeys[0].Value == new Assimp.Quaternion(0, 0, 0, 0)))); Debug.Assert(!aiChannel.HasPositionKeys || (aiChannel.PositionKeyCount == 1 && aiChannel.PositionKeys[0].Value == new Vector3D(0, 0, 0))); } @@ -928,7 +923,6 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName { rotationKeys = aiChannel.RotationKeys; - Debug.Assert(pivot.Type == FbxPivot.PivotType.Rotation); Debug.Assert(!aiChannel.HasScalingKeys || (aiChannel.ScalingKeyCount == 1 && aiChannel.ScalingKeys[0].Value == new Vector3D(1, 1, 1))); Debug.Assert(!aiChannel.HasPositionKeys || (aiChannel.PositionKeyCount == 1 && aiChannel.PositionKeys[0].Value == new Vector3D(0, 0, 0))); } @@ -936,7 +930,6 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName { translationKeys = aiChannel.PositionKeys; - Debug.Assert(pivot.Type == FbxPivot.PivotType.Translation); Debug.Assert(!aiChannel.HasScalingKeys || (aiChannel.ScalingKeyCount == 1 && aiChannel.ScalingKeys[0].Value == new Vector3D(1, 1, 1))); Debug.Assert(!aiChannel.HasRotationKeys || (aiChannel.RotationKeyCount == 1 && (aiChannel.RotationKeys[0].Value == new Assimp.Quaternion(1, 0, 0, 0) || aiChannel.RotationKeys[0].Value == new Assimp.Quaternion(0, 0, 0, 0)))); } From 7f7c1147cbf876fbbc68e4118f460e9829be3346 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:51:02 +0200 Subject: [PATCH 07/11] inline GetTransform() --- .../OpenAssetImporter.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 1b562b97a46..3eaa1f15b83 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -199,14 +199,6 @@ public static PivotType GetPivotType(string nodeName) else return PivotType.Invalid; } - - public Matrix GetTransform() - { - if (this.Type != PivotType.Invalid) - return this.Transform; - else - return Matrix.Identity; - } } #endregion @@ -827,8 +819,10 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent) // The parent offset matrix is missing. :( if (_pivots.TryGetValue(node.Name, out FbxPivot pivot)) { + node.Transform = Matrix.Identity; // --> Use transformation pivot. - node.Transform = pivot.GetTransform(); + if (pivot.Type != FbxPivot.PivotType.Invalid) + node.Transform = pivot.Transform; } else { From a99e05dbd14c13738364c7182c4d59d3defda68c Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:54:13 +0200 Subject: [PATCH 08/11] simplify code pivots can't be invalid --- .../OpenAssetImporter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 3eaa1f15b83..6831f63f75e 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -545,10 +545,10 @@ private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, N pivot = new FbxPivot(); _pivots.Add(originalName, pivot); } - pivot.Transform = ToXna(aiNode.Transform); pivot.Type = FbxPivot.GetPivotType(aiNode.Name); if (pivot.Type == FbxPivot.PivotType.Invalid) throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), _identity); + pivot.Transform = ToXna(aiNode.Transform); } else if (!_bones.Contains(aiNode)) // Ignore bones. { @@ -819,10 +819,8 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent) // The parent offset matrix is missing. :( if (_pivots.TryGetValue(node.Name, out FbxPivot pivot)) { - node.Transform = Matrix.Identity; // --> Use transformation pivot. - if (pivot.Type != FbxPivot.PivotType.Invalid) - node.Transform = pivot.Transform; + node.Transform = pivot.Transform; } else { From ea71c008ba2b3b43ea918ace46d6512604edd3eb Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 23 Dec 2024 23:58:35 +0200 Subject: [PATCH 09/11] use Matrix4x4 --- .../OpenAssetImporter.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 6831f63f75e..32d34444a57 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -164,7 +164,7 @@ public enum PivotType } public PivotType Type; - public Matrix Transform; + public Matrix4x4 Transform; public static PivotType GetPivotType(string nodeName) { @@ -548,7 +548,7 @@ private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, N pivot.Type = FbxPivot.GetPivotType(aiNode.Name); if (pivot.Type == FbxPivot.PivotType.Invalid) throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), _identity); - pivot.Transform = ToXna(aiNode.Transform); + pivot.Transform = aiNode.Transform; } else if (!_bones.Contains(aiNode)) // Ignore bones. { @@ -820,7 +820,7 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent) if (_pivots.TryGetValue(node.Name, out FbxPivot pivot)) { // --> Use transformation pivot. - node.Transform = pivot.Transform; + node.Transform = ToXna(pivot.Transform); } else { From 26d7bafb3e6b2572f5b7868eb96b930e441a0fbe Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Tue, 24 Dec 2024 00:45:10 +0200 Subject: [PATCH 10/11] remove unused code pivots are ignored in ImportBones(...) --- .../OpenAssetImporter.cs | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 32d34444a57..6405125477e 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -214,7 +214,6 @@ public static PivotType GetPivotType(string nodeName) private Dictionary _deformationBones; // The names and offset matrices of all deformation bones. private Node _rootBone; // The node that represents the root bone. private List _bones = new List(); // All nodes attached to the root bone. - private Dictionary _pivots; // The transformation pivots. /// @@ -491,7 +490,6 @@ private List ImportMaterialsExt(List aiMaterials) /// private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, List materials) { - _pivots = new Dictionary(); NodeContent rootNode = ImportNodes(context, aiScene, aiScene.RootNode, materials, null, null); return rootNode; } @@ -539,16 +537,6 @@ private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, N // Translation, RotationOffset, RotationPivot, PreRotation, Rotation, // PostRotation, RotationPivotInverse, ScalingOffset, ScalingPivot, // Scaling, ScalingPivotInverse - string originalName = GetNodeName(aiNode.Name); - if (!_pivots.TryGetValue(originalName, out FbxPivot pivot)) - { - pivot = new FbxPivot(); - _pivots.Add(originalName, pivot); - } - pivot.Type = FbxPivot.GetPivotType(aiNode.Name); - if (pivot.Type == FbxPivot.PivotType.Invalid) - throw new InvalidContentException(String.Format("Unknown $AssimpFbx$ node: \"{0}\"", aiNode.Name), _identity); - pivot.Transform = aiNode.Transform; } else if (!_bones.Contains(aiNode)) // Ignore bones. { @@ -817,16 +805,9 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent) { // The current bone is the first in the chain. // The parent offset matrix is missing. :( - if (_pivots.TryGetValue(node.Name, out FbxPivot pivot)) - { - // --> Use transformation pivot. - node.Transform = ToXna(pivot.Transform); - } - else - { - // --> Let's assume that parent's transform is Identity. - node.Transform = Matrix.Invert(offsetMatrix); - } + + // --> Let's assume that parent's transform is Identity. + node.Transform = Matrix.Invert(offsetMatrix); } else if (isOffsetMatrixValid && aiParent == _rootBone) { From 30ebcb5cc38ee56b0ffaedf0bf379686caaf9edc Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Tue, 24 Dec 2024 00:47:15 +0200 Subject: [PATCH 11/11] remove unused FbxPivot --- .../OpenAssetImporter.cs | 100 ------------------ 1 file changed, 100 deletions(-) diff --git a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs index 6405125477e..360f0eca342 100644 --- a/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs +++ b/src/Xna.Framework.Content.Pipeline.Graphics/OpenAssetImporter.cs @@ -102,106 +102,6 @@ public class OpenAssetImporter : ContentImporter // --> Limitation #6: When scale, rotation, or translation is animated, all components // X, Y, Z need to be key framed. - #region Nested Types - /// Defines the frame for local scale/rotation/translation of FBX nodes. - /// - /// - /// The transformation pivot defines the frame for local scale/rotation/translation. The - /// local transform of a node is: - /// - /// - /// Local Transform = Translation * RotationOffset * RotationPivot * PreRotation - /// * Rotation * PostRotation * RotationPivotInverse * ScalingOffset - /// * ScalingPivot * Scaling * ScalingPivotInverse - /// - /// - /// where the matrix multiplication order is right-to-left. - /// - /// - /// 3ds max uses three additional transformations: - /// - /// - /// Local Transform = Translation * Rotation * Scaling - /// * GeometricTranslation * GeometricRotation * GeometricScaling - /// - /// - /// Transformation pivots are stored per FBX node. When Assimp hits an FBX node with - /// a transformation pivot it generates additional nodes named - /// - /// - /// OriginalName_$AssimpFbx$_TransformName - /// - /// - /// where TransformName is one of: - /// - /// - /// Translation, RotationOffset, RotationPivot, PreRotation, Rotation, PostRotation, - /// RotationPivotInverse, ScalingOffset, ScalingPivot, Scaling, ScalingPivotInverse, - /// GeometricTranslation, GeometricRotation, GeometricScaling - /// - /// - /// - /// - private class FbxPivot - { - public enum PivotType - { - Invalid, - Translation, - RotationOffset, - RotationPivot, - PreRotation, - Rotation, - PostRotation, - RotationPivotInverse, - ScalingOffset, - ScalingPivot, - Scaling, - ScalingPivotInverse, - GeometricTranslation, - GeometricRotation, - GeometricScaling, - } - - public PivotType Type; - public Matrix4x4 Transform; - - public static PivotType GetPivotType(string nodeName) - { - if (nodeName.EndsWith("_Translation")) - return PivotType.Translation; - else if (nodeName.EndsWith("_RotationOffset")) - return PivotType.RotationOffset; - else if (nodeName.EndsWith("_RotationPivot")) - return PivotType.RotationPivot; - else if (nodeName.EndsWith("_PreRotation")) - return PivotType.PreRotation; - else if (nodeName.EndsWith("_Rotation")) - return PivotType.Rotation; - else if (nodeName.EndsWith("_PostRotation")) - return PivotType.PostRotation; - else if (nodeName.EndsWith("_RotationPivotInverse")) - return PivotType.RotationPivotInverse; - else if (nodeName.EndsWith("_ScalingOffset")) - return PivotType.ScalingOffset; - else if (nodeName.EndsWith("_ScalingPivot")) - return PivotType.ScalingPivot; - else if (nodeName.EndsWith("_Scaling")) - return PivotType.Scaling; - else if (nodeName.EndsWith("_ScalingPivotInverse")) - return PivotType.ScalingPivotInverse; - else if (nodeName.EndsWith("_GeometricTranslation")) - return PivotType.GeometricTranslation; - else if (nodeName.EndsWith("_GeometricRotation")) - return PivotType.GeometricRotation; - else if (nodeName.EndsWith("_GeometricScaling")) - return PivotType.GeometricScaling; - else - return PivotType.Invalid; - } - } - #endregion - private static readonly List EmptyVectorKeys = new List(0); private static readonly List EmptyQuaternionKeys = new List(0);