Custom Contact Reports

Benjiro

24-06-2009 02:11:31

Hi Guys,

I'm trying to make a custom contact report that when pair of actors are touching each other gravity will be disabled.


class myContactReport : public NxUserContactReport
{
void onContactNotify(NxContactPair& pair, NxU32 events)
{
NxActor *sphere;
NxActor *surface;
if(pair.actors[0]==(NxActor*)mSphere)
{
sphere = pair.actors[0];
surface = pair.actors[1];
}
else if(pair.actors[1]==(NxActor*)mSphere)
{
sphere = pair.actors[1];
surface = pair.actors[0];
}
else
{
return;
}
sphere->setLinearVelocity(surface->getGlobalPosition() - sphere->getGlobalPosition());
sphere->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);
}
};



mScene->getScene()->setUserContactReport(new myContactReport());
mCube->setContactReportFlags(NX_NOTIFY_ON_TOUCH);


Error 2 error C2248: 'NxOgre::SceneGeometry::setContactReportFlags' : cannot access protected member declared in class 'NxOgre::SceneGeometry' c:\documents and settings\bne8179\desktop\framework\game\worldstate.cpp 172

Basically the setcontactreportflags function is set to protected, is there another way of setting flag for NX_NOTIFY_ON_TOUCH??

Benjiro

24-06-2009 07:26:20

Worked it out, you have to access NxActor.

mCube->getNxActor()->setContactReportFlags(NX_NOTIFY_ON_TOUCH);