ISceneNodeAnimator

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
jerky
Posts: 12
Joined: Sun Aug 14, 2005 4:53 am

ISceneNodeAnimator

Post 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?
jerky
Posts: 12
Joined: Sun Aug 14, 2005 4:53 am

Post 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
check out JohnnyAppleseed: Irrlicht Terrain Editor at http://home.case.edu/~jcp16/johnnyappleseed
Foole
Posts: 87
Joined: Mon Aug 29, 2005 10:08 am

Post 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.
Locked