Skip to content

Commit a9821f5

Browse files
authored
Merge pull request #273 from Unity-Technologies/Uni-35607-component-rotation-euler
Uni-35607-component-rotation-euler
2 parents 4e695a3 + d25cab7 commit a9821f5

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,33 +1401,38 @@ protected void ExportAnimationCurve (UnityEngine.Object uniObj,
14011401
class UnityToMayaConvertSceneHelper
14021402
{
14031403
bool convertDistance = false;
1404+
bool convertLtoR = false;
1405+
14041406
float unitScaleFactor = 1f;
14051407

14061408
public UnityToMayaConvertSceneHelper(string uniPropertyName)
14071409
{
14081410
System.StringComparison cc = System.StringComparison.CurrentCulture;
14091411

1410-
convertDistance |= uniPropertyName.StartsWith ("m_LocalPosition.", cc);
1411-
convertDistance |= uniPropertyName.StartsWith ("m_Intensity", cc);
1412+
bool partT = uniPropertyName.StartsWith ("m_LocalPosition.", cc);
1413+
bool partTx = uniPropertyName.EndsWith ("Position.x", cc) || uniPropertyName.EndsWith ("T.x", cc);
1414+
bool partRy = uniPropertyName.Equals("localEulerAnglesRaw.y", cc);
1415+
bool partRz = uniPropertyName.Equals("localEulerAnglesRaw.z", cc);
14121416

1413-
bool convertLHRH = convertDistance && uniPropertyName.EndsWith (".x", cc) || uniPropertyName.EndsWith ("T.x", cc);
1414-
convertDistance |= convertLHRH;
1415-
convertDistance |= uniPropertyName.EndsWith ("T.y", cc);
1416-
convertDistance |= uniPropertyName.EndsWith ("T.z", cc);
1417+
convertLtoR |= partTx || partRy || partRz;
1418+
1419+
convertDistance |= partT;
1420+
convertDistance |= uniPropertyName.StartsWith ("m_Intensity", cc);
14171421

1418-
if (convertDistance) {
1422+
if (convertDistance)
14191423
unitScaleFactor = ModelExporter.UnitScaleFactor;
1420-
if (convertLHRH)
1421-
unitScaleFactor = -unitScaleFactor;
1422-
}
1424+
1425+
if (convertLtoR)
1426+
unitScaleFactor = -unitScaleFactor;
14231427
}
14241428

14251429
public float Convert(float value)
14261430
{
14271431
// left handed to right handed conversion
14281432
// meters to centimetres conversion
1429-
return (convertDistance) ? unitScaleFactor * value : value;
1433+
return unitScaleFactor * value;
14301434
}
1435+
14311436
}
14321437

14331438
/// <summary>
@@ -1463,7 +1468,20 @@ public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPai
14631468
return true;
14641469
}
14651470

1466-
// NOTE: Transform Rotation handled by QuaternionCurve
1471+
// Transform Rotation (EULER)
1472+
// NOTE: Quaternion Rotation handled by QuaternionCurve
1473+
if (uniPropertyName.StartsWith ("localEulerAnglesRaw.x", ct)) {
1474+
prop = new FbxPropertyChannelPair ("Lcl Rotation", Globals.FBXSDK_CURVENODE_COMPONENT_X);
1475+
return true;
1476+
}
1477+
if (uniPropertyName.StartsWith ("localEulerAnglesRaw.y", ct)) {
1478+
prop = new FbxPropertyChannelPair ("Lcl Rotation", Globals.FBXSDK_CURVENODE_COMPONENT_Y);
1479+
return true;
1480+
}
1481+
if (uniPropertyName.StartsWith ("localEulerAnglesRaw.z", ct)) {
1482+
prop = new FbxPropertyChannelPair ("Lcl Rotation", Globals.FBXSDK_CURVENODE_COMPONENT_Z);
1483+
return true;
1484+
}
14671485

14681486
// Transform Translation
14691487
if (uniPropertyName.StartsWith ("m_LocalPosition.x", ct) || uniPropertyName.EndsWith ("T.x", ct)) {

0 commit comments

Comments
 (0)