Archived

This topic is now archived and is closed to further replies.

hello_there

enviroment mapping

Recommended Posts

i enabled enviroment mapping like this glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); but when i did that the texture disapeared and the object was just shiney red. what i wanted was was the object with the texture on it and it shine. can someone tell me how to achieve this.

Share this post


Link to post
Share on other sites
quote:

ohh nope they''re wrong. but does that matter my game has no lights yet.


Yes, the GL_SPHERE_MAP texgen mode uses the normals to compute the reflection vectors into the envmap. So if they are wrong, so will your envmapping be.

Share this post


Link to post
Share on other sites
my normals are correct now. but it's still not how i want it. i want it so that the player looks shiny but still has the texture on it. atm the texture is applied to the whole background not just the cube.

[edited by - hello_there on November 6, 2002 9:35:23 PM]

Share this post


Link to post
Share on other sites
hi, just wondering but you did disable the sphere mapping when you aren''t useing it right? and if you do then perhapes some code could help us determine your problem or maybe a better explenation of your situation.

Share this post


Link to post
Share on other sites
yes i did disable it like this

glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);

this is the code to draw the cube and stuff

float x = 0.15f;
float y = 0.15f;
float z = 0.19f;

glLoadIdentity();

glPopMatrix(); //revert to the saved camera
glPushMatrix(); //save the camera position on the stack

// setup environment mapping
glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

glBindTexture(GL_TEXTURE_2D, stotexture);

glTranslatef(playerposx,playerposy,playerposz);

glPushMatrix();
glBegin(GL_QUADS);

glNormal3f(0.0f,-1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);glVertex3f(-x,-y, z);//bottom
glTexCoord2f(0.0f, 0.0f);glVertex3f(-x,-y,-z);
glTexCoord2f(1.0f, 0.0f);glVertex3f( x,-y,-z);
glTexCoord2f(1.0f, 1.0f);glVertex3f( x,-y, z);

glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f);glVertex3f(-x, y, z);//top
glTexCoord2f(1.0f, 0.0f);glVertex3f(-x, y,-z);
glTexCoord2f(0.0f, 0.0f);glVertex3f( x, y,-z);
glTexCoord2f(0.0f, 1.0f);glVertex3f( x, y, z);

glNormal3f(-1.0f, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);glVertex3f(-x, y,-z);//left
glTexCoord2f(1.0f, 0.0f);glVertex3f(-x,-y,-z);
glTexCoord2f(1.0f, 1.0f);glVertex3f(-x,-y, z);
glTexCoord2f(0.0f, 1.0f);glVertex3f(-x, y, z);

glNormal3f(1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);glVertex3f( x, y,-z);//right
glTexCoord2f(0.0f, 0.0f);glVertex3f( x,-y,-z);
glTexCoord2f(0.0f, 1.0f);glVertex3f( x,-y, z);
glTexCoord2f(1.0f, 1.0f);glVertex3f( x, y, z);

glNormal3f(0.0f, 0.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f);glVertex3f(-x,-y, z);//front
glTexCoord2f(1.0f, 0.0f);glVertex3f( x,-y, z);
glTexCoord2f(1.0f, 1.0f);glVertex3f( x, y, z);
glTexCoord2f(0.0f, 1.0f);glVertex3f(-x, y, z);

glEnd();
glPopMatrix();

Share this post


Link to post
Share on other sites
ok I looked it over and things are very confusing alone and you have an extra pop and and extra push around your drawing this is useless in all conditions nothing changed states in between them minus the texture cords and the normals... and you should name these every time.

I think I get where your coming from with the saved cameras they are comeing from up above this where you draw the objects the first time. Ok we will need the code that saves these states. and the way the code works such as a loop that it is contained in if one at all. Those peaces will really help bring the problem into the light.

Share this post


Link to post
Share on other sites