Skip to main content
GameDev.net gamedev.net
🔒 Locked

collision information

Started by voguemaster Aug 14, 2006 at 4:07 AM 1 replies 650+ views
Original Post
voguemaster
voguemaster
hi, What are possible parameters that one needs to pass to other modules of the engine after a collision ? Some stuff are used by the physics (collision nomral, relative velocities, etc.), some by other modules. I'm looking for possible things that the collision detection system needs to pass when it's notifying the engine about a collision. Of course, ideas on how to pass these in the best way are also welcome... E
-----------------------------He moves in space with minimum waste and maximum joyGalactic Conflict demo reel -http://www.youtube.com/watch?v=hh8z5jdpfXY
CIJolly
CIJolly
The data the engine needs depends on what you want to do.

For collision resolution, the collision detection will have to pass things like contact points, contact time, normal, relative velocities, rotational velocities, etc.

For the game logic, the engine might need pointers to the objects that collided and the states (position, velocity, etc) of the objects before the collision took place. The states of the objects after the collision will be able to be retrieved using the pointers to the objects involved in the collision.

I pass data from collisions using a linked list. Everytime a collision is detected, a "collision point" object is created. It contains all of the stuff I mentioned above. The collision point object is added to a collision point list.

The physics engine loops through this list and uses some equations to resolve the collisions. The game engine loops through the list and uses switches to perform the game logic (eg, if object type 1 (fireball) collides with object type 2 (player) damage player, destroy fireball).

There are probably better ways to do this, but this seems fairly easy to impliment, and stores the data somewhere you can access and loop through it easily.
voguemaster
voguemaster
Thanks for the reply. Other interesting stuff might be to pass some kind of pointer or handle to the objects under collision, so the game logic (or any other module) can retrieve surface or material properties from the objects (for collision audio or other reasons).

It's interesting to see other designs. I am going to pass an object that contains general data about the collision back to the engine core. It will then get routed to all registered listeners that are interested in monitoring collisions in the system.

In 3D Game Engine Architecture, Dave Eberly describes his method. He uses a callback function that is set beforehand. The function receives several arguments, one of which is the specific instance of the Intersector object that contains information about the intersection in question.
-----------------------------He moves in space with minimum waste and maximum joyGalactic Conflict demo reel -http://www.youtube.com/watch?v=hh8z5jdpfXY

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.