Setting up collisions between many bodies

sir_nacnud

12-03-2008 02:00:36

For the program I am working on, I have many bodies. I want the collision callback called each time any of the bodies collide with each other or other things. So I am creating an ActorGroup for each body. The problem comes when calling the setCollisionCallback, I am going to have to call this for every other ActorGroup for every body. All of the examples I have seen on this forum only discuss collisions between two ActorGroups, is there a practical way to set it up between multiple ActorGroups, or am I going about it the wrong way?

betajaen

12-03-2008 09:49:01

Yeah. Have a look at the GroupCallback class.

sir_nacnud

12-03-2008 18:40:32

I don't see what you are getting at with the GroupCallback class. From what I can tell it is just composed of different ways to create a class to be called. The class to be created inherits GroupCallback can be ContactCallback, InheritedCallback, or TriMethodCallback.

What I am asking is how can I create n objects and have n objects collide with each other without having to call setCollisionCallback for objects 1,2 1,3 ... 1,n, 2,3, ... 2,n, ... n-1,n. This will be ((n-1)n)/2 calls to setCollisionCallback. So if you had ten objects, you would have to call setCollisionCallback 45 times. This is using each object in its own ActorGroup.

betajaen

12-03-2008 18:43:42

You assign a GroupCallback to detect collisions the same group as the group of those Actors. It's usually used so you don't have to create 45 callbacks.

sir_nacnud

13-03-2008 00:44:40

I was able to get the callbacks set up properly, thanks for the help. Do you know if it has been implemented in NxOgre to get the position of the collision?

NickM

13-03-2008 06:50:21

For my game I altered the NxOgre code so that for instance 'onStartTouch' returns the 'NxContactPair& pair' and from that I do NxContactStreamIterator i(pair.stream);
and from that I can get various information about the collision, including the position.

NoodlesOnMyBack

14-03-2008 03:48:43

For my game I altered the NxOgre code so that for instance 'onStartTouch' returns the 'NxContactPair& pair' and from that I do NxContactStreamIterator i(pair.stream);
and from that I can get various information about the collision, including the position.


That helped a lot, thanx