[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] PyODE
Kris Schnee wrote:
does anyone know
how to feed collision information back to the program outside PyODE?
In one of my WIPs I'm using just the collision detection
part of ODE to do something like this. I maintain a dict
that maps geom objects back to the game objects they
represent. Then I call the collide() method of my geom
space with a callback that does the appropriate thing.
My World object has a method that goes like this:
def for_colliding_objects(self, action):
def callback(data, geom1, geom2):
contacts = ode.collide(geom1, geom2)
if contacts:
obj1 = self.geom_to_object[geom1]
obj2 = self.geom_to_object[geom2]
action(obj1, obj2, contacts)
self.geom_space.collide(None, callback)
If you've got objects bouncing, you must already have
a loop somewhere that's generating contact information
from colliding geoms, so you should be able to incorporate
it into that.
--
Greg