I have a carrier object and a plane that is controllable by keyboard input, i want to be able to detect a collision between the 2 so i can land on the carrier. This is my code:
//Camera
gluLookAt(45,30,-50,eyeX,eyeY-5,eyeZ,0,1,0);
//Skybox
glPushMatrix();
glEnable(GL_TEXTURE_2D);
drawSea();
glDisable(GL_TEXTURE_2D);
drawCube();
//Carrier
glPushMatrix();
//glTranslatef(-22,12,0);
glTranslatef(-carrierX,12,-carrierZ-190);
glEnable(GL_TEXTURE_2D);
model2.speedDisplayFaceNormals();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
glPopMatrix();
//Aircraft
glPushMatrix();
glTranslatef(eyeX,eyeY-5,eyeZ);
glRotatef(-heading, 0,1,0);
glRotatef(-elevation, 1,0,0);
glEnable(GL_TEXTURE_2D);
model.speedDisplayFaceNormals();
glDisable(GL_TEXTURE_2D);
//Bounding box
glBegin(GL_QUADS);
glVertex3f(-6, -2, -6);
glVertex3f(6, -2, -6);
glVertex3f(6, -2, 6);
glVertex3f(-6, -2, 6);
glEnd();
glPopMatrix();
My initial ideas are to have a plane at the bottom of the aircraft, and one on top of the carrier, and then detecting when they collide should be easy. You can see i have added a plane to the bottom of the aircraft, however, as the position of the aircraft moves, the plane will move too, how do i get the current co-ordinates of the plane as it is being moved? Or is there a different way i should go about this? I have a good understanding of how to execute the detection once i can get the co ordinates as the objects are moving