Changes between Version 2 and Version 3 of AnimationExportTutorial


Ignore:
Timestamp:
May 4, 2014, 6:08:07 AM (10 years ago)
Author:
leper
Comment:

More wikification

Legend:

Unmodified
Added
Removed
Modified
  • AnimationExportTutorial

    v2 v3  
     1[[TOC]]
     2
    13= Introduction =
    24This is a guide covering how to export and set up animation files from Blender3D into 0AD as well as some tips and general guidelines for get the animations working in 0 AD.[[BR]]The guide assumes you're using a modern version of Blender (2.69 at the time of writing). It doesn't handle actual rigging or modeling, only exporting to 0 AD. It is easier to follow if you are used to Blender's dopesheet window.
     
    810 1. The XML file describing the armature (called skeleton in 0AD) with its bones names and hierarchy.
    911
    10 Once that is done, an actor XML file needs to be created to link the mesh with its animations, textures, etc.
     12Once that is done, an [wiki:Actors actor XML file] needs to be created to link the mesh with its animations, textures, etc.
    1113
    1214''Click to enlarge images.''
     
    1517Blender has many options and tools to make animation easier and improve the result automatically. However, much of that information is lost when exporting to COLLADA. Here are guidelines to keep in mind when configuring your rig to make animations for 0AD:
    1618
    17 '''Use only one object and one armature.'''
     19=== Use only one object and one armature.
    1820
    1921A limitation of the game's engine is that COLLADA files with more than one mesh object will not load. It is recommended you work on only one object and its armature (you can use "only selected" when exporting, but this makes things easier). Note that this means that if you want prop points, they must be bones. Only non-rigged meshes can use empties.
    2022
    21 '''Use "vertex groups" and not envelopes.'''
     23=== Use "vertex groups" and not envelopes.
    2224
    23 '''Avoid disabling "inherit rotation" in bones.'''
     25=== Avoid disabling "inherit rotation" in bones.
    2426
    2527While it's a very nice blender feature, when exporting your animation the bones that have their inherit rotation checkbox disabled end up inheriting their parent's rotation, plus the extra rotation you add in the animation resulting in weird and undesired behaviors. There's a tricky workaround for this, which is creating a helper bone which the bone that you don't want to rotate will copy its rotation.
    2628
    27 '''Make sure the rig have the correct scale, and has its scale applied before start animating.'''
     29=== Make sure the rig have the correct scale, and has its scale applied before start animating.
    2830
    2931Resizing your rig and/or mesh and applying its new scale before baking the animation may end up messing the animations you may already have, specially if you have any IK (Inverse Kinematics) setup in your rig. I recommend you avoid any scaling of the objects. If you have to scale, scale in edit mode. However, here's a workaround that may or may not work:
     
    3335 * Import them back into blender, scale them correctly, and export them back without applying the scale one by one.
    3436
    35 '''Export only baked animations with "Clear Constraints" or sampled animations.[[BR]]'''Many constraints (IK constraints, bone constraints) are not exported to COLLADA. This means that your animation could look fine in Blender, but will be broken in-game. To avoid this, either sample your keyframes (add a keyframe to every frame) using shift-o in the dopeSheet editor, or bake your animations using "Clear Constraints".
     37=== Export only baked animations with "Clear Constraints" or sampled animations.
    3638
    37 '''Save your .blend file before exporting.[[BR]]'''You will lose your rig constraints when baking the animation, and importing COLLADA back into blender loses information and is often broken. Because of this, if you want to tweak an animation, or use the same skeleton/rig to create a new one, the only way to do it right now is using the .blend file.
     39Many constraints (IK constraints, bone constraints) are not exported to COLLADA. This means that your animation could look fine in Blender, but will be broken in-game. To avoid this, either sample your keyframes (add a keyframe to every frame) using shift-o in the dopeSheet editor, or bake your animations using "Clear Constraints".
     40
     41=== Save your .blend file before exporting.
     42
     43You will lose your rig constraints when baking the animation, and importing COLLADA back into blender loses information and is often broken. Because of this, if you want to tweak an animation, or use the same skeleton/rig to create a new one, the only way to do it right now is using the .blend file.
    3844
    3945In this guide, we're going to set up the animations for a wild animal unit "Tiger" that will be controlled by the IA "Gaia".
    4046
    41 = 1 - Exporting the .DAE file with the mesh and armature =
     47== 1 - Exporting the .DAE file with the mesh and armature
    4248In this step, we're going to use Blender3D to create the main file needed for the unit's animation.[[BR]]This file tells the engine the relationship between the bones and the mesh. You will need a rigged mesh.
    4349
     
    5662Navigate to the folder where you want the file to be created, name the file, and change the export settings so that they look like the screenshot below. You can use "Apply modifiers" safely as long as it doesn't apply the armature modifier, and you can use "Include Children" if you are using prop points.
    5763
    58 ,,Note: These "mesh+armature" files are stored in \0AD\binaries\data\mods\public\art\meshes\ . There are subfolders, pick the most appropriate one.,,
     64,,Note: These "mesh+armature" files are stored in [source:ps/trunk/binaries/data/mods/public/art/meshes binaries/data/mods/public/art/meshes]. There are subfolders, pick the most appropriate one.,,
    5965
    6066[[Image(http://i.imgur.com/kVLRgsc.png, 50px, align=center)]]
    6167
    62 = 2 - Exporting the .DAE file animations =
     68== 2 - Exporting the .DAE file animations
    6369In Blender3D, you have to use the "action editor" to create the different actions (or animations) that you want to export into 0AD to use them. These actions are usually: walk, run, idle, attack, and death, but you can make variations of each one or make more types of actions if desired (check existing actor files to know which). While this tutorial does not cover how to animate in Blender3D, there are links to existing tutorials at the bottom of this page.
    6470
    65 == 2.1- Baking the action to keyframes or sampling the keyframes. ==
     71=== 2.1 - Baking the action to keyframes or sampling the keyframes.
    6672Blender3D interpolates between keyframes. This behavior is not kept automatically when exporting to COLLADA, so you need to tell Blender how to properly export your animation. There are two ways to do this, one is baking animations, the other is sampling the animation. Baking creates keyframes only for bones that are actually animated. Sampling creates them for all bones.
    6773
     
    7682[[Image(http://i.imgur.com/Sp8N9iN.jpg, align=center, 400px)]]
    7783
    78 == 2.2- Exporting the animation .DAE file ==
     84=== 2.2- Exporting the animation .DAE file
    7985This uses the same process as in point 1 above. Make sure you have only selected your mesh and its armature before exporting.[[BR]]Repeat 2.1 and 2.2 for each animation of the unit and name them accordingly. A general convention in game is that animations are named "mesh_animationType.dae", but you are free not to follow it.[[BR]],,Animation files are stored in \0AD\binaries\data\mods\public\art\animation\ (there are subfolders, pick the most appropriate one),,
    8086
    8187Animation files in-game are independent from the mesh with which they are exported. This means that any two units that have the same skeleton can use the same animation. Note that this doesn't account for potential scale issues, since it is possible to have units with the same skeleton (bone hierarchy…) and different sizes.
    8288
    83 = 3 - Creating the XML file describing the skeleton =
    84 0 AD needs a .XML file that describes the Blender armature, called a skeleton file. They are located in "\0AD\binaries\data\mods\public\art\skeletons\".
     89== 3 - Creating the XML file describing the skeleton
     900 AD needs a .XML file that describes the Blender armature, called a skeleton file. They are located in [source:ps/trunk/binaries/data/mods/public/art/skeletons/ binaries/data/mods/public/art/skeletons].
    8591
    8692The easiest way to set up one  is to open an existing file and modify it with the information of the new skeleton you want to add and save it as a new file. You can open .XML files with any text editor software.
     
    94100Once you have completed setting up the file, use "save as" and save the .xml file with an appropriate name in the folder specified at the beginning of this section.
    95101
    96 = Creating the actor file =
    97 Every unit (or entity) in 0 AD has it's own .XML file containing information that the engine can read. These files are called actors.
     102== Creating the [wiki:Actors actor file]
     103Every unit (or entity) in 0 AD has it's own .XML file containing information that the engine can read. These files are called [wiki:Actors actors].
    98104
    99105Some properties that contains these actor files are:
     
    105111 * Animation(s): Animations that the unit or entity can use and the variant/state associated with that animation.
    106112
    107 Animations in the actor files are normally specified just before the <mesh> tag in the following format:
     113Animations in the actor files are normally specified just before the ''<mesh>'' tag in the following format:
    108114
    109115[[Image(http://i.imgur.com/lrNRmQnl.png, 400px, align=center)]]
     
    111117The <animation> tags in this example include the location and filename of the animation (created in section 2), the name of the variant/state that will use that animation specified by "name=", and the speed at which the animation will play (see AnimationSync for more information as this value is not that trivial to understand).
    112118
    113 == Loading and hiding props during an animation ==
     119=== Loading and hiding props during an animation
    114120There are cases when you might want a prop to appear in the middle of an animation and not at the start (an archer's arrow…). To do this, you need to add a "load=X" parameter. X takes values between "0" (start of the animation) and "1" (end of the animation). Setting Load="0.5" means that at the middle of your animation, this prop will appear. Using "event=X" makes the prop disappear and works similarly. You will need to name your prop attachpoint "loaded-NAME".[[BR]]You need specific variants for this to work. The "attack_ranged" variant below uses this example.
    115121
     
    118124In this example the actor "arrow_back.xml" is going to be loaded at 16% of the duration of the build animation, and it will disappear at 84%. You specify where the prop actor will be placed with "attachpoint=" . The attachpoint value needs to be the name of a bone/empty object, whose name (in Blender) will be "prop-NAME".
    119125
    120 Static meshes without skeleton should use empties parented to the mesh with the name prefix of "prop-". You can later use this empty location to spawn an actor on it's place when defining the props between the <prop> tags right after the <mesh> definition in the actor file. The props will inherit the empties rotation and position, but not scale.
     126Static meshes without skeleton should use empties parented to the mesh with the name prefix of "prop-". You can later use this empty location to spawn an actor on it's place when defining the props between the ''<prop>'' tags right after the ''<mesh>'' definition in the actor file. The props will inherit the empties rotation and position, but not scale.
    121127
    122 ----
    123 '''''Rigging Tutorials:'''''
     128
     129== References
     130
     131=== Rigging Tutorials:
    124132
    125133http://vimeo.com/30073532 [[BR]]http://vimeo.com/30072564 [[BR]]http://vimeo.com/30078317
    126134
    127 '''''Animation Tutorials:'''''
     135=== Animation Tutorials:
    128136
    129137http://www.cgmasters.net/free-tutorials/epic-looping-idles/ [[BR]]http://cgcookie.com/blender/2011/08/22/animating-a-character-picking-up-an-object/
    130138
    131 '''''Import/export 0 AD assets and AO baking:'''''
     139=== Import/export 0 AD assets and AO baking:
    132140
    133141http://www.wildfiregames.com/forum/index.php?showtopic=17542&p=273078