PDA

View Full Version : Specify texture order with CVA's



Ace_Man
04-07-2001, 06:33 PM
Hi,
I'm loading objects via the ASE format (from 3dsMax) and I seem to be missing something.
I've got the objects in, but I can't seem to figure out how to get the texture coords correct.

The ASE file has a list of tex coords and list of "orders" for the tex coords (just like like for the vertices/faces)

How do I specify the texture orders?

I'm using CVA's and here the snippet I use to render my scene....

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

for(int i = 1; i <= objCount; i++) {
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, objArray[i].texCoordArray);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), objArray[i].vertArray);

glLockArrays(0, objArray[i].vCount);
glDrawElements(GL_TRIANGLES, objArray[i].fCount, GL_UNSIGNED_INT,
objArray[i].faceOrderArray);
glUnlockArrays();
}

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

It's clear that I needed to specify the vertex list and the ordering for the model data (faces)...but how can I do the same with with the tex coords....

Before I startd using CVA's, I did all this in loops with GLBegin(GL_TRIANGLES) so it was no problem....

This question also apply's to Normals as well...Am I losing control over my data by sending it all at once, or am I just missing some trival function call?

Any help would greatly be appreciated...

Korval
04-07-2001, 07:01 PM
If I understand you correctly (I don't know what an "order" is, but I have my suspicions), your problem is that you have a face made of vertex position indices a, b, c and you want the texture coordinates to come from indices d, e, f.

Things don't work that way in OpenGL vertex arrays. You supply one index and it fetches from that index in all the arrays. Basically, what that means is that OpenGL requires each set of position, normal, texture coordinates, and colors that you want to use be unique. In other words, if you have a vertex position that uses two different texture coordinates (depending on which face you are looking at), then your vertex position array must have two copies of this position, one for each texture coordinate. The same goes for normals.