First if you have some kind of structure to your program, it will make it easy to follow later on. As understand that openGL works in reverse of how one would think rotation and translation should effect an object.
keyboard();// we do keyboard stuff here.
{
if (key == up_arrow) z++;
}
display();// we draw things here!
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Start with a clean matrix… note I am not sure why you call it more then once in your program… maybe part of your problem.
glMatrixMode(GL_MODELVIEW); We are ready to draw.
// Move our view, replaces glulookat
glRotatef(WrotateX, 1.0f, 0.0f, 0.0f); // look right/left
glRotatef(WrotateY, 0.0f, 1.0f, 0.0f); // look up/down
glRotatef(WrotateZ, 0.0f, 0.0f, 1.0f); // rotate view, may need to use.
glTranslatef( 0,0, Worldz); // move on the z-axis
// now draw objects
glPushMatrix(); // save the matrix, we only want to effect this object with the follow commands.
glTranslate(…);// move object to its location.
glRotate(…);// rotate object
draw_object()
glPopMatrix(); // repeat this code for each object you want to draw.
glutSwapBuffers();
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 6.0f, 0.0f, 1.0f, 0.0f);
glTranslatef(-0.8f, 0.0f, 2.0f);
glRotatef(turnrot, 0.0f, 1.0f, 0.0f);
glScalef(0.1f, 0.1f, 0.1f);
gun.Render();
glLoadIdentity();
glTranslatef(0.0f, -1.4f, z);
lev.Render();
if (keys[VK_UP])
{
z+=0.3f;
}
if (keys[VK_DOWN])
{
z-=0.3f;
}
i didnt understand that tut… it is hard to understand without any code… thanks anyway…[/b]<HR></BLOCKQUOTE>
[This message has been edited by nexusone (edited 08-28-2002).]