Animator chaining.

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Animator chaining.

Post by 3DModelerMan »

I've created a patch that adds animator chaining to Irrlicht. You use it like this pseudocode shows.

Code: Select all

//Could be any kind of animator. 
ISceneNodeAnimator* anim1 = smgr->addAnimator(); 
//Two other kinds of animators. The animators can't be looping though. 
ISceneNodeAnimator* anim2 = smgr->addAnimator(); 
ISceneNodeAnimator* anim3 = smgr->addAnimator(); 

//Set up animator chaining. 
anim1->setNextAnimator(anim2); 
anim2->setNextAnimator(anim3);
I think it would be a good feature to have in Irrlicht so I just made it.
http://rapidshare.com/files/374278256/S ... patch.html
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

I just wonder why is this between bug reports. A good idea, though.
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

At least the code shown should be a no-op, because the animators would be executed in exactly this order. Moreover, a proper interface for priorities etc. would be more effective. If I missed something, please explain some more.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

A priority system for this? That could be usefull. What else should there be? The reason I put it in bug reports was because I noticed that's where everyone else posted patches.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

They usually post patches in Bug reports because the patches usually fix a bug. :P
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

A no op animator system I think would be less flexible. If you had an animator that branched for example you'd want to hide the set next functions and the get next functions and just make the animator transision itself.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

slavik262 wrote:They usually post patches in Bug reports because the patches usually fix a bug. :P
Yes, but this one adds something new, but I guess it doesn't really matter.
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The reason why this is a no-op is that animators are automatically executed in creation order. You can actually chain animators today. So you should at least show some benefit of your method.
Posting these things in bug reports is ok. If larger design decisions are to be made it could better go into OpenDiscussion
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

Oh okay. If this is what you mean it should be able to do...

Code: Select all

//Could be any kind of animator. 
ISceneNodeAnimator* anim1 = smgr->addAnimator(); 
//Two other kinds of animators. The animators can't be looping though. 
ISceneNodeAnimator* anim2 = smgr->addAnimator(); 
ISceneNodeAnimator* anim3 = smgr->addAnimator();
ISceneNodeAnimator* anim4 = smgr->addAnimator(); 

//Set up animator chaining. 
anim1->setNextAnimator(anim2); 
anim2->setNextAnimator(anim3);

//...
//later somewhere when your animator is not finished yet.
if ( !anim2->isFinished() )
anim2->setNextAnimator(anim4);
//...
Then it already can. Oh and I forgot, you still have to add the first animator in the chain with ISceneNode::addAnimator();
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

From what I see you need to add all animators with addAnimator. Moreover, the chaining aspect doesn't come clear. You don't really chain anything here, you just start the animator at a later point. Does your code require anim3 to stop when anim4 starts?
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

The code is similar to the CProcess technique from Game Coding Complete third edition. You set all the animators and when the current animator in the sequence is finished, it's deleted and the current animators m_next variable (which is an ISceneNodeAnimator) is then added as the next animator. That's the best I can explain off the top of my head, if you want to see what I mean, try looking at the patch and you can see the whole thing.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ah, ok. So you don't want any animator to start except for the first one and unless the old one has finished. Well, that's not that easily addable, because it would break the old "all at once" pattern resp. is not that easily understandable.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

The all at once pattern is still there, if you want it. You can set the chaining to be on or off. It defaults to have animator chaining be turned off so that if people are porting existing projects they won't run into problems. You have to turn it on to get it to do the chaining.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

I actually think such a behavior could be a nice addition for any and all animators, but more thoughts should be put into it. Aka, something like this should probably be possible:

1st:(3 animators simultaneously)
Then when the last one finishes (and maybe an option for when the first one finishes?)
2nd:(1 other animator)
Then loop on finish.

It could be a very good addition, as long as it's clean and easy to use.

Probably would be good if "chains" could be used inside one another too.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

I can do those easily. Does anyone else want that too?
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Post Reply