Questions on implementing animation

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Questions on implementing animation

Post by shadowghost21 »

These animations are not the mesh kind. I am talking moving object 1 at point a to point b in some time unit. I assume most people set up some kind position, destination, speed, and then on every update call move the object that distance over delta time of the frame (for frame independent animations). I just feel as I get deeper into writing my game, the more stuff I find myself needing(and to write myself). And while I posses the technical ability to write some kind of animation manager(I don't posses the time) it would be nice if there was a library that would off load some of the code load so I can focus on other aspects until I get enough time to write my own. So if there isn't anything nice (I'm think like iOS's neat animation blocks, for those that have done any iPhone programming) would here is what I would do:

AnimationManager, gets called on the main game loop before drawing all the stuff.
AnimationManger has an UPDATE(s32 deltaTime) method that is actually called.
Animation manager processes it's array of animations(defined below) and checks for ending conditions

And maybe this could be a base class or Interface that you would implement on top of ISceneMesh or some such. Maybe with a little more though that my caffeine induced code rage below :)

Code: Select all

struct animation {
    vector3df start;
    vector3df end;
    vector3df rotation;
    vector3df scale;
    f32 speed;
};
 


I can see that there are lots of ways to represent some kind of animation. Because there are different types of animations, like the main 3: position, rotation, scale. If anyone has any good ideas to add or tell me I am completely wrong, I would love to hear some ideas before I sink time into it. Although after writing this post I don't think it would take that much time to get a rough refactorable draft of an animation manager. I may give it a go this weekend if the idea strikes me again and I might just share :)

EDIT: I wanted to add that the reason I bring this up is because well besides the obvious need for animations, moving planets around (they don't really need to use physics) and ordering units to move in an RTS game would hugely useful. I do assume that some people on here use Irrlicht to games and maybe those people would like to share a bit of postmortem wisdom with those who don't have such experiences.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Questions on implementing animation

Post by Radikalizm »

Irrlicht has the IAnimator class for handling scene node animations, and considering your post I think this is pretty much what you're looking for
You can just inherit the IAnimator class to build an animator with custom behaviour. Animators get updated whenever a scene node registers itself with the scene manager, it automatically gets a delta-time value from the scene node and it can check for ending conditions on its own each frame if you want to

There's no need for extra bloat and additional god-classes like an animation manager, everything you're looking for is already in the engine
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: Questions on implementing animation

Post by shadowghost21 »

*face palm* I feel stupid for not taking a look earlier. I have seen in it Intellisense a few times but just though it was for animating meshes and not actually moving them around the screen. I like your solution sir. Thank you, I'll have a look at that tonight!
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: Questions on implementing animation

Post by shadowghost21 »

How about animating GUI elements? Does this still apply?
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Questions on implementing animation

Post by Radikalizm »

No, there are no animators for GUI elements as far as I know
shadowghost21
Posts: 56
Joined: Wed Nov 23, 2011 11:53 pm

Re: Questions on implementing animation

Post by shadowghost21 »

Bummer. I did think about building the gui from 3d objects but that means a lot of extra code or at least a another class to do everything. I'll think up some ways around it. Thanks again Radiklizm
Post Reply