Max Unity and fbx question.

Max Unity and fbx question.

jonathanjASQ6E
Contributor Contributor
3,163 Views
3 Replies
Message 1 of 4

Max Unity and fbx question.

jonathanjASQ6E
Contributor
Contributor

i have some questions about the fbx format, max and unity.

 

i use fbx a lot going between 3dsmax 2018 and unity.

i have found i need to set max system units to meters to get an un-scaled model in unity

and prior to export i need to rotate all objects pivots +90 on the local x axis to keep models from being pre-rotated -90 on the x in unity.

this is just how its done it seems 🙂

 

i have automated the process with a maxscript so i don't even notice the extra steps really, but it gnaws at me that i am missing something.

hopefully yall can give me a hand understanding what im not understanding. 🙂

 

its my understanding that an fbx file knows what coordinate system it was authored in, knows what system units it was authored in and in general has a fair amount of data to pull from. i have poked around in the ascii format fbx and it seems it would be a relatively simple task to take the information and produce a perfectly converted and orientated mesh in the target application.

 Question 1 : why don't fbx meshes brought into other programs come in with correct size and orientation and require scale and rotation to be applied automatically or by a users hand to fix? 

 

in all my tests with unity, max, and fbx i have found that setting the up vector in "Axis Conversion" to either Y-up or Z-up does nothing to change how unity imports the mesh. With either setting the mesh is imported into unity with a -90 x rotation. In the ascii fbx files i can find the lines where this data is set and stored so my thought is that unity just doesn't pay attention to it.

Question 2: What am i missing about axis conversion, is it a problem with max or unity or my understanding of what it is supposed to do?

 

rotating the pivot only on a mesh in max prior to export will cause the imported mesh in unity to have a rotation of 0,0,0. while this works, it is hardly ideal and is destructive especially with hierarchies and animations. i am unclear though as to how unity knows that i rotated the pivot and that it should not apply the -90 degree rotation on the x axis after import.

Question 3: how does unity or the fbx format know the difference between a mesh that is rotated 90 degrees on the X axis and a mesh that has had only its pivot rotated 90 degrees on the X axis?

 

what got me here is i decided to write a converter to "fix" an fbx after export or to write a more focused exporter/importer so that it would be happy living in unity. that way my max files don't need any changes to its  set up or system units and there is no cleaning up afterwards in unity. upon looking at the fbx format it just feels like it should already do this and i am hoping that i have just been missing something.

Question 4: any advice, suggestions or answers to questions i should have asked?

 

thank you in advance

-j

 

 

 

 

 

 

3,164 Views
3 Replies
Replies (3)
Message 2 of 4

ads_royje
Alumni
Alumni

Hi @jonathanjASQ6E

 

good questions ! 🙂

 

" Question 1 : why don't fbx meshes brought into other programs come in with correct size and orientation and require scale and rotation to be applied automatically or by a users hand to fix? 

"

For the Scale "issue", in Max <-> FBX translation a single 1.0 units of FBX equals a 1.0 cm in Max. To get no scaling, in Max set the System units to CM.

In Customize > Units Setup > System Units Setup

 

As you are already looking into the FBX ascii file, this is write into :

GlobalSettings:

P: "UnitScaleFactor", "double", "Number", "",1

If Max is in cm, the Scale Factor will be 1. Other units will give a UnitScaleFactor not 1 and importing in any other software would results in a Scale value applied to keep a relative size.

 

"

Question 2: What am i missing about axis conversion, is it a problem with max or unity or my understanding of what it is supposed to do?

 

Question 3: how does unity or the fbx format know the difference between a mesh that is rotated 90 degrees on the X axis and a mesh that has had only its pivot rotated 90 degrees on the X axis?

"

 

The Axis conversion may not do anything if the plugin importing "knows" the source, in this case, Max.

This info is in the header of the FBX file.

 

If the mesh comes in Unity not standing up, as I read. There was indeed a defect in 2018 when exporting a Mesh without any animation would have this effect as a results.

A fix for that issue is in Max 2018 update 1

If you do have the Update 1 and still have this issue, let me know.

 

"

Question 4: any advice, suggestions or answers to questions i should have asked?

"

 

You are asking the right questions!

 

I hope this gives you some answers 🙂

 

 

Message 3 of 4

jonathanjASQ6E
Contributor
Contributor

thank you for the response.

 

"For the Scale "issue", in Max <-> FBX translation a single 1.0 units of FBX equals a 1.0 cm in Max. To get no scaling, in Max set the System units to CM."

 

this is odd, i have found a max system units of "meters" gives the best results. using "centimeters" results in the asset in unity to have a 0.01 file scale. thankfully file scale in unity does its magic before the inspector reports the objects transform so for all intents and purposes scale is 1. i do sort of wish unity had the same for rotation so the re-orienting of the asset occurred before inspector reports the transform. that way scripts and what not would not require special considerations in place for dealing with rotation when directly on that object.

perhaps this just means the onus is on the target applications importer to make better use of the information contained with in the fbx file.

 

<soapbox>

in general though having to switch system file units really should only ever be done if you are encountering floating point error with large objects in files or want extra precision on very very small items in files. the decision should not be made lightly especially in light of the fact that if you someday need to change the system units on an in progress file you can make a lot of work for your yourself if the file is in anyway complex. 

 

from a  workflow perspective if you want to work in a different unit system just change the display units. production tools,  intermediary formats, and target applications should be fairly agnostic of each other and should be able to deal with things like system unit differences. 

</soapbox>

 

"If the mesh comes in Unity not standing up, as I read. There was indeed a defect in 2018 when exporting a Mesh without any animation would have this effect as a results."

 

max version is 2018.4

 

so standing up part is a bit tricky, as the model when placed in the editor window is indeed standing upright. the trouble is that the transform indicates the rotation is at -90 degrees. and if you look at the import settings on the model it shows the model laying on its side. this is true of both y-up and z-up exports. 

 

export as max intended:

MaxToUnityPivot0.png

if i rotate the pivot in max and then export:

MaxToUnityPivot90.png

so the rotating the pivot in max 90 degrees prior to export does result in what i am looking for in unity.

but i am concerned about whats going on under the hood and how unity can tell that the pivot has been altered.

it also suggests that altering pivots of an object could cause unintended and non obvious errors to occur.

especially since an object rotated 90 degrees in the normal fashion does not receive same treatment.

 

i am hoping to find a way around this rotating pivots just so it exports correctly is not good workflow.

 

Some questions:

how does fbx/unity/max determine the pivot has changed?

 

is the fbx format intended to be a universal format for going between autodesk applications?

 

is the fbx format intended to be a universal format for use by other applications?

 

is scaling the objects in an fbx file on import the intended method for dealing with unit conversions?

 

is rotating the objects in an fbx file on import the intended way to deal with axis conversions?

 

where might i find a "best practices" document for fbx development?

 

are there already any autodesk tools out there to alter an fbx after it is authored?

 

 

i just want to thank you again for all the patience and help it is much appreciated.

-j

 

 

0 Likes
Message 4 of 4

jonathanjASQ6E
Contributor
Contributor
from FBX SDK:
"Since objects in the FBX SDK are created by default in the right handed, Y-Up axis system, the vertices of a mesh should be defined accordingly."
and 
"Objects in the FBX SDK are always created in the right handed, Y-Up axis system. The scene's axis system may need to be converted to suit your application's needs. Consult the FbxAxisSystem class documentation for more information."
also
"The implicit coordinate system is in centimeters. It means that a plane with coordinates (0,0,0), (1,0,0), (1,1,0), (0,1,0) and all scaling/unit factors equal to one defines a "1x1 cm" plane."
 
upon opening up an ascii FBX file authored in max 2018 using the 2018 FBX exporter this is what you find:

 

1.
the vertices of a mesh are saved in the right handed Z-up and not the FBX standard quoted above. it is important to note the axis conversion option in the exporter has no effect on this.
2.
the vertices of a mesh are saved using the default system units and not the FBX standard described in the quotes above. it is important to note the unit conversion option in the exporter has no effect on the results.
this is complicated slightly by the "scaling/unit factors equal to one" part of the quote but ill get to that later.
3.
a meshes position is saved as "Lcl Translation" which is saved in units properly converted to the units set in the exporter and oriented to the up axis chosen in the exporter but seems to have the "handedness" switched.
 
4.

 the "Lcl Scaling:" property seems to be tasked with correcting the unconverted mesh vertices. this is affected by unit conversion in exporter.

5.

when a mesh has had its pivot rotated (as is commonly suggested to do to get better imports from max to unity) the property "GeometricRotation" stores this data. this suggests that mesh vertex locations are not relative to the altered pivot but rather the initial position pivot was at object creation in max.

 
 
 
all this leads me to believe that the core problem is the following:
 
1. Max does not import FBX vert data correctly and improperly uses scale to make the asset appear "sized" in the Max viewport.
 
2. "File units converted to:" option in importer does not work as expected.
 
3. Max does not export  FBX vert data or in the correct coordinate system nor in the correct units and misuses "Lcl scalng","PreRotation" and in some cases "GeometricRotation" to make up for this. 
 
4. "Scene units converted to:" option in exporter does not function as expected.
 
5. "Up Axis:" option in exporter seems to not be used correctly..
 
 
i do worry that if the problem were this obvious that it would have been fixed long ago, this makes me think i might be missing something.
hope you can help clear this all up.
 
thank you again.
-j
 
 
 
0 Likes