Building animation sets at run-time

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderators: Forum Moderators, Developers

Forum rules
Before posting a new idea, you must read the following:
Post Reply
iinscrutable
Posts: 23
Joined: March 4th, 2008, 6:51 am
Contact:

Building animation sets at run-time

Post by iinscrutable » November 3rd, 2008, 5:23 pm

The idea is to allow mixing of several images into a new one by using, for example, Cairo (http://www.cairographics.org/) binding to WML. This can greatly improve graphics in RPG-style scenarios. For example, if the character can wield 4 different swords (differing in appearance, not just stats), 4 different shields and 3 helmets, scenario builder have to draw 48 animation sets (for each combination of sword, shield and helmet). With ability to mix images, the number drops to 12: 4 animations of swords in motion, 4 for shields, 3 for helmets and 1 for character itself; all of 48 animations will be rendered by combining character image with equipped sword, shield and helmet. Generated animation sets can be cached for later use.

This can look like the following (simplified form):

Code: Select all

[attack_anim]
  ...
  [frame]
    ...
    image = {MIX_IMAGES "images/units/{CHARACTER_RACE}_FACE_{DIRECTION}_ATK_STEP_2.png" "images/weapons/{EQUIPPED_WEAPON}_FACE_{DIRECTION}_ATK_STEP_2.png" "images/shields/{EQUIPPED_SHIELD}_FACE_{DIRECTION}_ATK_STEP_2.png" }
  [/frame]
  ...
[/attack_anim]

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Building animation sets at run-time

Post by zookeeper » November 3rd, 2008, 5:50 pm

Well, actually you could do all that with 1.5.x WML alone, no need for any Cairo bindings. Of course it'd be pretty darn complicated, but then again, probably still easier than the alternatives.

Basically, what you'd need is to dynamically generate all animations for the unit into some variable and then give those animations to the unit with the help of [insert_tag]. The resulting animations for attacking and standing for a dude with a red sword, green helmet and big shield would thus end up looking a bit like this:

Code: Select all

[attack_anim]
    ...
    
    [frame]
        image=dude-swinging-red-sword-1.png
    [/frame]
    [frame]
        image=dude-swinging-red-sword-2.png
    [/frame]
    
    [sword_frame]
        image=red-sword-striking-1.png
    [/sword_frame]
    [sword_frame]
        image=red-sword-striking-2.png
    [/sword_frame]
    
    [helmet_frame]
        image=green-helmet-striking-1.png
    [/helmet_frame]
    [helmet_frame]
        image=green-helmet-striking-2.png
    [/helmet_frame]
    
    [shield_frame]
        image=big-shield-striking-1.png
    [/shield_frame]
    [shield_frame]
        image=big-shield-striking-2.png
    [/shield_frame]
[/attack_anim]

[standing_anim]
    ...
    
    [frame]
        image=dude-standing-with-red-sword.png
    [/frame]
    
    [sword_frame]
        image=red-sword-standing.png
    [/sword_frame]
    
    [helmet_frame]
        image=green-helmet-standing.png
    [/helmet_frame]
    
    [shield_frame]
        image=big-shield-standing.png
    [/shield_frame]
[/standing_anim]
It actually shouldn't be unfeasibly hard at all, provided that all the items have basically identical animations. Actually...heck, it should be reasonably easy. :P

Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Re: Building animation sets at run-time

Post by Rhuvaen » November 4th, 2008, 12:17 am

zookeeper wrote: Of course it'd be pretty darn complicated, ...
[and one funny example later]
Actually...heck, it should be reasonably easy. :P
Hah... is that an idea forming? :)

Two questions:
1. wouldn't you just use team color to make the guy have a red sword and green helmet (a different team color per frame :P)?

2. how would an [insert_tag] for a sword_frame for instance look like? (I have little understanding of the animation engine, actually)

Errr... just looking at AnimationWML right now, and it looks like it should just work out of the box with a given set of images...! :shock:

Post Reply