SanMiguel
21-01-2008 22:57:39
Evening all,
I'm in the middle of my app from 0.6 to 0.9 - everything going smoothly enough - groups and contact reporters all OK.
In spite of
http://www.ogre3d.org/phpBB2addons/view ... 7130#27130 I'm unable to get my triggers working.
Anyone got a quick example, including trigger callback methods?
Thanks in advance,
SanMiguel
SanMiguel
22-01-2008 11:33:56
Still having problems getting trigger to work.
Here's my trigger handline code:
#ifndef __myTrigger_H__
#define __myTrigger_H__
#include "nxOgre.h"
#include "Ogre.h"
#include "nxogretrigger.h"
using namespace NxOgre;
using namespace Ogre;
class myTrigger : public TriggerCallback::InheritedCallback
{
public :
myTrigger() { }
void OnEnter(Trigger* t, Actor *a) {
Body * bd = static_cast<Body*>(a);
bd->getEntity()->setMaterialName("nx.cube.red");
}
void OnLeave(Trigger* t, Actor *a)
{
Body * bd = static_cast<Body*>(a);
bd->getEntity()->setMaterialName("nx.cube.green");
}
void OnInside(Trigger* t, Actor *a)
{
Body * bd = static_cast<Body*>(a);
bd->getEntity()->setMaterialName("nx.cube.blue");
}
// character stuff
void OnEnter(Trigger* t, Character *a) { }
void OnLeave(Trigger* t, Character *a) { }
void OnInside(Trigger* t, Character *a) { }
};
#endif
and here is my setup code:
myTrigger *testTriggerCB = new myTrigger();
Trigger* testTrigger = mScene->createTrigger("testTrigger", new CubeShape(10), Vector3(0,5,0), "Static:yes");
testTrigger->setCallback(testTriggerCB);
I've tried it with (and without)
testTrigger->setGroup(mGroup);
Neither seems to affect any Body entering, leaving or inside the trigger.
SanMiguel
betajaen
22-01-2008 11:48:51
Small "o"'s on onEnter, onExit not capital ones like you have there.
SanMiguel
22-01-2008 12:11:34
Thanks Betajaen - i was just too close to the wood to see the trees. Solved.
SanMiguel