UV mapping not working on imported obj file
Asked Answered
B

2

6

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)

enter image description here

But it ends up looking like this:

enter image description here

What happened to my UV mapping?

Braid answered 11/7, 2013 at 3:54 Comment(0)
P
2

Just flip the texture vertically and load the texture it will work fine.

You can do it using photoshop.

Paver answered 11/7, 2013 at 4:41 Comment(0)
D
12

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/.

Dough answered 11/7, 2013 at 23:56 Comment(2)
The version of libgdx that I'm using (downloaded the latest .zip yesterday) doesn't have that overload of loadModel. Thanks for bringing up the converter, though... that's definitely what I'll be using going forward. Also, welcome to Stack Overflow! Also, thanks for the tutorials, that was my first introduction to libgdx.Braid
If you use ObjLoader instead of ModelLoader you should have the flipV argument (ObjLoader loader = new ObjLoader();). You can also use the more general parameters: loader.loadModel(file, new ObjLoaderParameters(true));.Dough
P
2

Just flip the texture vertically and load the texture it will work fine.

You can do it using photoshop.

Paver answered 11/7, 2013 at 4:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.