Problem getting NxScene

wraith

11-07-2009 12:57:16

So I have all of my Nx physics encapsulated in one singleton class, and I initialise this when my Ogre scene is rendered. the variable mScene, which is the NxOgre scene is created and used for creating Nx bodies. This all works fine. My mScene variable is definitely initialised. I use

mScene->getScene()->setActorGroupPairFlags()

when the physics class is initialised to set up collision groups. This also works fine. However, once everything is rendered, in my frame listener I have a keypress which calls the following code in my physics class:

void Physics::SetActorContactReport(OGRE3DBody* body1, OGRE3DBody* body2, int flag) {
NxActor* b1=body1->getNxActor();
NxActor* b2=body2->getNxActor();
mScene->getScene()->setActorPairFlags((NxActor&)b1,(NxActor&)b2, flag);
}


This doesn't work however, and I get an access violation. I'm fairly certain the problem is in the getScene() call, but I have no idea why. The bodies being passed are definitely initialised (I can see them in the scene) so I'm stumped as to what's going wrong. Does anyone have any clue as to what's going wrong?

wraith

12-07-2009 11:19:03

Okay, so that problem might be a little difficult to answer, and I cannot get it to work the way I want to. Instead, I'll tell you what I'm trying to do, and if anyone has a simple way of achieving it I'd be very grateful.

I need to disable the collisions between two actors, who are in groups that regularly could collide. So say I have groups SHIP and PROJECTILE. Normally, projectiles can hit ships. My problem is that if a ship creates a projectile, the projectile hits its parent ship. This is easily ignored in the contact report, but it doesn't stop SHIP affecting the forces applied to PROJECTILE. I need a way to ignore collisions between the two , but not the rest of the group. I thought about just assigning each ship a unique id (through groups), but there are only 32 available shape groups. If anyone has any ideas, I'd be much obliged.

wraith

12-07-2009 11:59:05

And of course, immediately after posting that I figured out how to do it. I was trying to disable a collision but not its report. There's an actor flag that does exactly that. So for future reference:

mBody->getNxActor()->raiseActorFlag(NX_AF_DISABLE_RESPONSE);

I think it could also be achieved through NxOgre's RigidBodyDescription.

betajaen

12-07-2009 12:26:03

I was looking into Collision Filtering in the documentation for you ten minutes back, perhaps that may be a bit more targeted than just a blanket of all collisions.