spacegaier
12-03-2008 21:01:00
I'm trying to work with triggers right now. I've already created one and also a Callback class for it. But there is nothing to see so far. I guess I have to tell the bodies that have to interact with the trigger to do so, but how?
NxOgre::Trigger *trigger = m_pNxScene->createTrigger("trigger", new NxOgre::CubeShape(10,10,10), NxOgre::Pose(Vector3( 0,0,0), Quaternion(Radian(Degree(270)), Vector3(0,1,0))));
myTrigger *mytrigger = new myTrigger();
trigger->setCallback(mytrigger);
class myTrigger : public NxOgre::TriggerCallback::InheritedCallback
{
public :
myTrigger(){ };
void onEnter(NxOgre::Trigger* t, NxOgre::Actor *a)
{
NxOgre::Body * bd = static_cast<NxOgre::Body*>(a);
bd->getEntity()->setMaterialName("DarkGrey");
}
void onLeave(NxOgre::Trigger* t, NxOgre::Actor *a)
{
NxOgre::Body * bd = static_cast<NxOgre::Body*>(a);
bd->getEntity()->setMaterialName("IndianRed");
}
void onInside(NxOgre::Trigger* t, NxOgre::Actor *a)
{
NxOgre::Body * bd = static_cast<NxOgre::Body*>(a);
bd->getEntity()->setMaterialName("RoyalBlue");
}
};