Thanks Nyad, I gave that ago but it’s still not working, now all the objects on screen rotate constantly never staying still! I forgot to mention that I have another object on screen that I want to control seperately. Here’s the code I have at the minute, it’s probably easier to explain that way:
void camera (void) {
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(yrot,0.0,1.0,0.0);
glRotatef(zrot,0.0,0.0,1.0);
glTranslated(-xpos,-ypos,-zpos);
}
void display (void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
camera();
//****Draw map****
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3, GL_FLOAT, 0, colors);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawElements(GL_TRIANGLES, indexSize, GL_UNSIGNED_INT, index);
glPopMatrix();
//****Draw Plane****
glRotatef(xrotP,1.0,0.0,0.0); //This is supposed to rotate just the plane
glColor3f(1.0,1.0,1.0);
quadratic=gluNewQuadric();
//Main part of plane
glPushMatrix();
glTranslatef(50000.0,50500.0,-10000.0);
glRotatef(90.0,0.0,1.0,0.0); //Rotate it to be parallel with ground
glRotatef(90.0,1.0,0.0,0.0); //Face North
gluCylinder(quadratic,700.0,700.0,5000.0,30,30);
glPopMatrix();
//Front of plane
glPushMatrix();
glTranslatef(50000.0,45500.0,-10000.0);
glRotatef(90.0,0.0,1.0,0.0);
glRotatef(90.0,1.0,0.0,0.0);
gluSphere(quadratic,700.0,30,30);
glPopMatrix();
//Wing
glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(50700.0, 47000.0, -10000.0);
glTexCoord2f(0.0, 1.0); glVertex3f(50700.0, 49000.0, -10000.0);
glTexCoord2f(1.0, 1.0); glVertex3f(57000.0, 50500.0, -10000.0);
glTexCoord2f(1.0, 0.0); glVertex3f(57000.0, 48500.0, -10000.0);
glEnd();
glPopMatrix();
glutSwapBuffers();
}
The first half of the display function displays the map, the second half displays the plane (well only a few parts of it at the minute!). The map is rotated and translated using the camera function which moves the map based on the keys pressed on the keyboard. This half works fine.
Now the second half is the problem, I basically want to acheive the same thing, use another ‘camera’ type function which allows me translate/rotate the plane independently - without moving the map. I also want to apply these translations/rotations to the entire plane model, not each part individually.
First off, is this possible? Secondly, if so, what have I done wrong/what do I need to change?
Thanks again for any help, its very much appreciated.