You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BugGlobal flag to mark a deviation from expected behaviourExplanationGreat discussion / explanation other users can learn fromFBXBugs related to the FBX formatOrientationQuestions/problems related to 3D model orientation (e.g. "up" direction respected on import)PostprocessingIssues regarding the post-processing steps.
I'm trying to load an fbx model with Assimp in Unity. And I'm sorry, there was a little mistake in my first question, I have edited it. Actually I'm using Assimp.Net version 3.0, because with the latest release of it or the code from the master branch an exception is thrown at the file importing step.
AssimpImporter importer = new AssimpImporter();
MeshVertexLimitConfig m = new MeshVertexLimitConfig (meshVertexLimit);
importer.SetConfig (m);
Scene model = importer.ImportFile(path + '/' + modelName,
PostProcessSteps.SplitLargeMeshes |
PostProcessSteps.OptimizeGraph |
PostProcessSteps.OptimizeMeshes |
PostProcessSteps.Triangulate |
PostProcessSteps.SortByPrimitiveType |
PostProcessPreset.TargetRealTimeMaximumQuality
);
I have found some points about the issue. My exported model has Z-up axis, instead of Y-up axis (unlike assimp), that's why the model is rotated. Is there a way I can get that info from the model (how the axises are set up in the model)?
Thanks.
Up-axis usually taken from file format specification. Or from description of a camera if scene is contain it.
Also you must pay attention to your graphics library. For example - OpenGL by default has Y-up axis.
Hey I have a similar issue but annoyingly everything LOOKS fine when imported, but the Armature itself when I peek at the code is rotated by 90 degrees, this means when I try to get the world space coordinates of the bones, all non-root bones have the Y and Z columns flipped and with the wrong sign.
I think Assimp may be applying the wrong transform to mRootNode. Isn't a scene-level, root node transform supposed to be identity? Here's my debug output for scene->mRootNode->mTransform for a Z_UP COLLADA file containing two sibling boxes at the scene level:
Inside the COLLADA file, the only transform matricies specified are on the boxes themselves, not on the scene node, so I expected this to be an identity mat4. If I manually do scene->mRootNode->mTransformation = aiMatrix4x4(); before processing the tree, everything works as intended. If this isn't supposed to be an identity matrix, what is it?
I can send the COLLADA file if it assists in reproducing the (possible) issue.
Reacted by Blayne, Liam Zhang, veyvin, tigertang and HandsomeXi
@ne0ndrag0n I think its because whatever program you used uses different coordinates; its similar I think to my problem above; for me, blender is Z up and Y forward; but when imported it's rotated 90 degrees if I don't have "Experimental apply transforms" enabled.
Similarly I get problems with the Blender bone orientations; depending on their bone roll ASSIMP doesn't import them in properly.
@ruzannakamalyan@kimkulling I just came across the same issue. A model (fbx) that is correctly rotated when dragging into Unity's project folder structure is rotated 90 degree around the x axis relative to its coordinate system when imported through TriLib. When I do the following in the AssetLoader.cs (703) its correct, but since it depends on the model I can't do that:
Since this is an AssimpInterop call (native) I don't even know how to fix that.
Did you guys have a solution for this, implemented or recommended or anything?
I also am currently facing this issue. Is there any solution? Other than manually fixing matrix while parsing? I am using aiProcess_MakeLeftHanded, since I am using DirectX. however, its still rotated sideways. You would have to flip the y, and z axis, but internally it might be calculating using wrong rotation.
Apparently, FBX allows some arbitrary orientations of the default axis, blender also supports it, but when loading it through assimp, those orientations are not reflected by default. You have to read them from the metadata.
I think assimp should do this automatically. It's just checking if that data is present, and if so, assign it to the root node.
It may be format specific, but that's why we're using assimp, to abstract from that.
Reacted by Bradford Medeiros, Antonio and xusjtuer
Found this thread yesterday and since I'm using the AssimpNet wrapper and was having the same problem I thought maybe I could fix this in blender since I'm not really keen to change any cpp then do all the other steps to make it load properly in Unity.
What it does is use the official valve plugin to load the SMD, then I apply the rotation, save it to a new folder and reload the entire project as a new file. That way the process won't eventually fill up and get extremely slow
I think the issue is also because assimp does not respect the root node transformation of the scene hierarchy. I've been messing around with it and it seems that it will swap axes, and while it can output correctly to GLB if the root node transform rotates it, with FBX modifying the root node transform does not seem to have any effect regardless of what the transform is
BugGlobal flag to mark a deviation from expected behaviourExplanationGreat discussion / explanation other users can learn fromFBXBugs related to the FBX formatOrientationQuestions/problems related to 3D model orientation (e.g. "up" direction respected on import)PostprocessingIssues regarding the post-processing steps.
Activity
kimkulling commentedon Apr 5, 2016
Have you used the transformation matrix of the root node?
ruzannakamalyan commentedon Apr 5, 2016
Hi Kim, thanks for your prompt answer. I'll post the processing function. The first call is for model.RootNode, where the model is the imported model.
kimkulling commentedon Apr 6, 2016
Hm, which loader are you using. Maybe there is something wrong. Your code looks fine for me.
ruzannakamalyan commentedon Apr 6, 2016
I'm trying to load an fbx model with Assimp in Unity. And I'm sorry, there was a little mistake in my first question, I have edited it. Actually I'm using Assimp.Net version 3.0, because with the latest release of it or the code from the master branch an exception is thrown at the file importing step.
ruzannakamalyan commentedon Apr 8, 2016
Hi @kimkulling ,
I have found some points about the issue. My exported model has Z-up axis, instead of Y-up axis (unlike assimp), that's why the model is rotated. Is there a way I can get that info from the model (how the axises are set up in the model)?
Thanks.
smalcom commentedon Aug 1, 2016
Up-axis usually taken from file format specification. Or from description of a camera if scene is contain it.
Also you must pay attention to your graphics library. For example - OpenGL by default has Y-up axis.
BBlayne commentedon Oct 17, 2016
Hey I have a similar issue but annoyingly everything LOOKS fine when imported, but the Armature itself when I peek at the code is rotated by 90 degrees, this means when I try to get the world space coordinates of the bones, all non-root bones have the Y and Z columns flipped and with the wrong sign.
ne0ndrag0n commentedon Dec 31, 2016
I think Assimp may be applying the wrong transform to mRootNode. Isn't a scene-level, root node transform supposed to be identity? Here's my debug output for
scene->mRootNode->mTransformfor a Z_UP COLLADA file containing two sibling boxes at the scene level:Inside the COLLADA file, the only transform matricies specified are on the boxes themselves, not on the scene node, so I expected this to be an identity mat4. If I manually do
scene->mRootNode->mTransformation = aiMatrix4x4();before processing the tree, everything works as intended. If this isn't supposed to be an identity matrix, what is it?I can send the COLLADA file if it assists in reproducing the (possible) issue.
BBlayne commentedon Dec 31, 2016
@ne0ndrag0n I think its because whatever program you used uses different coordinates; its similar I think to my problem above; for me, blender is Z up and Y forward; but when imported it's rotated 90 degrees if I don't have "Experimental apply transforms" enabled.
Similarly I get problems with the Blender bone orientations; depending on their bone roll ASSIMP doesn't import them in properly.
kimkulling commentedon Apr 18, 2017
Any chance to get the Collada model? And sorry for my late response!
Kim
catdsnny commentedon Mar 24, 2018
Had the same issue when loading a model into opengl based C++ engine. Flipping Y and Z coordinates on load solved the problem for me.
Alexees commentedon Mar 29, 2018
@ruzannakamalyan @kimkulling I just came across the same issue. A model (fbx) that is correctly rotated when dragging into Unity's project folder structure is rotated 90 degree around the x axis relative to its coordinate system when imported through TriLib. When I do the following in the AssetLoader.cs (703) its correct, but since it depends on the model I can't do that:
Since this is an AssimpInterop call (native) I don't even know how to fix that.
Did you guys have a solution for this, implemented or recommended or anything?
JrIndie commentedon Jun 18, 2018
I also am currently facing this issue. Is there any solution? Other than manually fixing matrix while parsing? I am using aiProcess_MakeLeftHanded, since I am using DirectX. however, its still rotated sideways. You would have to flip the y, and z axis, but internally it might be calculating using wrong rotation.
I am using blender exporting to collada.
kimkulling commentedon Dec 8, 2018
I was pretty sure that this one should be fixed already. But unfortunately it seems to be still there.
20 remaining items
jpincho commentedon Jul 7, 2021
Apparently, FBX allows some arbitrary orientations of the default axis, blender also supports it, but when loading it through assimp, those orientations are not reflected by default. You have to read them from the metadata.
I think assimp should do this automatically. It's just checking if that data is present, and if so, assign it to the root node.
It may be format specific, but that's why we're using assimp, to abstract from that.
seyitcemyilmaz commentedon Nov 30, 2022
It solved my wrong rotationed bone problem. Thank you very much.
Danil0v3s commentedon Aug 12, 2023
Found this thread yesterday and since I'm using the AssimpNet wrapper and was having the same problem I thought maybe I could fix this in blender since I'm not really keen to change any cpp then do all the other steps to make it load properly in Unity.
Here's the gist https://gist.github.com/Danil0v3s/4c923d51d148d61a3b4feaf34b77a644
What it does is use the official valve plugin to load the SMD, then I apply the rotation, save it to a new folder and reload the entire project as a new file. That way the process won't eventually fill up and get extremely slow
JulianKnodt commentedon Sep 18, 2023
I think the issue is also because assimp does not respect the root node transformation of the scene hierarchy. I've been messing around with it and it seems that it will swap axes, and while it can output correctly to GLB if the root node transform rotates it, with FBX modifying the root node transform does not seem to have any effect regardless of what the transform is
netpenthe commentedon Sep 28, 2023
+1, would be great to fix
kimkulling commentedon Mar 13, 2024
After a looong period of time I found the issue again: #5494
Feedback would be hightly appreciated.
livinamuk commentedon Mar 18, 2024
This is huge. Thank you.