View Full Version : Collision detection!
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!!
12-01-2005, 12:11 PM
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.
glGenQueries (1, cd);
glBeginQuery (GL_COLLIDE_DETECT, cd);
... drawing stuff
glGetQueryObjectiv (cd, GL_COLLIDE_DETECT, t);
// has collided
r = t.resultant;
m = t.moment;
// do the collision response
// has not collided
}Forgive me please.
12-04-2005, 10:24 PM
...glBeginQuery (GL_COLLIDE_DETECT, cd);...why i have not heard from this opengl command until now? ;) it would be very useful...
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.
Bangalore - 1
12-05-2005, 09:00 PM
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 (http://www.cdadc.com/programming/tutorials/opengl/collision.html)
Have fun :)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.