About Store Forum Documentation Contact



Post Reply 
Animation management
Author Message
JonathonA Offline
Member

Post: #1
Animation management
Working on code for managing the animations and mapping them to ids to avoid hardcoding animation file paths and wanted to hear the communities thoughts/experiences if thats okay?

I have had experience of this before where I used four character codes defined in .csv or tab delimited files that map the codes to an animation file and other attributes were available too such as looping, affected bones etc.

In code, the four character codes were defined in an enum, so for example, ANIM_IDLE = 'idle', WALK_BACKWARD = 'wlkb', RUN_FORWARD = 'runf' etc.

Benefit of these csvs was allowing the artists/builders to swap out animations as they saw fit. One of the problems that came up was whenever you want to add more animation types you'd have to edit the code to add a new type and I was wondering what ways there are around that? Also wondered if anyone has had experiences using strings instead of enums or maybe hash tables and if you managed to make a flexible system for managing animations that avoids the need to rebuild the code every time a new animation is required.

Look forward to hearing some thoughts on this smile
(This post was last modified: 03-19-2012 06:58 PM by JonathonA.)
03-19-2012 05:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #2
RE: Animation management
In a different engine I did something like this. I made an animator class that was used to manage the finer details of animating all character like objects. Each NPC or Character had it's own instance of animator which it could call updates and animation requests from.

All you had to do was update the animator each frame and call in new animations to blend in when required. It even handled automatic return to idle, automatic random emote playing on idle and other features.

I used SQLite3 to specify animations for each object. That way without changing the code you could change or add animations no problems. This is called Data Driven Design and I consider it to be one of the most important design techniques when it comes to flexible code whether you use SQL, XML, TXT Files or whatever, it's a good habit to get into doing this. The coder shouldn't have to change the code to accommodate new animations or change existing animations.

To allow for infinite number of animations I used and STL std::map<std::string, Animation*> This way you can add as many animations as you want and it worked well. However, for EE I would probably use the EE map container instead. My animator class used strings to identify animations and it worked fine. However, in hindsight it would have been better (performance wise) to have use enums instead.

So to sum it up... the way you explained it sounds about the right way to do it.. Not just for animation but for almost everything in your game if possible. Luckily, unlike the last engine I used, EE does a lot of the DDD for you in those other areas.

Let us know how you go with it.

Scarlet Thread Development Blog: http://nanodev.tumblr.com/
Esenthel Tutorials Blog: http://scarlettutorials.tumblr.com/
YouTube Channel: http://www.youtube.com/user/ScarletThreadStudios?feature=mhee
(This post was last modified: 01-14-2013 04:20 AM by Scarlet Thread.)
01-14-2013 04:17 AM
Find all posts by this user Quote this message in a reply
Post Reply