PDA

View Full Version : AutoTexture 3D Coord Gen Prob



DarthPaul
07-03-2002, 10:46 AM
I'm having a problem with the automatic texture coordinate generation. The x and y directions are fine I'm just having a problem with getting the next slices.


Here's the code I use for generating the texture coordinates.
static GLfloat splane[4] = {-1.f/(float)(Wslices*2), 0.f, 0.f, .5f};
static GLfloat tplane[4] = {0, -1.f/(float)(Hslices*2), 0, .5f};
static GLfloat rplane[4] = {0, 0, 1.f/(float)(Dslices*2), 0.5f};

glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

glTexGenfv(GL_S, GL_OBJECT_PLANE, splane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tplane);
glTexGenfv(GL_R, GL_OBJECT_PLANE, rplane);


Here was the code before the auto gen:
for(int i = 0; i < Dslices; i++)
{

glBegin(GL_QUADS);
glTexCoord3f(1.0f, 1.0f, (float)i/(float)(Dslices-1));
glVertex3f(-widcoord, -htcoord, -(depthcoord*Dslices)/2);
glTexCoord3f(1.0f, 0.0f, (float)i/(float)(Dslices-1));
glVertex3f(-widcoord, htcoord, -(depthcoord*Dslices)/2);

glTexCoord3f(0.0f, 0.0f, (float)i/(float)(Dslices-1));
glVertex3f(widcoord, htcoord, -(depthcoord*Dslices)/2);
glTexCoord3f(0.0f, 1.0f, (float)i/(float)(Dslices-1));
glVertex3f(widcoord, -htcoord, -(depthcoord*Dslices)/2);
glEnd();

}


[This message has been edited by DarthPaul (edited 07-03-2002).]

[This message has been edited by DarthPaul (edited 07-03-2002).]

DarthPaul
07-04-2002, 05:04 AM
Do I need to post more code?? I could really use some help. I haven't a clue what the problem is.

jwatte
07-05-2002, 07:58 AM
You're not really describing your problem very well.

First: do you have a 3D texture bound? Does your card support 3D texturing?

Second: are you drawing in blended mode, and have you turned off depth writes? Else you won't see more than the first slice.

I find that when you sit down and start thinking through exactly what the details of your assumptions are, and how your code relates to those assumptions, 99 times out of 100 the bug becomes apparent by itself. (The ability to stringently describe assumptions and requirements is, by the way, a very valuable skill to acquire in general, and it's gosh-darn hard to do it well!)

jwatte
07-05-2002, 08:00 AM
Oh, I also forgot: why are you sending texcoords when you're using texgen?