How to setup a listener for collision ?

jams

23-08-2007 13:13:01

Hi, I'd like to be able to do specific stuffs on some collisions like sound or effect, how can I setup a kind of collision listener with NxOgre ?
I see there is a Trigger class and a TriggerController or ContactController but I don't understand how to use them (if they do what I suppose they do !)

betajaen

23-08-2007 14:15:46

http://www.ogre3d.org/phpBB2addons/view ... 7130#27130

jams

23-08-2007 17:24:24

Thanks for quick response. I tried the method you suggest, but I can't get my methods to be called :(. Here is what I'm doing :mFirstGroup = mScene->createActorGroup("first");
mSecondGroup = mScene->createActorGroup("second");

mFirstGroup->setCallback<PhysicsManager>(this, &PhysicsManager::onStartTouch, &PhysicsManager::onEndTouch, &PhysicsManager::onTouch);
mFirstGroup->setCollisionCallback(mSecondGroup, NxOgre::NX_NOTIFY_ALL, true);
Here is how callbacks are declared:void onStartTouch(NxOgre::Actor* a, NxOgre::Actor* b);
void onEndTouch(NxOgre::Actor* a, NxOgre::Actor* b);
void onTouch(NxOgre::Actor* a, NxOgre::Actor* b);
Then here is how shapes for bodies are created:shape = new NxOgre::CubeShape(bbox.getSize().x, bbox.getSize().y, bbox.getSize().z, "Group: first");Then I have only one body belonging to second group (this is a vehicle) which is created using this shape:NxOgre::ShapeDescription* shape = new NxOgre::CubeShape(bbox.getSize().x, bbox.getSize().y, bbox.getSize().z, "Group: second");By the way I'm using NxOgre 0.9-28. What am I doing wrong ?

betajaen

23-08-2007 17:33:15

The "Group: second" / "Group: first" part need to be part of the Actor, not the shape, as it's an ActorGroup you've created.

jams

23-08-2007 18:07:54

Well, I must do something else wrong, since I still don't get any call to my callbacks :(
Here is how the bodies are created:NxOgre::Body* b = mScene->createBody("",shape,NxOgre::Pose(node->getPosition(),node->getOrientation()), "Static: Yes, Group: first");
mBody = scene->createBody(name, shape, pos, "Group: second");


I usually do not activate NxOgre Framelistener, but I tried with, and same result. I have enabled scene gravity and floor. I red somewhere on the forum that WheelShape does not behave like other shapes, maybe am I doing collisions only against my vehicle wheels ?

jams

23-08-2007 18:16:23

Wait ... my big mistake ... my DLL did not compile beacause it could not find NX_NOTIFY_ALL ... so I was testing against wrong DLL version :(
At first sight it seems to work !
Thanks a lot !