ASE file texture encoding... help

Hello, I’m writing an ASE-file parser. Everything goes fine til i get to the texturing part. Ok, so how does it work? what are the t-vertex and t-faces? how do i read all that and stick it into a vertex array with the classical glTexCoord2f-style texcoords?
Urgent help, please.

Okay, I hope I am recalling this correctly. This is how i did it:

Okay, the *MESH_TVERT section of the ASE file is a list of texture vertices
that you should make into an array (in the same order specified).

*MESH_TVERT 0 0.00 1.00 0.00

This means:

Index 0
U = 0.00
V = 1.00
W(?) = 0.00

If you are only doing 2D texture mapping, you should only worry
about getting the U and V coords and putting them into your array

Now onto : *MESH_TFACE
This sections tells you which texture vertex index of the array to use for each 3
texture vertices of each face.
Example:


*MESH_TFACE 209 123 157 124

This means:
Current Texture Face Index is 209
Vertex 1 : Use TexVertex at Index 123 of your vertex array
Vertex 2 : Use TexVertex at Index 157 of your vertex array
Vertex 3 : Use TexVertex at Index 124 of your vertex array


So basically your TVERTS are a list of all the vertices that your
textures use. and your TFACE’s tell you which of those vertices
to use (for each textured face) by referring to vertex array.


Evertime you specify the mesh’s vertices with glVertex3f( … ) by getting your faces from the mesh-face array, you use the same index for getting your texture face vertices from your texture face array and send them to glTexCoord2f(… ); most ASE files have the same number of texture faces as mesh faces, so parallel arrays work like this work

In other words : each texture face ( TFACE ) corresponds to the mesh face ( FACE ) of the same index (in most cases)


I hope that this has made some sense.
If not let me know and i can send you some code
or explain further!


[This message has been edited by drakaza (edited 09-28-2000).]

Hey…

I’ll explain it from the start with some pseudo code as well:
This explains reading the TVertex bit. Here is the actual ASE
entry, followed by the C / Pseudo code




*MESH_NUMTVERTEX 561
*MESH_TVERTLIST {
*MESH_TVERT 0 0.00 1.00 0.00


parseString( ); // *MESH_NUMTVERTEX
numTVerts = parseInt ( ); // number of different texture vertices

parseString( ); // *MESH_TVERTLIST
parseString( ); // opening brace

// allocate an array that is numTVerts multiplied by 2 float entries (U and V coords)
TexVarray = malloc(numTVerts * (2*sizeof(float) ) );

FOR (each J from 0 TO numTVerts)
{
parseString( ); // *MESH_TVERT
parseInt( ); // Index. You can ignore this
TexVarray[J] [0] = parseFloat( ); // U value
TexVarray[J] [1] = parseFloat( ); // V value
parseFloat( ); // W value. Ignore this for 2D orientated textures
}


Now you have all of the texture vertices stored in your array
Now what you have to do is find out which of these texture
vertices is used for the 3 points of each texture face

These are the mesh vertices that you have stored…

Face[50].vertex[0][0] // X value of vertex 0 of face at index 50
Face[50].vertex[0][1] // Y value of vertex 0 of face at index 50
Face[50].vertex[0][2] // Z value of vertex 0 of face at index 50
Face[50].vertex[1][0] // X value of vertex 1 of face at index 50

ETC…ETC…

And these are the the texture coords that you are storing…

Face[50].tex_u[0] // U value of vertex 0 of face at index 50
Face[50].tex_v[0] // V value of vertex 0 of face at index 50
Face[50].tex_u[1] // U value of vertex 1 of face at index 50
Face[50].tex_v[1] // V value of vertex 1 of face at index 50

ETC…ETC…



*MESH_NUMTVFACES 960
*MESH_TFACELIST {
*MESH_TFACE 0 0 33 34


parseString( ); // *MESH_NUMTVFACES
numTVfaces = parseInt( ); // should be same as number of mesh faces
parseString( ); // opening brace

FOR (each K from 0 TO numTVfaces)
{
parseString( ); // *MESH_TFACE
parseInt( ); // Index. You can ignore this
IndexVert0 = parseInt( );
IndexVert1 = parseInt( );
IndexVert2 = parseInt( );

// Vertex 0
Face[K].tex_u[0] = TexVarray[IndexVert0] [0];
Face[K].tex_v[0] = TexVarray[IndexVert0] [1];

// Vertex 1
Face[K].tex_u[1] = TexVarray[IndexVert1] [0];
Face[K].tex_v[1] = TexVarray[IndexVert1] [1];

// Vertex 2
Face[K].tex_u[2] = TexVarray[IndexVert2] [0];
Face[K].tex_v[2] = TexVarray[IndexVert2] [1];

}


Now after all that is done and you are rendering each face:



FOR (ALL vertices (index) of the current face )
{
glTexCoord2f( face->tex_u[index], face->tex_v[index]);
glVertex3fv(face->vertex[index]);
}


I hope this has made things a bit clearer…
I can go into some more detail if you need more help

This is my biggest post, so bare with me if it makes no
sense!! It’s a bit hard explaining something that is tightly
in your head! Well let me know how it goes!