Mesh UVs Question

Hey, could someone please explain to me how a cube mesh has 20 uv coordinates? (Vec2’s)


vt 1.0000 0.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vt 1.0000 0.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vt 1.0000 0.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vt 1.0000 0.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vt 1.0000 0.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vt 1.0000 1.0000
vt 1.0000 1.0000
vt 1.0000 1.0000
vt 1.0000 1.0000
vt 1.0000 1.0000

It just doesn’t add up. I’m trying to write an exporter, and when I use the code from the export_obj.py for UVs, I got 4 coordinates exported :confused:


vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000

When I export UV coordinates per vertex, per face, I get 24 vec2’s…


vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000

But blender’s built in .obj exporter writes 20 vec2’s. Which seems to be the correct number, even though I have no idea why and how it adds up?

Thank you in advance for all the help

you obtain 24 vec because the cube have 6 faces, each face 4 vertices = 6*4 = 24. that mean that you check the same vertex multiple times.

That is correct, yes. Isn’t that what you normally do? I mean each vertex in each face can have a different uv coordinate, so you do want to check each vertex of each face. But for some reason, the built in .obj exporter writes 20?!

How is that 20?! Even if it indexed the values, it still doesn’t add up. 20 uv coordinates is just an weird number that I don’t understand how to calculate myself…

Maybe it’s something to do with some vertices sharing UV coordinates and others being unique. Try editing the UV map so each face has a unique set of min and max UV numbers. That might help you investigate.