Animation System 4 – Data Driven Workflow

Now since I have working and stable animation systems in the engine –

  • Skeletal Animation for Characters (Software Skinning & HW Indexed Skinning)
  • Non Skeletal Animation for animating objects
  • Facial Animation

Next step is to create a data driven workflow.  Right now to import a model in the engine, playing a particular animation and assigning events I have to hard everything into the C++ code itself. And in case I have to blend multiple animations that  creates another long code mess.

A proper way to do things will be to let user be able to choose things at Run Time without have to modify code. Now the ideal way to do it is to make an editor to where user can easily edit any animation related properties and save them into a file which can be loaded and used at the runtime, but my level editor itself is very long due and I don’t want to make a separate application for this purpose for now. So solution I was searching for is something based on easily editable file format. So these were my goals when trying to decide for a particular text-based file format –

  • Easy to Read and Edit in Notepad (or any other text file editor)
  • Implementing parser or read/write code for file format shouldn’t take much time because this is a temporary thing for now, later at sometime I will switch to editor for sure.

So first I thought maybe some XML based format. Even thought writing a xml parser could take some more time but there are some open source xml parsers available for the job. But XML format is not that easy to edit in Notepad.

I thought maybe make something like a file format like I had for my terrain loader just specify all properties one after other with each property in each line or maybe separated by spaces.

Something like –

heightmap257.raw
10
10

But as you can see by file itself no one can tell what that file name or 10 means.A better way would be something like –

Animation Name - "walk"
Type - Loop

Making these Name / value pairs are much better than simple values in each line. So one standard format that already supports this is INI files. I still remember messing with car properties in old NFS HotPersuit  which was interesting.

So next thought came to my mind is how to parse these INI files. These INI files are old way of specifying properties for windows app. So I searched on internet if there is some standard support for it in VC++ or not. Also looked for some text-based formats others are using.  I found there’s in fact some function in VC++ to read and write separate properties of INI files. So I decided that’s the way to go. I also eventually landed on some pages about the mentioning of same thing in some GameInstitute’s Tutorials which I already had from long time back. So I also referred their way of handling animation workflow with .ini files.

So anyways here are the goals that I had for my file format . We should be able to load character and then provide various animation related parameters an should also be able to specify some common event types and data for it.

For example :- Specifying the name of walk cycle animation and its type to loop. Then be able to specify an event to play footstep sound  at specific time.

Also wanted to specify various blending parameters along with events and other stuff. Because if we think of any character in any game they mostly play multiple animations blended together e.g. shooting + walk, shoot + run, etc. This also saves a lot of time in art production because artist can only create 2 animation walk and shoot and rest will be handled in engine by blending or changing speeds for different animations etc. So 1 particular group of sequence that defines one complete behaviour in-game is termed as action here e.g. IdleWalk, RunningShoot, etc. ,   which are composed of multiple animations having different properties.

So here is a sample of how my file structure looks like this –


[Action1]

Name = Walk_Shooting
DefinitionCount = 3

Definition[0].SetName = Walk_Legs_Only
Definition[0].GroupName = Legs
Definition[0].Weight = 1.0
Definition[0].Speed = 1.0
Definition[0].BlendMode = MixFadeGroup
Definition[0].MixLength = 0.3
Definition[0].TimeMode = MatchGroup

Definition[1].SetName = Walk_Variation
Definition[1].GroupName = Hips
Definition[1].Weight = 1.0
Definition[1].Speed = 1.0
Definition[1].BlendMode = MixFadeGroup
Definition[1].MixLength = 0.5
Definition[1].TimeMode = MatchSpecifiedGroup
Definition[1].TimeGroup = Legs

Definition[2].SetName = Gun_Shooting_Pose
Definition[2].GroupName = Torso
Definition[2].Weight = 1.0
Definition[2].Speed = 1.0
Definition[2].BlendMode = MixFadeGroup
Definition[2].MixLength = 1.0
Definition[2].TimeMode = Begin

And here’s a screenshot  of animation system in work  –

So this text file system based on INI files is simple and easy to use for now but reading and writing INI files are very slow compared to binary files. For now couple of files won’t create that much difference but later on at some point as soon as I get some editor ready for managing animation system I would be switching to binary format so we can read and write much quickly.

References –

Game Engine Architecture (A very good reference about how animation system actually works in a game engine)

GameInstitute’s 3D Graphics Programming (for those who are interested in the action file format using INI files i mentioned above)

Advertisements

About chetanjags

Game Developer

Posted on September 22, 2012, in JustAnotherGameEngine and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: