@@ -152,12 +152,9 @@ public override NodeContent Import(string filename, ContentImporterContext conte
152
152
153
153
using ( AssimpContext importer = new AssimpContext ( ) )
154
154
{
155
- // TODO: check if we can set FBXPreservePivotsConfig(false) and clean up the code.
156
-
157
155
// FBXPreservePivotsConfig(false) can be set to remove transformation
158
- // pivots. However, Assimp does not automatically correct animations!
159
- // --> Leave default settings, handle transformation pivots explicitly.
160
- //importer.SetConfig(new Assimp.Configs.FBXPreservePivotsConfig(false));
156
+ // pivots.
157
+ importer . SetConfig ( new Assimp . Configs . FBXPreservePivotsConfig ( false ) ) ;
161
158
162
159
// Set flag to remove degenerate faces (points and lines).
163
160
// This flag is very important when PostProcessSteps.FindDegenerates is used
@@ -429,15 +426,6 @@ private NodeContent ImportNodes(ContentImporterContext context, Scene aiScene, N
429
426
430
427
node = mesh ;
431
428
}
432
- else if ( aiNode . Name . Contains ( "_$AssimpFbx$" ) )
433
- {
434
- // This is a transformation pivot.
435
- // <OriginalName>_$AssimpFbx$_<TransformName>
436
- // where <TransformName> is one of
437
- // Translation, RotationOffset, RotationPivot, PreRotation, Rotation,
438
- // PostRotation, RotationPivotInverse, ScalingOffset, ScalingPivot,
439
- // Scaling, ScalingPivotInverse
440
- }
441
429
else if ( ! _bones . Contains ( aiNode ) ) // Ignore bones.
442
430
{
443
431
node = new NodeContent ( ) ;
@@ -608,10 +596,7 @@ private static Node FindRootBone(Scene aiScene, string boneName)
608
596
Node rootBone = node ;
609
597
while ( node != aiScene . RootNode && ! node . HasMeshes )
610
598
{
611
- // Only when FBXPreservePivotsConfig(true):
612
- // The FBX path likes to put these extra preserve pivot nodes in here.
613
- if ( ! node . Name . Contains ( "$AssimpFbx$" ) )
614
- rootBone = node ;
599
+ rootBone = node ;
615
600
616
601
node = node . Parent ;
617
602
}
@@ -655,19 +640,8 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent)
655
640
Debug . Assert ( aiParent != null ) ;
656
641
657
642
NodeContent node = null ;
658
- if ( ! aiNode . Name . Contains ( "_$AssimpFbx$" ) ) // Ignore pivot nodes
659
643
{
660
- const string mangling = "_$AssimpFbxNull$" ; // Null leaf nodes are helpers
661
-
662
- if ( aiNode . Name . Contains ( mangling ) )
663
- {
664
- // Null leaf node
665
- node = new NodeContent ( ) ;
666
- node . Name = aiNode . Name . Replace ( mangling , string . Empty ) ;
667
- node . Identity = _identity ;
668
- node . Transform = ToXna ( GetRelativeTransform ( aiNode , aiParent ) ) ;
669
- }
670
- else if ( _bones . Contains ( aiNode ) )
644
+ if ( _bones . Contains ( aiNode ) )
671
645
{
672
646
// Bone
673
647
node = new BoneContent ( ) ;
@@ -752,26 +726,23 @@ private NodeContent ImportBones(Node aiNode, Node aiParent, NodeContent parent)
752
726
private AnimationContent ImportAnimation ( Animation aiAnimation , string nodeName = null )
753
727
{
754
728
AnimationContent animation = new AnimationContent ( ) ;
755
- animation . Name = GetAnimationName ( aiAnimation . Name ) ;
729
+ animation . Name = aiAnimation . Name . Replace ( "AnimStack::" , string . Empty ) ;
756
730
animation . Identity = _identity ;
757
731
animation . Duration = TimeSpan . FromSeconds ( aiAnimation . DurationInTicks / aiAnimation . TicksPerSecond ) ;
758
732
759
733
// In Assimp animation channels may be split into separate channels.
760
- // "nodeXyz" --> "nodeXyz_$AssimpFbx$_Translation",
761
- // "nodeXyz_$AssimpFbx$_Rotation",
762
- // "nodeXyz_$AssimpFbx$_Scaling"
763
- // Group animation channels by name (strip the "_$AssimpFbx$" part).
734
+ // Group animation channels by name.
764
735
IEnumerable < IGrouping < string , NodeAnimationChannel > > channelGroups ;
765
736
if ( nodeName != null )
766
737
{
767
738
channelGroups = aiAnimation . NodeAnimationChannels
768
- . Where ( channel => nodeName == GetNodeName ( channel . NodeName ) )
769
- . GroupBy ( channel => GetNodeName ( channel . NodeName ) ) ;
739
+ . Where ( channel => nodeName == channel . NodeName )
740
+ . GroupBy ( channel => channel . NodeName ) ;
770
741
}
771
742
else
772
743
{
773
744
channelGroups = aiAnimation . NodeAnimationChannels
774
- . GroupBy ( channel => GetNodeName ( channel . NodeName ) ) ;
745
+ . GroupBy ( channel => channel . NodeName ) ;
775
746
}
776
747
777
748
foreach ( IGrouping < string , NodeAnimationChannel > channelGroup in channelGroups )
@@ -785,33 +756,9 @@ private AnimationContent ImportAnimation(Animation aiAnimation, string nodeName
785
756
786
757
foreach ( NodeAnimationChannel aiChannel in channelGroup )
787
758
{
788
- if ( aiChannel . NodeName . EndsWith ( "_$AssimpFbx$_Scaling" ) )
789
- {
790
- scaleKeys = aiChannel . ScalingKeys ;
791
-
792
- 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 ) ) ) ) ;
793
- Debug . Assert ( ! aiChannel . HasPositionKeys || ( aiChannel . PositionKeyCount == 1 && aiChannel . PositionKeys [ 0 ] . Value == new Vector3D ( 0 , 0 , 0 ) ) ) ;
794
- }
795
- else if ( aiChannel . NodeName . EndsWith ( "_$AssimpFbx$_Rotation" ) )
796
- {
797
- rotationKeys = aiChannel . RotationKeys ;
798
-
799
- Debug . Assert ( ! aiChannel . HasScalingKeys || ( aiChannel . ScalingKeyCount == 1 && aiChannel . ScalingKeys [ 0 ] . Value == new Vector3D ( 1 , 1 , 1 ) ) ) ;
800
- Debug . Assert ( ! aiChannel . HasPositionKeys || ( aiChannel . PositionKeyCount == 1 && aiChannel . PositionKeys [ 0 ] . Value == new Vector3D ( 0 , 0 , 0 ) ) ) ;
801
- }
802
- else if ( aiChannel . NodeName . EndsWith ( "_$AssimpFbx$_Translation" ) )
803
- {
804
- translationKeys = aiChannel . PositionKeys ;
805
-
806
- Debug . Assert ( ! aiChannel . HasScalingKeys || ( aiChannel . ScalingKeyCount == 1 && aiChannel . ScalingKeys [ 0 ] . Value == new Vector3D ( 1 , 1 , 1 ) ) ) ;
807
- 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 ) ) ) ) ;
808
- }
809
- else
810
- {
811
- scaleKeys = aiChannel . ScalingKeys ;
812
- rotationKeys = aiChannel . RotationKeys ;
813
- translationKeys = aiChannel . PositionKeys ;
814
- }
759
+ scaleKeys = aiChannel . ScalingKeys ;
760
+ rotationKeys = aiChannel . RotationKeys ;
761
+ translationKeys = aiChannel . PositionKeys ;
815
762
}
816
763
817
764
int scaleIndex = - 1 ;
@@ -980,27 +927,6 @@ private static Matrix4x4 GetRelativeTransform(Node node, Node ancestorNode)
980
927
return transform ;
981
928
}
982
929
983
- /// <summary>
984
- /// Gets the animation name without the "AnimStack::" part.
985
- /// </summary>
986
- /// <param name="name">The mangled animation name.</param>
987
- /// <returns>The original animation name.</returns>
988
- private static string GetAnimationName ( string name )
989
- {
990
- return name . Replace ( "AnimStack::" , string . Empty ) ;
991
- }
992
-
993
- /// <summary>
994
- /// Gets the node name without the "_$AssimpFbx$" part.
995
- /// </summary>
996
- /// <param name="name">The mangled node name.</param>
997
- /// <returns>The original node name.</returns>
998
- private static string GetNodeName ( string name )
999
- {
1000
- int index = name . IndexOf ( "_$AssimpFbx$" , StringComparison . Ordinal ) ;
1001
- return ( index >= 0 ) ? name . Remove ( index ) : name ;
1002
- }
1003
-
1004
930
private static void ImportMetadata ( Scene _scene , NodeContent rootNode )
1005
931
{
1006
932
foreach ( var metaDataPair in _scene . Metadata )
0 commit comments