Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Collision Detection

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012

    Exclamation Collision Detection

    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)
    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);

    Thanks in advance

  2. #2
    Intern Contributor
    Join Date
    Jul 2006
    This is not an OpenGL question. OpenGL is for graphics - it draws stuff. would be a more appropriate place to ask ... or google for simple examples.

    For example: (did not read any of it myself, but glancing it - it seems to contain what you ask for).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts