If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
#1 |
|
penguins
Join Date: Feb 2004
Posts: 13,978
|
Yeah, I know it's something a little odd to ask, but anyhoo...
I'm doing a mini program in openGL, and I want to implement collision detection between a box, 3 walls and a floor... Anyone know of a good tutorial to implement this? The one I've found (NeHe's lesson 30 ) are somewhat specific to what those programs are doing. I was wondering if there's some general format I can follow... |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Nov 2002
Location: Edmonton, Alberta, Canada
Posts: 1,765
|
I have yet to write a collision system consisting of more than just bounding spheres and cylinders, but here's a list of articles on the subject:
http://www.gamedev.net/reference/lis...tegoryid=45#99
__________________
"Extremism is so easy. You've got your position, and that's it. It doesn't take much thought. And when you go far enough to the right, you meet the same idiots coming around from the left." -- Clint Eastwood -Ostsol |
|
|
|
|
|
#3 |
|
penguins
Join Date: Feb 2004
Posts: 13,978
|
thanks, I'll go through those.
|
|
|
|
|
|
#4 |
|
Tea maker
Join Date: Feb 2002
Location: In the Island of Sodor, where the steam trains lie
Posts: 4,382
|
While on the subject of collision detection, check out the Jenga (and roadkill!) demos in this physics simulator. (Click/download Novodex rocket).
It is awesome.
__________________
"Your work is both good and original. Unfortunately the part that is good is not original and the part that is original is not good." -(attributed to) Samuel Johnson "I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." Alan Kay |
|
|
|
|
|
#5 |
|
penguins
Join Date: Feb 2004
Posts: 13,978
|
oooo.....
hm.... not understanding |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2004
Location: USA
Posts: 65
|
Think of it like this any movable object in your game world exists in four distinct 'spaces', collision, physics, geometry, and the world. The world is your objects position and orientation, the geometry is the mesh that is associated with the object, mass/inertia tensor velocity/acceleration (linear and angular) all are properties of your object in relation to the physics 'space'. When it comes to collision you have a variety of different ways to implement your object representation in that 'space'.
The choice of representation is usually a tradeoff between speed and accuracy. For example a bounding sphere is a common collision primitive, a sphere that encloses all of the object is associated with the object and is used for collision purposes. Why a sphere? because imagine testing to see if two spheres collide, if the sum of the radius's of the two spheres is greater than the distance between there centers the spheres are colliding. This can be done lightning quick. The obvious drawbacks are that spheres will give you alot of faulty collisions depending on the actually shape of said object. So look up things like sphere trees, AABB, OBB, line swept spheres, bounding volume hierarchies. There are many papers out there for you to read, as well as libraries for you to look into DEEP, SWIFT++, PIVOT, SWIFT, H-COLLIDE, RAPID, PQP, V-COLLIDE, I-COLLIDE, IMPACT. (the previous all can be found here: http://www.cs.unc.edu/~geom/collide/packages.html) There are many more like the one thats integrated into ODE (a physics engine), i forget its name at the moment. Oh and there is a website by the name of magic-software, somewhere on there site is a table on the math of colliding various type of primitives with each other i.e. triangles and lines. For you I would advise using a bounding sphere for the object and the plane equations for the walls and floor/ceiling (assuming they are flat). The plane equation is fast easy to understand and well documented. |
|
|
|
|
|
#7 |
|
penguins
Join Date: Feb 2004
Posts: 13,978
|
whoa
Yes, everything is flat, there's just a cube in the room which I can move or rotate in the x,y,z at the press of keys. I was looking at the planes stuff, but it kind of flew right past me (implementation). off to some reading, and perhaps back on monday for this thread (update). edit: just to note.. there's a right parenthese in your link |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jul 2004
Location: USA
Posts: 65
|
Plane stuff is pretty simple. This is from memory just so you get the concept don't mind the memory lapses I made note of what i can't remember at the moment. The plane equation is Ax+By+Cz(-/+)D=0 so you have a four vector of floats defining your plane. The normal or the whole thing including D must be normalized (forgot which) when you plug a point into the equation, the output is zero if the point is on the plane. If not its the shortest (line perpendicular from plane to point) distance to the plane, a negative distance means its distance D away from the plane on the other side of the normal. Long story short, if you use a bounding sphere and plug the current location of the center of said sphere into the plane equation, compare distance returned with radius of sphere... which will bring you to collision response which is another topic entirely. Just remember you need to stores collisions you can't just respond to them immediately, think collision in corner with two walls at same time.
|
|
|
|
|
|
#9 |
|
penguins
Join Date: Feb 2004
Posts: 13,978
|
ah.... I think I understand it better now. Thanks
*still working on code* |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AnandTech article up (X360 vs PS3) | pipo | Console Technology | 87 | 26-Jun-2005 05:58 |
| Opengl per pixel collision detection | K.I.L.E.R | 3D Technology & Algorithms | 4 | 19-Jun-2005 23:03 |
| UT2004, Far Cry - CPU and VPU (nv40, R420) | ShePearl | 3D Architectures & Chips | 196 | 27-May-2004 09:11 |
| Help implementing collision detection | ShinHoshi | General Discussion | 5 | 21-Aug-2003 17:56 |
| The next-generation: The camera and collision detection | Ooh-videogames | Console Technology | 21 | 24-Feb-2003 02:47 |