-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imported Model is rotated by 90 degrees #849
Comments
Have you used the transformation matrix of the root node? |
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.
|
Hm, which loader are you using. Maybe there is something wrong. Your code looks fine for me. |
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.
|
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)? |
Up-axis usually taken from file format specification. Or from description of a camera if scene is contain it. |
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
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 I can send the COLLADA file if it assists in reproducing the (possible) issue. |
@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. |
Any chance to get the Collada model? And sorry for my late response! Kim |
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. |
@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. |
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. |
I was pretty sure that this one should be fixed already. But unfortunately it seems to be still there. |
I encountered a strange version of this bug where only the mesh y and z are swapped, the skeleton is properly oriented. The model is a collada file, that seemingly got exported from Max. It can be found here: The flags I used to import the model are: I would add that, though the model is facing upwards in blender, the skeleton is aligned to the model. |
@kimkulling I guess the error is caused because the root node is transformed when a different Y axis value is found, but the application that loads the model isn't aware of this orientation and reset the root node rotation according the values user passes. I've fixed it in TriLib by adding a new node on the top of the root node, to mantain the original matrix. |
I'm having the same issue using latest assimp code built from source in git. The problem shows up in open3dmod too - in both cases the object is on its side. But if I open the same file in Blender (2.79 or 2.80b) or in the Windows 3D file viewer, it is oriented properly. File is attached. Edit: I also imported it into UE4 and uploaded it to https://viewer.autodesk.com and they also show it oriented as expected. |
encountering the same issue with Assimp.Net (3) (also loading via Unity), when I perform -90 rotation to correct for YZ flip. To solve I have to flip each vectors X-Axis manually, and also apply reverse winding order. Unity Workaround (Assimp.Net) (assumes you dont need tangents, you you can just flip X axis there too), you do not need to adjust UVs. // Per Vertex:
#if ASSIMP_BUG_WORKAROUND
vert.x = -vert.x;
nrm .x = -nrm.x;
#endif
#if ASSIMP_BUG_WORKAROUND
// Assimp Config (to solve faces flipping and facing inwards)
steps |= PostProcessSteps.FlipWindingOrder;
#endif |
I also have this issue on a few models. On these models, this seems to be caused by the"UpAxis" and "FrontAxis" (GlobalSettings) properties not being used. Assimp reads these and saves them, but does not seem to use them for anything. Should these be applied to the root node transform maybe? I can't find much documentation about "UpAxis" and "FrontAxis", but after some testing I have the impression that: Example:
|
Update:
etc.. Converting the 0,1,2 values to unit vectors vectors (right, up, forward), constructing a matrix from these and multiplying the scene's root node transform by it solved the issue for me. Creating the matrix:
And then finally, multiply the @kimkulling should this be done automatically, or is it better to leave it up to the developer? It seems like FBXSDK does this automatically. |
And here are some test models: To test, open "XYZ arrows ascii.FBX" and modify the axis information (under "GlobalSettings"). If anyone wants to test that their results are correct, you can open the model in FBX Review to compare. |
@mlavik1 thanks for your job, works fine |
I would say do it automatically makes sense for me. As far as I know previous users encountered the sme problem before. |
+1 to that issue. If any1 could add a setting/config where we could specify up/front/right axis and let the system auto convert it to correct axis that would be great! And if any1 can remove the darn "$AssimpFbx$" transform hierarchies for FBX imports that would be a lot of help too... half of my data import out of wack :- ) |
+1 would kill for a real fix |
+1, guys it's been over 4 years since it was opened.. |
+1 |
1 similar comment
+1 |
I wonder whether blender export module for fbx is broken or it's still assimp malfunction. The thing is that if you export .obj in blender and you set export axes properly you will get correct output in desired coordinate system. In case of FBX - blender allows for setting up axes but during assimp import you'll get no results. As someone stated in #456 - assimp makes no transformations so it means blender exporter is invalid and if you import any fbx you need to fix its orientation. Well, I don't know the fbx internals, but it's also possible that this format tends to live in Z-up. PS: I know it's old, but it's possible that someone will have problm with blender export and rotated axes. |
Also encountering the issue with blender / assimp combo (just using a build of assimp of head). I haven't verified if it's assimp or the fbx file being exported from blender. Might be useful for the above people to reply if this is also happening only in blender or elsewhere as well. Maybe not in the scope of assimp, but esp since fbx model format harder to read, I assume this gets confusing for people using the library. Wonder if there are any good analysis tools to deconstruct the fbx file so I can definitely say this is on blender |
I'm currently using this snippet of code to fix that orientation, and it works perfectly for me.
Then obviously reading the value from mTransformation :) |
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. |
It solved my wrong rotationed bone problem. Thank you very much. |
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 |
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 |
+1, would be great to fix |
After a looong period of time I found the issue again: #5494 Feedback would be hightly appreciated. |
This is huge. Thank you. |
Hi,
I'm using the latest version of Assimp and Assimp.Net 3.0 release.
After Importing I'm getting the model rotated by 90 degrees.
Any suggestions on what I'm missing?
The text was updated successfully, but these errors were encountered: