Skip to content

Commit 22ecd5e

Browse files
committed
convert to maya axis before multiplying by inverse of prerotation
Sort of works but there are still euler flips
1 parent aca9450 commit 22ecd5e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,13 +1598,15 @@ Key [] ComputeKeys(UnityEngine.Quaternion restRotation, FbxNode node) {
15981598
m.SetR (fbxPreRotationEuler);
15991599
fbxPreRotationInverse = m.GetQ();
16001600

1601+
var tempRestRotation = fbxPreRotationInverse;
1602+
16011603
//fbxPreRotationInverse.ComposeSphericalXYZ(fbxPreRotationEuler);
16021604
fbxPreRotationInverse.Inverse();
16031605

16041606
// If we're only animating along certain coords for some
16051607
// reason, we'll need to fill in the other coords with the
16061608
// rest-pose value.
1607-
var lclQuaternion = new FbxQuaternion(restRotation.x, restRotation.y, restRotation.z, restRotation.w);
1609+
var lclQuaternion = tempRestRotation;//new FbxQuaternion(restRotation.x, restRotation.y, restRotation.z, restRotation.w);
16081610

16091611
// Find when we have keys set.
16101612
var keyTimes = new HashSet<float>();
@@ -1632,15 +1634,28 @@ Key [] ComputeKeys(UnityEngine.Quaternion restRotation, FbxNode node) {
16321634
// pre-rotation
16331635
// then pre-rotation inverse
16341636
// then animation.
1637+
1638+
var result = ModelExporter.ConvertQuaternionToXYZEuler(fbxFinalAnimation);
1639+
1640+
m = new FbxAMatrix ();
1641+
m.SetR (result);
1642+
fbxFinalAnimation = m.GetQ();
1643+
16351644
var fbxQuat = fbxPreRotationInverse * fbxFinalAnimation;
1645+
//var unityQuat = new Quaternion ((float)fbxQuat.X, (float)fbxQuat.Y, (float)fbxQuat.Z, (float)fbxQuat.W);
1646+
//var unityEul = unityQuat.eulerAngles;
1647+
1648+
m = new FbxAMatrix ();
1649+
m.SetQ (fbxQuat);
1650+
var unityEul = m.GetR ();
16361651

16371652
// Store the key so we can sort them later.
16381653
Key key;
16391654
key.time = FbxTime.FromSecondDouble(seconds);
1640-
key.euler = ModelExporter.ConvertQuaternionToXYZEuler(fbxQuat);
1655+
key.euler = unityEul;//new FbxVector4(unityEul.x, unityEul.y, unityEul.z); //ModelExporter.ConvertQuaternionToXYZEuler(fbxQuat);
16411656
keys[i++] = key;
16421657

1643-
Debug.Log ("pre rotation: " + fbxPreRotationEuler + ", complete rotation: " + key.euler);
1658+
Debug.Log ("pre rotation: " + fbxPreRotationEuler + ", complete rotation: " + key.euler + ", unity rot: " + unityEul);
16441659
}
16451660

16461661
// Sort the keys by time

0 commit comments

Comments
 (0)