Skip to content

Commit 7cda0bc

Browse files
committed
add constant variable for scale factor
1 parent ae61baa commit 7cda0bc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class ModelExporter : System.IDisposable
3636

3737
const string ProgressBarTitle = "Fbx Export";
3838

39+
const int UnitScaleFactor = 100;
40+
3941
/// <summary>
4042
/// Create instance of example
4143
/// </summary>
@@ -356,9 +358,9 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene, b
356358
// from m to cm.
357359
foreach (var controlPoint in ControlPointToIndex.Keys) {
358360
fbxMesh.SetControlPointAt (new FbxVector4 (
359-
-controlPoint.x*100,
360-
controlPoint.y*100,
361-
controlPoint.z*100
361+
-controlPoint.x*UnitScaleFactor,
362+
controlPoint.y*UnitScaleFactor,
363+
controlPoint.z*UnitScaleFactor
362364
), ControlPointToIndex [controlPoint]);
363365
}
364366
} else {
@@ -370,9 +372,9 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene, b
370372
{
371373
// convert from left to right-handed by negating x (Unity negates x again on import)
372374
fbxMesh.SetControlPointAt(new FbxVector4 (
373-
-meshInfo.Vertices [v].x*100,
374-
meshInfo.Vertices [v].y*100,
375-
meshInfo.Vertices [v].z*100
375+
-meshInfo.Vertices [v].x*UnitScaleFactor,
376+
meshInfo.Vertices [v].y*UnitScaleFactor,
377+
meshInfo.Vertices [v].z*UnitScaleFactor
376378
), v);
377379
}
378380
}
@@ -451,7 +453,11 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
451453
// Negating the x value of the translation, and the y and z values of the rotation
452454
// to convert from Unity to Maya coordinates (left to righthanded).
453455
// Scaling the translation by 100 to convert from m to cm.
454-
var fbxTranslate = new FbxDouble3 (-unityTranslate.x*100, unityTranslate.y*100, unityTranslate.z*100);
456+
var fbxTranslate = new FbxDouble3 (
457+
-unityTranslate.x*UnitScaleFactor,
458+
unityTranslate.y*UnitScaleFactor,
459+
unityTranslate.z*UnitScaleFactor
460+
);
455461
var fbxRotate = new FbxDouble3 (unityRotate.x, -unityRotate.y, -unityRotate.z);
456462
var fbxScale = new FbxDouble3 (unityScale.x, unityScale.y, unityScale.z);
457463

0 commit comments

Comments
 (0)