Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Collision detection!

  1. #1
    Guest

    Collision detection!

    Hello!

    I have 2 moving objects, blue car and red car. The red car being human controlled. The blue car rotating, permanently, around a roundabout.
    I understand how to (very simply) detect collision between the red car and static objects, just by making the co-ordinates out of bounds, but have no idea how to go about doing something like this with a moving object.

    Any help would be grand!!
    thanks!

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2005
    Posts
    20

    Re: Collision detection!

    depending on what kind of detail you want to have in your game you could use anything from simple point-in-circle or point-inside-polygon tests to more advanced stuff like oriented bounding boxes (which are harder to code).

    In any way, this has not much to do with OpenGL so you're better off going to a forum like gamedev.net where this can be discussed in detail.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: Collision detection!

    Code :
    glGenQueries (1, cd);
    glBeginQuery (GL_COLLIDE_DETECT, cd);
     
    ... drawing stuff
     
    glEndQuery();
     
    GLtorsor t;
    glGetQueryObjectiv (cd, GL_COLLIDE_DETECT, t);
     
    if (t){
       // has collided
       r = t.resultant;
       m = t.moment;
     
       // do the collision response
    }
    else{
       // has not collided
    }
    Forgive me please.

  4. #4
    Intern Newbie
    Join Date
    Aug 2005
    Location
    Germany
    Posts
    30

    Re: Collision detection!

    hello jide,

    ...glBeginQuery (GL_COLLIDE_DETECT, cd);...
    why i have not heard from this opengl command until now? it would be very useful...

    dj3hut1

  5. #5
    Guest

    Re: Collision detection!

    Following can be a possible way of detecting collision between Red car and the blue car.(I may be wrong also)

    1. Construct Bounding spheres of both the cars.
    Bounding sphere will return radius and centre of the sphere. The centre can be considered as the centre of Gravity for better understanding

    2. During every iteration check for sphere / sphere overlap. Collision is detected if these two spheres overlap

    3. There are lot of websites talks about algorithms and even source code for constructing Bounding sphere construction

    4. Sphere/ sphere overlap test is easy to implement. ( if radii distance is lessthan the distance between their centers, an overlap exists)

    This is my solution for Collision detection.

    Rajesh.R
    IRIS,CAIR,
    Bangalore - 1

  6. #6
    Junior Member Regular Contributor Swiftless's Avatar
    Join Date
    Apr 2005
    Location
    Australia
    Posts
    118

    Re: Collision detection!

    Hey mate, on me website, I have a very simple collision detection method which can be used for circles or spheres. It is less accurate to that of a bounding box but is perfect for the beginner.

    It basically does what <Rajesh.R> describes above.

    The link is:
    Collision Detection

    Have fun

Posting Permissions

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