Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Why is FBXImporter Scale Factor = 0.01??

Discussion in 'Editor & General Support' started by 7089yUu, May 2, 2010.

  1. 7089yUu

    7089yUu

    Joined:
    Feb 16, 2010
    Posts:
    27
    Why is the FBXImporter Scale Factor .01 and not 1.0? Is there a way to automate a scale conversion in Unity to make it 1.0?

    Since 1 Unit in Unity = 1 Meter, it seems logical that if I:
    1. Set my Maya Units = Meters
    2. Create a 1 Meter Cube with a scale of 1.0
    3. Set my FBX Export Units = Meters, which is a Scale Factor of 1.0.
    4. Import the FBX cube to Unity.

    that the cube would have a scale of 1.0 and the FBX Scale Factor would be 1.0. But since the FBX Scale Factor in Unity defaults to .01 (with no apparent way to change it aside from manually setting the value in the Inspector), the cube has a Scale = 1.0 but is in fact 100 times smaller than a 1 Unit Cube primitive created in Unity.

    The only way I've found to make units work automatically (where a scale of 1.0 in Maya is a scale of 1.0 in Unity) is to set:

    Maya Units = Meters
    FBX Export = Centimeters (Scale Factor = 100)

    This results in a Unity scene object with a scale of 1.0 that is the same size as a 1 Unit Cube primitive created by Unity. So to get a seamless export from Maya to Unity it appears your FBX Scale Factor MUST be 100. This eliminates the possibility of using Feet, which are the units I'd like to be using...

    Since the Maya FBX exporter only allows you to select from the menu a series of predefined units/scale factors, the only solution to using feet is to script the export process and set the Scale Factor = 100.

    Code (csharp):
    1.  
    2. //mel
    3. FBXExportScaleFactor [float]
    4. FBXExportScaleFactor -q
    5.  
     
  2. 7089yUu

    7089yUu

    Joined:
    Feb 16, 2010
    Posts:
    27
    Didn't work. The following code results in a cube with a scale = 100 and scale factor still = .01.
    Code (csharp):
    1.  
    2. FBXExportScaleFactor 100.0;
    3. FBXExport -f "C:Cube.fbx";
    4.  
     
  3. twitchfactor

    twitchfactor

    Joined:
    Mar 8, 2009
    Posts:
    333
    Yeah, I get the same thing with SketchUp. It's like gambling to figure out what you should set your units to and no matter what, it's either 10x too big or 100x too small.

    Someone out there must know the magic formula to export 1:1, so I can stop wasting time adjusting things in the inspector.
     
  4. 7089yUu

    7089yUu

    Joined:
    Feb 16, 2010
    Posts:
    27
    Code (csharp):
    1.  
    2. //Maya Units = Feet.
    3. //Converts from feet to meters * .01 Unity Scale Factor
    4.  
    5. global string $exportPath ;
    6.  
    7. global proc getFilePath (string $fileName , string $fileType) {
    8.     global string $exportPath ;
    9.     $exportPath = $fileName ;
    10. }
    11.  
    12. proc ExportToUnity() {
    13.     global string $exportPath;
    14.     fileBrowserDialog -mode 1 -fileCommand "getFilePath" -fileType "Fbx" -actionName "Specify" -ds 1 -wt "Specify output file"  ;
    15.     FBXExportScaleFactor 3.2808399;
    16.     FBXExport -f $exportPath;
    17.     print "Export complete. \n" ;
    18. }
    19.  
    20.  
     
  5. 7089yUu

    7089yUu

    Joined:
    Feb 16, 2010
    Posts:
    27
    There's an additional issue I've run into with regards to animation where the bones are scaled differently than the entire FBX asset, so the skin mesh is distorted. Seems like the best way around this (and still keep your units in feet) is to script the following:

    1. Switch Maya Units to Meters
    2. FBX Export Units = Centimeters (Scale Factor = 100)
    3. Export FBX.
    4. Switch Maya Units back to Feet.

    Will post some code if I get this working with animations.
     
  6. 7089yUu

    7089yUu

    Joined:
    Feb 16, 2010
    Posts:
    27
    Here's the finished code for exporting to Unity if you want your units in Maya to stay as feet, and have characters in Maya and Unity to have a scale = 1.0.

    Code (csharp):
    1.  
    2. global string $exportPath ;
    3.  
    4. proc ExportToUnity() {
    5.     global string $exportPath;
    6.     currentUnit -linear "meter";
    7.     fileBrowserDialog -mode 1 -fileCommand "getFilePath" -fileType "Fbx" -actionName "Specify" -ds 1 -wt "Specify output file"  ;
    8.     FBXExportScaleFactor 1;
    9.     FBXExport -f $exportPath -s;
    10.     print "Export complete. \n" ;
    11.     currentUnit -linear "foot";
    12. }
    13.  
    If you want to use an FBX Preset file, start with the standard Autodesk preset, change the Units to centimeter and save a new preset. Then use the following code to load the preset file when exporting. Why the ScaleFactor in the code above = 1.0, and the Scale Factor in the preset = 100.0 is still a mystery to me...

    Code (csharp):
    1.  
    2. global string $exportPath ;
    3.  
    4. proc ExportToUnity() {
    5.  
    6. global string $exportPath;
    7.     currentUnit -linear "meter";
    8.     fileBrowserDialog -mode 1 -fileCommand "getFilePath" -fileType "Fbx" -actionName "Specify" -ds 1 -wt "Specify output file"  ;
    9.     FBXLoadExportPresetFile -f "C:/Unity.fbxexportpreset";
    10.     FBXExport -f $exportPath -s;
    11.     print "Export complete. \n" ;
    12.     currentUnit -linear "foot";
    13. }
    14.  
     
    MV10 likes this.