Page 1 of 1
ISceneNodeAnimator
Posted: Thu Sep 29, 2005 4:18 pm
by jerky
In "normal" c++ Irrlicht, you could make your own scene node animators by inheriting the ISceneNodeAnimator class
Code: Select all
class MySceneNodeAnimator : public ISceneNodeAnimator {
void animateNode(ISceneNode node, timeMs) {
// animation stuff here
}
}
But in C#, you can no longer inherit ISceneNodeAnimator because it expects an argument of
ISceneNodeAnimator* realSceneNode and the compiler gives an error of "No overload for method 'ISceneNodeAnimator' takes '0' arguments".
Has anyone come up with any workarounds?
Posted: Thu Sep 29, 2005 5:40 pm
by jerky
Here's one workaround using the .NET System.Threading.Timer
Code: Select all
class MySceneNodeAnimator {
private ISceneNode nodeToAnimate;
MySceneNodeAnimator(ISceneNode nodeToAnimate) {
this.node = nodeToAnimate;
}
public void animate() {
/* do animation stuff on scene node here */
}
}
class MainClass {
// keep a reference to the timer so it doesn't get garbage collected
private System.Threading.Timer timer;
MainClass() {
ISceneNode node; // get from SceneManager
MySceneNodeAnimator myanim = new MySceneNodeAnimator(node);
// create a TimerCallBack, a delegate (function pointer) to the function
// you want called (animated)
System.Threading.TimerCallback cb = new System.Threading.TimerCallback(myanim.animate);
// create a timer
long howLongToWaitBeforeExecuting = 0;
long executeEveryXMilliseconds = 100;
timer = new System.Threading.Timer(cb, null, howLongToWaitBeforeExecuting, executeEveryXMilliseconds);
}
}
This animation function should execute every X seconds. I found the idea at
http://www.yoda.arachsys.com/csharp/thr ... mers.shtml
Posted: Thu Sep 29, 2005 11:58 pm
by Foole
I use a similar system to jerky except I call it from my main loop, just after Scene.DrawAll(); I am effectively duplicating irrlicht's animator system.
To use irrlicht's existing system, you would have to write a class in the wrapper dll which would act as a proxy for a .NET animator class.