Changes between Version 10 and Version 11 of BasicAnimationImplementation


Ignore:
Timestamp:
Aug 27, 2013, 10:33:38 AM (11 years ago)
Author:
wraitii
Comment:

"Finish" the animation tutorial. I still need to test a few things, and it's probably far from perfect.

Legend:

Unmodified
Added
Removed
Modified
  • BasicAnimationImplementation

    v10 v11  
    22[[TOC]] In this tutorial we are going to animate the crate/box object created in the previous [http://trac.wildfiregames.com/wiki/Basic3DImplementation tutorial] to demonstrate the process of importing a basic animated model into 0 A.D. This example can be extended to work with more complex models.
    33
    4 Since this process is not extremely straightforward, I will preface this tutorial with some information about the game's 3D engine regarding animations.
     4Since this process is not extremely straightforward, I will preface this tutorial with some information about the game's 3D engine regarding animations.[[BR]](Note: this tutorial is fairly verbose and in-depth. If you already have a rigged model in Blender and some knowledge about the game's art folder (where to put textures…), I recommend you skip straight to the end).
    55
    66== Animations in 0 A.D. ==
    7 Animations in 0 A.D. rely on three types of files: * Meshes: those are the basic files that define how an object will look like in-game, such as the crate object in the [[Basic3DImplementation]] tutorial. Meshes also contain the "Armature", that is the bones that will be animated.
     7Animations in 0 A.D. rely on three types of files:
    88
     9 * Meshes: those are the basic files that define how an object will look like in-game, such as the crate object in the [[Basic3DImplementation]] tutorial. Meshes also contain the "Armature", that is the bones that will be animated.
    910 * Animations: obviously, those files define animations. Each file can only define one animation.
    1011 * Skeletons: those define "Skeletons", an in-game concept that defines hierarchical relations between bones. You might think that this is redundant with the armature information in the Model files, and in fact it is. However, they are used to parse animations more easily. Each skeleton can be reused by many different models and animations, which adds a layer of abstraction on top of the 3D meshes.
     
    6162[[Image(http://i.imgur.com/SNOas.png)]] [[Image(http://i.imgur.com/jirAX.png)]]
    6263
    63 == Exporting the animated Model to 0 A.D. ==
    64  * '''STEP 1''' To export your mesh into 0 A.D. and for it to load without issues, your armature needs to conform to a Skeleton file. Therefore, the first step will be finding a proper Skeleton file for your armature or, if there is none, to create a new one.[[BR]]
    65    * '''STEP 1-A: using an existing skeleton '''Skeletons are defined in `binaries\data\mods\public\art\skeletons`. Open rowing_boat.xml (why? Because it's one of the smallest files).[[BR]]You will notice two main parts: one defined by `<standart_skeleton>` and one by `<skeleton>`. This is because there is a default skeletons and we can define subsets from that (this helps support different 3D softwares).[[BR]](screenshot here)[[BR]]You will also notice a few `<bone>` identifiers, which are hierarchically defined (RowingBoatBone is the parent of RightRow and LeftRow). If you want to use this skeleton, your armature needs to conform to the skeleton file. In the case of the rowing boat skeleton, this means your model must have a bone named RowingBoatBone (see step 7) above, and then two bones RightRow and LeftRow which have RowingBoatBone as a parent (see step TODO), and no other bone. Update your model accordingly (note: using an existing skeleton only makes sense if your model fits the scheme. If you're designing a chicken, you should use the Chicken skeleton which will make more sense).[[BR]]
    66    * '''STEP 1-B: creating a new skeleton''' Since our model is a crate, it doesn't make sense to use any existing skeleton. Thus, we will create our own. Copy any of the files in binaries\data\mods\public\art\skeletons and name it "CrateBox.xml". Then open this file in NotePad++. Erase everything and copy the following, then save the file:
     64== Exporting the animated Model into 0 A.D. ==
     65 * '''STEP 1''' To export your model into 0 A.D. and for it to load without issues, your armature needs to conform to a Skeleton file. Therefore, the first step will be finding a proper Skeleton file for your armature or, if there is none, to create a new one.
     66
     67 * '''STEP 1-A: using an existing skeleton''' Skeletons are defined in `binaries\data\mods\public\art\skeletons`. Go there and open rowing_boat.xml (why? Because it's one of the smallest files).[[BR]]You will notice two main blocks: one defined by `<standart_skeleton>` and one by `<skeleton>`. This is because there is a default skeleton and we can define subsets from that (this helps support different 3D softwares).
    6768
    6869{{{
    69 TODO
     70#!xml
     71<skeletons>
     72<standard_skeleton title="Rowing Boat" id="rowingboat">
     73  <bone name="RowingBoatBone">
     74    <bone name="RightRow"></bone>
     75    <bone name="LeftRow"></bone>
     76  </bone>
     77</standard_skeleton>
     78  <skeleton title="Rowing Boat" target="rowingboat">
     79    <identifier>
     80      <root>RowingBoat</root>
     81    </identifier>
     82    <bone name="RowingBoatBone"><target>RowingBoatBone</target>
     83      <bone name="RightRow"><target>RightRow</target></bone>
     84      <bone name="LeftRow"><target>LeftRow</target></bone>
     85    </bone>
     86  </skeleton>
     87</skeletons>
    7088}}}
    71  * '''STEP 2 ''': Todo
     89 As you can see, there are also `<bone>`           blocks, which are hierarchically defined in <standard_skeleton> (RowingBoatBone           is the parent of RightRow           and LeftRow          ).[[BR]]          If you want to use this skeleton, you thus need an armature which has a main bone named RowingBoatBone           (see step 7 above on how to rename bones), and two bones RightRow           and LeftRow          , both having RowingBoatBone           as their parent (see step TODO). If such a scheme makes sense for your model (for example if you're making a new rowing boat), you can then use this skeleton by naming your bones appropriately.[[BR]]
     90
     91 * '''STEP 1-B: creating a new skeleton''' Since our model is a crate, it doesn't make sense to use any existing skeleton. Thus, we will create our own. Copy any of the files in binaries\data\mods\public\art\skeletons and name it "CrateBox.xml". Then open this file in NotePad++. Erase everything and copy the following, then save the file:
     92
     93{{{
     94#!xml
     95<skeletons>
     96<standard_skeleton title="CrateBox" id="cratebox">
     97  <bone name="CrateBox"></bone>
     98</standard_skeleton>
     99  <skeleton title="Rowing Boat" target="rowingboat">
     100    <identifier>
     101      <root>CrateBox</root>
     102    </identifier>
     103    <bone name="CrateBox"><target>CrateBox</target></bone>
     104  </skeleton>
     105</skeletons>
     106}}}
     107 * '''STEP 2 ''': Now that our model and armature have been made usable in 0 A.D. (either by conforming to an existing skeleton or creating a new one), we will export the model. Right click on the crate so it's the only selected element, then go to File->export->collada.dae in the menubar.
     108
     109 [[Image(http://i.imgur.com/VbBJeZI.jpg)]] [[BR]]
     110
     111 * '''STEP 3''' You can now choose where to save your files and what name to give it. This is not important for putting the model in 0 A.D., but it's generally good practice to follow the game's existing methods (usually a model is named civ_name where "civ" is the shortcut for the civilization's name (cf brit for britons) and where name is fairly descriptive). For exporting, you should use the following settings (the important part is here is that you can only export one model with its armature at most):
     112
     113 [[Image(http://i.imgur.com/nERDoNY.png)]] [[BR]]
     114
     115 * '''STEP 4''' You now have your crate box file saved somewhere. For the sake of simplicity, I recommend you first follow the guidelines in [[Basic3DImplementation]], section "Actor File Setup". This means you need to put your .dae file in `art\meshes\props\`.[[BR]]Go to "crate_test.xml" in `binaries\data\mods\public\art\actors\props\special\eyecandy` and change the code so it now looks like this:
     116
     117{{{
     118#!xml
     119<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
     120<actor version="1">
     121
     122  <castshadow/>
     123
     124  <group>
     125    <variant frequency="100" name="Base">
     126      <animations>
     127        <animation file="mechanical/crate_animation.dae" name="Idle" speed="10"/>
     128      </animations>
     129      <mesh>props/wrld_crate_test.dae</mesh>
     130      <textures><texture file="props/crate_test.png" name="baseTex"/></textures>
     131    </variant>
     132  </group>
     133
     134</actor>
     135}}}
     136 * '''STEP 5''' Once you have saved the actor file with the changes, make a copy of your .dae file for the rigged crate and name it "crate_animation.dae". Move this file to `art\animation\mechanical.`
     137
     138 * '''STEP 6''' At this point, you should have created 4 files: an actor file, a texture for your model, your rigged model, and your animation file. You can then launch 0 A.D., open the scenario editor, go to the object tab and you should be able to find your crate in the list (you need to select Actor(All) for this to work). If you place a few boxes, you should see them animated.
     139
     140 [[Image(http://i.imgur.com/QVJLMyM.png)]] [[BR]]
     141
     142
     143
     144= Short summary =
     145 * Your model needs to be rigged with an armature using vertex groups.
     146 * Your armature needs to follow the guidelines of a skeleton file in `binaries\data\mods\public\art\skeletons`. You must name your bones accordingly if you use an existing one, or create a new one that will fit the scheme of your armature (note: as of now, I'm not sure if the hierarchical relations must be followed or not, I'd assume yes.)
     147 * You can only export one model and its armature at a time (see step 3 above). Your model needs to be exported with the animation if you want it to be animated, but the "native" animation it is exported with doesn't matter.
     148 * You can only export one animation at a time. The animation is defined as any movement between the start frame and the end frame in Blender. To export an animation, you need to export the model and the animation.
     149 * Your actor needs to have the proper definitions for all your animations.