Texture Coord Generation

Ok I’m having trouble with the automatic texture coord generation with opengl. I have looked at the rebook online, etc, and still do not fully understand how it works. Would someone use it to assign texture coords to objects in object space one time? or every frame? …

I’m only asking this because I cannot get my texture mapping to work properly. Example: If I have terrain to texture map I would think that the best way to map it would be to use planar mapping. I know how this algorithm works (I think) but the problem is that my textures will not line up if some triangles mostly on the xz plane are next to other triangles on a xy plane… THE planes to not match up…

does anyone know what I mean?? and if not I can try to explain it in another way…

Thankx,

Mongoose

Every frame, in fact, every time the object is drawn, if you are drawing it more than once in a given scene. At least that’s how I do it and it works just fine.

Mongoose,

Why don’t you post some source code and/or pseudocode to show how you’re using texgen. Maybe we could offer some assistance after looking at it.

Thanks -
Cass

ok here’s a quick example of the functions i have

INITIALIZE CODE

// create the camera
gpCam = new cCamera(
cVector2( (float)sx, (float)sy ),
cVector3( 0.0f, 0.0f, 150.0f ),
cVector3( 0.0f, 0.0f, 0.0f ) );

// load some textures
jvLoadTexture( tidRock, IDB_ROCK );

// create dummy object
vrts[0].set( 0.0f, 15.0f, 0.0f );
vrts[1].set( -20.0f, 5.0f, 0.0f );
vrts[2].set( -10.0f, -12.0f, 0.0f );
vrts[3].set( 10.0f, -12.0f, 0.0f );
vrts[4].set( 20.0f, 5.0f, 0.0f );
vrts[5].set( 0.0f, 0.0f, -10.0f );

// texture coord generation information
GLfloat sPlane[4] = { 0.05, 0.03, 0.0, 0.0 };
GLfloat tPlane[4] = { 0.0, 0.03, 0.05, 0.0 };

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
glTexGenfv(GL_S, GL_OBJECT_PLANE, sPlane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tPlane);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

’ RENDERING FUNCTION

// bind texture
glBindTexture( GL_TEXTURE_2D, tidRock );

glBegin( GL_TRIANGLE_FAN );
glVertex3fv( vrts[5].ary() );
glVertex3fv( vrts[0].ary() );
glVertex3fv( vrts[1].ary() );
glVertex3fv( vrts[2].ary() );
glVertex3fv( vrts[3].ary() );
glVertex3fv( vrts[4].ary() );
glVertex3fv( vrts[0].ary() );
glEnd();

… and that’s the short end of it…
I’m just not sure what the 2 planes are for when I try to have openGL map my coords automatially… I end up with a few triangles correctly rendered out of the pyramid but not all of them…

any info would help thankx,