I have exported an .obj file (along with .mtl and a .png) from Blender to import into a libgdx project. The file contains both UV and normal data.
I am pulling the file into the app like this:
ModelLoader loader = new ObjLoader();
model = loader.loadModel(Gdx.files.internal("data/car.obj"));
The object should look like this: (Yes, I'm not an artist)
But it ends up looking like this:
What happened to my UV mapping?
The UV Map isn't visible in the UV Editor In short, check these things first. The first solution is to make sure our Mode is Set to Edit Mode in the 3D viewport. We can do this by pressing Tab, or by going to the mode menu in the top left corner of the 3D viewport.
No, a . obj file does not contain textures.
Select your object. Go to UV > Unwrap > Smart UV Project. The following dialog will appear. Click OK to generate your UV mapping.
Go to object dat properties panel, open the uv maps section and delete the current uv map. Then just create a new one. That fixed it for me .
Use loader.loadModel(Gdx.files.internal("data/car.obj"), true);
to flip the vertical texture coordinates. You can also flip vertical textures coordinates while converting to the g3dx file format: fbx-conv -f car.obj
(-f is for flip vertical texture coordinates), which will give you a file called car.g3db and is more suitable for rendering. More info on how to load and convert models (and flip texture coordinates) etc. can be found here: http://blog.xoppa.com/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With