0
$\begingroup$

For two days I've been puzzled when trying to properly export UVs for vertices. Unfortunately when I load model in game engine, mapping isn't correct.

I found few threads about this process and tried to export few test files, but It's not clear to me. Maybe someone can help me here. Let's have example cube mapped with texture, then triangulated. According to this thread, little bit modified result is as pasted below (vertex index, loop index, u, v):

3 0 0.0 0.0
2 1 1.0 0.0
0 2 1.0 1.0
7 3 0.0 0.0
6 4 1.0 0.0
2 5 1.0 1.0
5 6 0.0 0.0
4 7 1.0 0.0
6 8 1.0 1.0
1 9 0.0 0.0
0 10 1.0 0.0
4 11 1.0 1.0
2 12 0.0 0.0
6 13 1.0 0.0
4 14 1.0 1.0
7 15 0.0 0.0
3 16 1.0 0.0
1 17 1.0 1.0
1 18 0.0 0.0
3 19 1.0 0.0
0 20 1.0 1.0
3 21 0.0 0.0
7 22 1.0 0.0
2 23 1.0 1.0
7 24 0.0 0.0
5 25 1.0 0.0
6 26 1.0 1.0
5 27 0.0 0.0
1 28 1.0 0.0
4 29 1.0 1.0
0 30 0.0 0.0
2 31 1.0 0.0
4 32 1.0 1.0
5 33 0.0 0.0
7 34 1.0 0.0
1 35 1.0 1.0

So here is question I'm trying to find answer for at this point: - Vertex with given index is repeated exactly 4 times. For example, vertex with index 3 have is represented by two sets of different UVs. Why? If all considered entries are describing vertex number 3, shouldn't they be identical?

This is the most important for format I want to export mesh to. This is how format look like:

TRANSLATE 0 0 0
ROTATE 0 0 0

SUBMODEL Cube
V -1.0 -1.0 -1.0 0.0 0.0
V -1.0 1.0 -1.0 1.0 0.0
V -1.0 -1.0 1.0 1.0 1.0
V -1.0 1.0 1.0 0.0 0.0
V 1.0 -1.0 -1.0 1.0 0.0
V 1.0 1.0 -1.0 1.0 1.0
V 1.0 -1.0 1.0 0.0 0.0
V 1.0 1.0 1.0 1.0 0.0
TRI 3 2 0
TRI 7 6 2
TRI 5 4 6
TRI 1 0 4
TRI 2 6 4
TRI 7 3 1
TRI 1 3 0
TRI 3 7 2
TRI 7 5 6
TRI 5 1 4
TRI 0 2 4
TRI 5 7 1
TEXTURE tex.dds
ENDSUBMODEL

Vertices are described by X Y Z U V. I already tried to loop all faces and store UVs in dictionary, where key of dictionary is index of vertex. But this not seem to work correctly.

Thank you in advance!

$\endgroup$
0
$\begingroup$

I just solved this problem. My thinking was wrong. I realized, that it is impossible to draw meshes using indices when one vertex is shared among few faces, where each face has different UV mapping on that vertex. The solution was to change format to face list.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.