PDA

View Full Version : Automatic Texture-Coordinate Generation Problem



lsdi
02-02-2002, 07:49 PM
Im load the vertices from a height map but the texture appears to be moving... its very strange.

But everything its ok without using automatic tex-coord generation.

every redraw() fuction I do this:




glBindTexture(GL_TEXTURE_2D, texture[Terrain[QUAD_ID].texture_id]);
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, QsPlane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, QtPlane);
glBegin(GL_TRIANGLE_STRIP);
for(i=0;i<Terrain[QUAD_ID].size;i++) {

glVertex3f(Terrain[QUAD_ID].vertices_x1[i],
Terrain[QUAD_ID].vertices_y1[i],
Terrain[QUAD_ID].vertices_z1[i]);
glVertex3f(Terrain[QUAD_ID].vertices_x2[i],
Terrain[QUAD_ID].vertices_y2[i],
Terrain[QUAD_ID].vertices_z2[i]);
glVertex3f(Terrain[QUAD_ID].vertices_x3[i],
Terrain[QUAD_ID].vertices_y3[i],
Terrain[QUAD_ID].vertices_z3[i]);

glVertex3f(Terrain[QUAD_ID].vertices_x4[i],
Terrain[QUAD_ID].vertices_y4[i],
Terrain[QUAD_ID].vertices_z4[i]);

glVertex3f(Terrain[QUAD_ID].vertices_x1[i],
Terrain[QUAD_ID].vertices_y1[i],
Terrain[QUAD_ID].vertices_z1[i]);
glVertex3f(Terrain[QUAD_ID].vertices_x3[i],
Terrain[QUAD_ID].vertices_y3[i],
Terrain[QUAD_ID].vertices_z3[i]);

}
glEnd();

Bob
02-03-2002, 03:09 AM
Is the texture moving all the time, or only when you move the viewpoint?

If it's moving only when you move the viewpoint, I guess you are doing your viewpoint transforms in the projection matrix.

lsdi
02-03-2002, 09:54 AM
The texture moves only when Im moving...






void display (void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

glPushMatrix();

if(start){start=!start; CamQ.Translate(10,10,-10);}
runInput();
CamQ.Update();
CamQ.PlaceCamera();
CamQ.MoveForward(speed);
create_frustum();
render();
glPopMatrix ();


start_unrender();
glPushMatrix();
CamS.Update(); //BASED ON QUARTENIONS
CamS.PlaceCamera();
draw_sky(0.1,0.3,0.7);
glPopMatrix();
hud();

stop_unrender();

glutSwapBuffers();
}

void reshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(20,(float)w/(float) h,0.1,5000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}



A lot of thanks.