1
\$\begingroup\$

I have made a 3D game engine, and as part of this I use Assimp to load in meshes to my game. One of the meshes I load in is my terrain.obj mesh that I made and exported from Blender(Version 2.82). The issue is that I noticed in my game the terrain is flipped, for example in Blender a certain mountain will have a valley next to it, but in my game that valley and mountain are at opposite sides of the mesh from each other, as if the model in my game has had its mesh vertices flipped on an x or z axis, I don't understand why this is happening, I would assume the model I export from Blender and load into my game with assimp should be identical.

My blender export settings are as follows:

enter image description here

The image you see above is the default export settings, I have changed nothing except I scale the model up by x64 and untick the write materials option.

My assimp code that loads in the mesh is as follows:

Assimp::Importer importer;

        const aiScene* scene = importer.ReadFile(("../res/models/" + fileName).c_str(), 
                                                 aiProcess_Triangulate |
                                                 aiProcess_GenSmoothNormals | 
                                                 aiProcess_FlipUVs |
                                                 aiProcess_CalcTangentSpace);

I noticed that aiProcess_FlipUVs sounded suspect because of the word "flip", and could possibly be the issue so I commented it out and this actually made the mesh load in exactly as it is in blender, that is all the hills and valleys are where they are supposed to be and not at opposite sides of the terrain from each other. But commenting this out also made the game world (terrain mesh) load in upside down, and upon swinging my camera around completely so that it was the write way up, my look controls (up / down / left / right) are all inverted.

Therefore, does anyone know how to correctly export the mesh from Blender and import it using Assimp so that the mesh exported from Blender is identical to the mesh imported with Assimp without removing the line of code aiProcess_FlipUVs as it may have solved the flipped mesh vertices issue but my controls and game world are inverted. I am new to Blender and Assimp so there must be something I am doing wrong or have missed.

\$\endgroup\$
3
  • \$\begingroup\$ In the end, I think the issues with the mirrored meshes, the inverted camera controls etc has to do with Blender's coordinate system and the coordinate system you're using in your code base. Make sure that the systems are correctly aligned. \$\endgroup\$ Feb 27 '20 at 16:12
  • \$\begingroup\$ @Daniel_1985, Blender has the "up/down" axis as the x axis while I am editing and moving around the scene, whereas in my game world the y axis handles up/down movement, so I would think maybe that is the issue, but as you can see from my attached image in the above question the .obj is exported with Forward as "-Z Forward" and up as "Y up", so it looks like it already changes this for me? \$\endgroup\$ Feb 27 '20 at 16:55
  • \$\begingroup\$ Are your game's coordinates left-handed or right-handed? \$\endgroup\$
    – DMGregory
    Feb 27 '20 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.