Collision groups

wraith

02-07-2009 08:41:59

I'm using 1.5.4, and I'm wondering if there's any way to specify which NxOgre bodies can interact within a particular scene. For example, if I have three groups called "Players", "Enemies" and "PlayerProjectiles", I might want PlayerProjectiles to interact with Enemies but not Players. I've tried playing around with groups, but they either don't offer the functionality I'm looking for or I'm doing it wrong. From reading this seems to have been done in the past through ShapeGroups, but I can't find anything on how or if it's done in the latest release. Any help would be appreciated.

spacegaier

02-07-2009 10:03:34

Never tried to use something in this direction in BloodyMess, but I just searched the code and found somethings (can't test them right now though as I am at work).

NxOgreActor.h has some methods:
void setGroup(GroupIdentifier actorGroup);
GroupIdentifier getGroup(void) const;
void setDominanceGroup(GroupIdentifier dominanceGroup);


NxOgreShape.h has some as well.

Try to play around with these GroupIdentifier. That could be the key for your solution.

wraith

03-07-2009 03:53:03

Creating and setting groups is easy enough, but I can't figure out how to define the relationships between them. So if I create my GroupIdentifiers and assign them to different objects (I'm not sure whether to use Groups or DominanceGroups, I don't understand the difference), they just interact normally because I haven't told them to do otherwise anywhere. I've looked through all the NxOgre files, but I can't find anything that seems like it could be used to define these relationships. I did find something in the PhysX file NxScene, but I'd rather not directly access it if it can be done through NxOgre.

wraith

05-07-2009 03:19:43

Alright, I just can't figure this out. No matter what I do, it doesn't seem to affect the collisions.

If I have two groups, defined as 0 and 1, I'm trying to disable collisions between them. I set the groups through the NxActor (bypassing NxOgre just to make sure it's set), using body->getNxActor->setGroup(). That works fine, it's definintely set. Then I try to set collision properties through the scene. I've tried both of these, together and seperately through the NxScene:

mScene->getScene()->setGroupCollisionFlag(0, 1, false);
mScene->getScene()->setActorGroupPairFlags(1, 0, NX_IGNORE_PAIR);


But they still collide. The only other thing I can think to try is GroupMasks, but that's a lot more complex. Can anyone help?

betajaen

05-07-2009 10:46:44

I think, you have assign the group to the shape of the NxActors if you want disable collisions.

wraith

06-07-2009 01:05:45

That fixed it, thanks betajaen.

In case anyone wants the code, here is how you would disable collisions between groups 0 and 1.


mScene->getScene()->setGroupCollisionFlag(0, 1, false);


And then you'd set the group with (although I think NxOgre doesn't support multiple shapes per body):

for (int i=0;i<(int)mBody->getNxActor()->getNbShapes();i++) { mBody->getNxActor()->getShapes()[i]->setGroup(1); }

betajaen

06-07-2009 01:47:21

I'll add some group functions into Shapes, Actor/rigidbody/staticgeometry and Scene in 1.5.6