Need help with creating a listener for a SceneNode

patg1865

21-09-2008 09:36:33

I need to setup a scenenode with a listener but I am not sure on how to go about doing that. There aren't any events (like framestarted for the framelistener class) for the Scenenode class.

Is there an example anywhere on how to use the SceneNode.setlistener function :?:

Any help would be GREATLY appreciated!


I am using VS 2008 and C#.
An Example in C# or C++ would be very helpful!

Bostich

21-09-2008 10:02:52

Hello patg1865,

i think u can try it in this way:


class MyNodeListener : Node.Listener
{
public override void NodeAttached(Node param1)
{
//Do suff()
base.NodeAttached(param1);
}
public override void NodeDestroyed(Node param1)
{
//Do suff()
base.NodeDestroyed(param1);
}
public override void NodeDetached(Node param1)
{
//Do suff()
base.NodeDetached(param1);
}
public override void NodeUpdated(Node param1)
{
//Do suff()
base.NodeUpdated(param1);
}
}



And using of that :


//Instanciate new object
MyNodeListener mnl = new MyNodeListener();

YourSceneNode.SetListener(mnl);



That should it be :P

No guarantee that it works, never used that by myself 8)

patg1865

21-09-2008 16:54:42

Thanks for the reply bostich!

decending from the node.listener was the only way I could think of to get it to work.. but I wanted to be sure! I searched all the forums (both ogre and mogre) for an example and couldn't find one.. (even in the src code for both).

I'll give it a try!

again many thanks! :D

patg1865

21-09-2008 17:18:13

That works great bostich!

I'm also going to do the same for MovableObject.Listener and once done I'll post code up here just in case someone else needs an example on using listeners with nodes/movableobjects.

<bows to bostich>