betajaen
07-07-2010 16:29:21
Save you the trouble of posting. This is the code you want:
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.
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.