@@ -351,12 +351,14 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene, b
351
351
}
352
352
fbxMesh . InitControlPoints ( NumControlPoints ) ;
353
353
354
- // copy control point data from Unity to FBX
354
+ // Copy control point data from Unity to FBX.
355
+ // As we do so, scale the points by 100 to convert
356
+ // from m to cm.
355
357
foreach ( var controlPoint in ControlPointToIndex . Keys ) {
356
358
fbxMesh . SetControlPointAt ( new FbxVector4 (
357
- - controlPoint . x ,
358
- controlPoint . y ,
359
- controlPoint . z
359
+ - controlPoint . x * 100 ,
360
+ controlPoint . y * 100 ,
361
+ controlPoint . z * 100
360
362
) , ControlPointToIndex [ controlPoint ] ) ;
361
363
}
362
364
} else {
@@ -368,9 +370,9 @@ public void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, FbxScene fbxScene, b
368
370
{
369
371
// convert from left to right-handed by negating x (Unity negates x again on import)
370
372
fbxMesh . SetControlPointAt ( new FbxVector4 (
371
- - meshInfo . Vertices [ v ] . x ,
372
- meshInfo . Vertices [ v ] . y ,
373
- meshInfo . Vertices [ v ] . z
373
+ - meshInfo . Vertices [ v ] . x * 100 ,
374
+ meshInfo . Vertices [ v ] . y * 100 ,
375
+ meshInfo . Vertices [ v ] . z * 100
374
376
) , v ) ;
375
377
}
376
378
}
@@ -447,8 +449,9 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
447
449
448
450
// transfer transform data from Unity to Fbx
449
451
// Negating the x value of the translation, and the y and z values of the rotation
450
- // to convert from Unity to Maya coordinates (left to righthanded)
451
- var fbxTranslate = new FbxDouble3 ( - unityTranslate . x , unityTranslate . y , unityTranslate . z ) ;
452
+ // to convert from Unity to Maya coordinates (left to righthanded).
453
+ // 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 ) ;
452
455
var fbxRotate = new FbxDouble3 ( unityRotate . x , - unityRotate . y , - unityRotate . z ) ;
453
456
var fbxScale = new FbxDouble3 ( unityScale . x , unityScale . y , unityScale . z ) ;
454
457
@@ -609,9 +612,11 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
609
612
fbxSceneInfo . mComment = Comments ;
610
613
fbxScene . SetSceneInfo ( fbxSceneInfo ) ;
611
614
612
- // Set up the axes (Y up, Z forward, X to the right) and units (meters)
615
+ // Set up the axes (Y up, Z forward, X to the right) and units (centimeters)
616
+ // Exporting in centimeters as this is the default unit for FBX files, and easiest
617
+ // to work with when importing into Maya or Max
613
618
var fbxSettings = fbxScene . GetGlobalSettings ( ) ;
614
- fbxSettings . SetSystemUnit ( FbxSystemUnit . m ) ;
619
+ fbxSettings . SetSystemUnit ( FbxSystemUnit . cm ) ;
615
620
616
621
// The Unity axis system has Y up, Z forward, X to the right (left handed system with odd parity).
617
622
// The Maya axis system has Y up, Z forward, X to the left (right handed system with odd parity).
0 commit comments