Attn Esset, RE: Contact Collisions

betajaen

07-07-2010 16:29:21

Save you the trouble of posting. This is the code you want:

createWorldSceneEtc();

MyCallback* myCallback = new MyCallback();

mBodyA = makeBox(Vec3(0,3,0));
mBodyA->setContactCallback(this);

mBodyB = makeBox(Vec3(0,7,0));
mBodyB->setContactCallback(this);

mScene->setActorFlags(mBodyA, mBodyB, NxOgre::Enums::ContactPairFlags_All);

/////////////////////////////////////

class MyCallback : public MyCallback
{

void onContact(const ContactPair& pair)
{
std::cout << "EXPLOSION!!" << std::endl;
}

};


It should be self-explanatory. The key here is to call setActorFlags in Scene to enable contact reporting between them (If you have more then, you have to call the same function between the other pairs).

Then for each RigidBody you have, use the setContactCallback function in Body/Actor/KinematicActor/KinematicBody so NxOgre knows what to call on such an event.

The next update of the NxOgreTutorials will have a full tutorial about this, but this should help you out now.

Yati

21-12-2011 08:44:16

Hi betajean,

I noticed in the PhysX a function called setActorGroupPairFlags that you can use to make a pair of groups. I can't find the NxOgre version of this function, does it not exist?

I'm making a Asteroids game so missiles the player fires and the astroids in two groups so I think think function is more useful for me that the setActorFlags function.

Thanks
Yati