File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
com.unity.formats.fbx/Editor Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -955,6 +955,31 @@ SkinnedMeshRenderer unitySkin
955
955
956
956
// add bind pose
957
957
ExportBindPose ( unitySkin , fbxNode , fbxScene , skinnedMeshToBonesMap ) ;
958
+
959
+ // now that the skin and bindpose are set, make sure that each of the bones
960
+ // is set to its original position
961
+ var bones = unitySkin . bones ;
962
+ foreach ( var bone in bones )
963
+ {
964
+ var fbxBone = MapUnityObjectToFbxNode [ bone . gameObject ] ;
965
+ ExportTransform ( bone , fbxBone , newCenter : Vector3 . zero , TransformExportType . Local ) ;
966
+
967
+ // Cancel out the pre-rotation from the exported rotation
968
+
969
+ // Get prerotation
970
+ var fbxPreRotationEuler = fbxBone . GetPreRotation ( FbxNode . EPivotSet . eSourcePivot ) ;
971
+ // Convert the prerotation to a Quaternion
972
+ var fbxPreRotationQuaternion = EulerToQuaternion ( fbxPreRotationEuler ) ;
973
+ // Inverse of the prerotation
974
+ fbxPreRotationQuaternion . Inverse ( ) ;
975
+
976
+ // Multiply LclRotation by pre-rotation inverse to get the LclRotation without pre-rotation applied
977
+ var finalLclRotationQuat = fbxPreRotationQuaternion * EulerToQuaternion ( new FbxVector4 ( fbxBone . LclRotation . Get ( ) ) ) ;
978
+
979
+ // Convert to Euler without axis conversion (Pre-rotation and LclRotation were already in Maya axis)
980
+ // and update LclRotation
981
+ fbxBone . LclRotation . Set ( ToFbxDouble3 ( QuaternionToEuler ( finalLclRotationQuat ) ) ) ;
982
+ }
958
983
}
959
984
960
985
return true ;
You can’t perform that action at this time.
0 commit comments