The texture matrix, and vertex winding

I have read my copy of “The OpenGL Super Bible” several times now… along with the red and blue books online, and searched every possable forum and news group and cant get any solid answers to my seemingly simple problems… So…

Here is the setup so far…
My engine has been designed so that all coordinates, whether they be for 2D images or textures, are all what I call “surface orientated”. That means simply that ( 0, 0 ) is the upper left, and ( w, h ) is lower right. When implementing this strategy obvoiusly i found that OpenGL does things differently. I had some options on how to handle this… 1) invert all y/h coordinates on the fly or 2) invert the texture matrix. Well it seemed simple to me. Inverting all the coordinates every frame would be bad so simply invert the texture matrix and be done. The following is done during thw window setup after the window and RC is created and various other perameters are set.

glMatrixMode( GL_TEXTURE );
glTranslatef( 0.5f, 0.5f, 0.0f );
glScalef( 1.0f, -1.0f, 1.0f );
glTranslatef( -0.5f, -0.5f, 0.0f );
glMatrixMode( GL_MODELVIEW );

Well… at the time of trying this out i had not reached the point of implementing the 2D interface portion of this engine and all i was concerned with was proper texture coords coming from ASE files exported from 3ds MAX… Yea, Yea, i know… “Stop with the ASE files…”… Anyway thats my first question… Are the coords in an ASE file orientated the same as OpenGL…??? i.e. ( 0, 0 ) == lower left… So… I did some simple test to find out… i jus made a single two triangle plane and then looked @ the exported ASE file it appeared they were in the place i thot they should be ( 0, 0 ) TOP left… “Good” i say… With the texture matrix inverted there should be no problem… and there wasnt… everything came out right after inverting the tex matrix… “Woo Hoo” i say…
Well I am also a left hander and the way the OpenGL axis system is set up seems foreign to me so at the begining of every scene the before the inverse camera matrix is applied is the following…

// Already in GL_MODELVIEW mode
glScalef( 1.0f, 1.0f, -1.0f );
// Multiply inverse camera matrix

// Multiply world matrix…

This also works just fine…
But then i came to implementing basic object like a skybox, billboard, and the 2D interface system (speciffically text)… I am pretty sure I am just uninformed on exactly wich point of view the direction of a ploys vertex winding is judged and if inverting the texture matrix had the effect i thot it was supposed to have. example: the billboard… the vertex indices and mapping coords are static data shared among all instances of the class and the 4 vertices are set when the size of the billboard is set. All object in this engine draw themselves like most all engines out there like this…

// …
renderer->selectMaterial( pMaterial );
renderer->pushTransform( mTransform );
renderer->drawTriangleMesh( 4, pVertices, 6, pIndices, pMapping );

The problem is that the billboard ( and all other objects i have hand coded, like the skybox and text ) have their textures upside down… Here is the data for the billboard…

const rIndex pIndices[6] = { 0, 1, 2, 0, 2, 3 };
const rMapCoord pMapping[4] = {
{ 0.0, 0.0 },
{ 0.0, 1.0 },
{ 1.0, 1.0 },
{ 1.0, 0.0 } };

And this is the setSize function…

void rBillboard::setSize( rReal w, rReal h )
fWidth = w;
fHeight = h;

w *= (rReal)0.5;
h *= (rReal)0.5;

pVertices[0].x = pVertices[1].x = -w;
pVertices[2].x = pVertices[3].x = w;
pVertices[0].y = pVertices[3].y = h;
pVertices[1].y = pVertices[2].y = -h;
// Vertices.z is all zero

// Calculate bounds for clipping… etc…
// …

If i dont invert the texture matrix everything comes out correctly… And that is where I am confused… What i am thinking is that when a texture is uploaded to the GL i am not flipping it so it goes in top row first… That says to me that tex coord ( 0, 0 ) would be the top left of the texture… which is where i want it to be… but w/o inverting the tex matrix geometry loaded from the ASE files draws with the tex’s flipped… i guess that goes back to my ASE format problem…

So after this excessively long and drawn out post, i think i can simplify my questions…

  1. should i be inverting the texture matrix so the GL will be set correctly for the “surface orientation” of the texture coords…

  2. Accounting for #1 … what is the deal with ASE files and the tex coords in them…? Should i be inverting the v coord in an ASE file and not the tex matrix…???

  3. Can someone clarify winding order in a way i can see in my head… ex. should the billboard vertices be ordered clockwise or counter with respect to its normal…??? meaning when the billboard size is set am i specifying the vertices as if i am lookin @ the normal towards the front face or down the normal lookin @ the back face…???

         Thank you in advance...

I’d like to say follow what OpenGL gaves for you. If you need to do some invertions, then do them on loading, just once. So, if you texture coordinates are inverted, then change them during the model loading. Also avoid inverting z-axis or so because this will pervade how the drawings are done.

Hope this helps.