Hi I am making a 3D game where a ball is kicked towards a wall with 3 targets which have points in them.

I am looking to do a collision detection with 2 sphere the ball and the target.

I am using gluPerspective(45.0f, fAspect, 1.0, 600.0);


void ball(void)
{
GLUquadricObj *qobj;
qobj = gluNewQuadric();
glTranslatef(40.0, -30.0, 200.0);
glColor3f(1, 1, 1);
gluSphere(qobj, 5, 50, 50);
}


void fivePoints(void)
{
GLUquadricObj *qobj;
qobj = gluNewQuadric();
glTranslatef(16, -4, -120);
gluQuadricNormals(qobj, GLU_SMOOTH);
glColor4f(1, 1, 1, 1);
gluSphere(qobj, 5, 50, 50);
}


How would I do the code in order to make it collide so if the ball hits the target the ball returns back to its original place.

Also I would like to do collision detection with the front wall so if the ball hits the front wall the ball should also return back to the same place.


void Wall(void)
{
glBegin(GL_QUADS);
glVertex3f(-120.0, -50.0, -500.0);
glVertex3f(-120.0, 50.0, -500.0);
glVertex3f(120.0, 50.0, -500.0);
glVertex3f(120.0, -50.0, -500.0);
glEnd();
glFlush();
}

Thanks in advance