One body can not attach two collision call back??

kidcdf

02-07-2008 07:08:47

I have a car, I want it to have collision with other cars and scene,either of them will play a different sound, but there is no "add callback" methods,such as:

maincar->body->getGroup()->addCallback(maincar->getCarCCB());
maincar->body->getGroup()->addCollisionCallback(m_nxscene->getActorGroup("othercar_group"),NX_NOTIFY_ALL,true);



which means my car body can not attach two collision call back as the same time, how to solve it?

NickM

03-07-2008 06:26:02

I have my cars in one actor group and my hittable scene objects in another.
I'm using version 0.9 btw.


metalActorGroup = mScene->createActorGroup("Banger");
staticActorGroup = mScene->createActorGroup("static");

myContactReport = new ContactReport();
metalActorGroup->setCallback<ContactReport>(myContactReport, &ContactReport::onStartTouch, &ContactReport::onEndTouch, &ContactReport::onTouch);
metalActorGroup->setCollisionCallback(staticActorGroup,NX_NOTIFY_ALL,false);
metalActorGroup->setCollisionCallback(metalActorGroup,NX_NOTIFY_ALL,true);

Kwazar

03-07-2008 20:59:23

Hi!
I had the same problem and I have solved it :)



AG1->setCollisionCallback( AG2, NX_NOTIFY_ALL, false );
AG1->setCallback<CallBack>( newCallBack, CallBack::onStartTouch, CallBack::onEndTouch, CallBack::Jiggle );
AG1->setCollisionCallback( AG3, NX_NOTIFY_ALL, false );
AG1->setCollisionCallback( AG4, NX_NOTIFY_ALL, false );
.
.
.
AG1->setCollisionCallback( AG10000, NX_NOTIFY_ALL, false );

void CallBack::onStartTouch( NxOgre::Actor *A, NxOgre::Actor *B )
{
if( B->getGroup()->getName() == AG2->getGroup()->getName() )
{
//Do something
}
else if( B->getGroup()->getName() == AG3->getGroup()->getName() )
{
//Do something
}

.
.
.
else if( B->getGroup()->getName() == AG10000->getGroup()->getName() )
{
//Do something
}
}

FriedChicken

05-07-2008 09:42:58

if this kind function provided, i would be very happy:

addCallback(group1, group2, callback_method)

betajaen

05-07-2008 10:04:15

It's a little vague and un-C++ like. Do you want everything pumped into a function? or a static method?