Archived

This topic is now archived and is closed to further replies.

albertoh

Texture coordinates in ASE File

Recommended Posts

Hello everybody. I''m new here. I have a model in 3DS Max with multiple textures. I want export it to .x file. For that, I first export to ASE file, and then convert it to X. The problem is in the ASE file: my model have 7806 vertices, but in some mapping channels the number of TVERTEX is more!! For example, the 2-nd channel have 8125. Some faces have diferent indices in the FACELIST, and the TFACELIST. For example in FACELIST : *MESH_FACE 239: A: 289 B: 288 C: 277 ... In *MESH_TFACELIST: *MESH_TFACE 239 289 7817 7818 And the model haven''t 7818 vertex!!! I can''t figure how to solve this problem. Sorry for my poor english. Thanks.

Share this post


Link to post
Share on other sites
Take a look at this other thread.

You have two lists of indices - one for the position of each face vertex (indexing into one array), and another for the texture coordinates of each face vertex (indexing into another array).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
there is no correspondence between the indicies of FACELIST and TFACELIST but there is a correspondence between the faces.

example :

FACELIST {
*MESH_FACE 0: A: 17 B: 216 C: 108
....
}

*MESH_VERTEX 17 6.9765 -0.8983 0.4645

*MESH_VERTEX 216 5.9331 -1.6804 0.2613

*MESH_VERTEX 108 0.4878 1.4634 0.0000

--------------------------------------------------

TFACELIST{
*MESH_TFACE 0 236 256 100
......
}
*MESH_TVERT 236 0.4444 0.1785 4.7473
*MESH_TVERT 256 0.5000 0.1785 4.7473
*MESH_TVERT 100 0.5556 0.1785 4.7473

*MESH_FACE and MESH_TFACE is the same face

but the indicies of FACE_LIST >*MESH_FACE points to
VERTEX_LIST > *MESH_VERTEX

and the indicies of TFACE_LIST >*MESH_TFACE points to
TVERTEX_LIST > *MESH_TVERTEX

i hope it is clear enough


Share this post


Link to post
Share on other sites
That''s understood. But, what happens when:
In *MESH_TFACELIST:
*MESH_TFACE 239 289 7817 7818

The vertices 7817, 7818 exist in TVERTEX_LIST, but not in VERTEXLIST. How can I calculate texture coordinates? That vertices haven''t position in space.
Or do you mean I must apply that texture coordinates to the correspondent vertices in MESH_FACELIST?

Thank you

Share this post


Link to post
Share on other sites
Okay, one more time :-)

MESH_TFACE 239 289 7817 7818

Translation: The three vertices of face number 239 use the texture coordinates numbered 289, 7817 and 7818

MESH_FACE 239 32 57 63

Translation: The three vertices of face number 239 use the positions numbered 32, 57 and 63

So... When setting the values of the three vertices for face number 239, you need to reference:

MESH_VERTEX 32
MESH_TVERT 289

MESH_VERTEX 57
MESH_TVERT 7817

MESH_VERTEX 63
MESH_TVERT 7818

Good luck.

Share this post


Link to post
Share on other sites
I usually do something like this when loading an ASE:
PSEUDOC++:


GetVertices();
GetTVertices();
GetFaces();
GetTFaces();

// Now all the data is loaded
struct Vertex
{
float x, y, z, tx, ty; // Position and tex coords
};

for(face = 0 to numFaces) (# of faces and tfaces are the same)
{
for(index = 0 to 3)
{
Vertex v;

// Build a vertex
v.(x,y, and z) = vertices[faces[face].Indices[index] ].(x, y, z)
v.(tx, ty) = tvertices[tfaces[face].Indices[index] ].(tx, ty)

// Insert the vertex into the list, using a duplicate if it exists
bool found = false;
for(i = 0 to meshVertexList.Size())
{
if(meshVertexList == v) // I have an overloaded == operator for my vertices
{
// We''ve found it in the list, so use the existing one,
// and don''t add the new one
newIndex = i;
found = true;
break;
}
}

if(!found)
{
// Wasn''t in the list, so add it to the end and use this index
newIndex = meshVertexList.Size();
meshVertexList.PushBack(v);
}

//Now that we know what the index in our actual vertex list will be,
//Add the new index to the index list
meshIndexList.PushBack(newIndex);
}
}



Hopefully you find that helpful (and hopefully I didn''t code that too poorly).

That''s generally the way I do the ASE loading (I get completely different indices in the long run, but I don''t end up with any vertices that are the same).

Again, hope that helps!


Josh

Share this post


Link to post
Share on other sites