Changes between Version 9 and Version 10 of BasicAnimationImplementation


Ignore:
Timestamp:
Aug 26, 2013, 7:14:06 PM (11 years ago)
Author:
wraitii
Comment:

I've just found out how to properly export an animation in-game so I'll finish this tutorial since the process is cryptic and undocumented. Still a lot TODO

Legend:

Unmodified
Added
Removed
Modified
  • BasicAnimationImplementation

    v9 v10  
    11= Basic Animation Exporting =
     2[[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.
     3
     4Since this process is not extremely straightforward, I will preface this tutorial with some information about the game's 3D engine regarding animations.
     5
     6== Animations in 0 A.D. ==
     7Animations 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.
     8
     9 * Animations: obviously, those files define animations. Each file can only define one animation.
     10 * 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.
     11
     12Using skeletons for animations makes the process a little tricky, so this tutorial will begin by explaining how to animate an object in Blender, then how to export it so that it works in 0 A.D.[[BR]]With that in mind, let's start.
    213
    314== 3D Animation ==
     
    3041[[Image(http://i.imgur.com/7VpDq.png)]]
    3142
    32  * '''STEP 7''' In the "Vertex Groups" box in the Object Data panel, you should see a vertex group called "Bone" selected. This vertex group corresponds to the bone in the armature. To make that bone move all the vertices in the cube, select all the vertices of the cube using the A key with your mouse over the 3D View, then press the "Assign" button under the list of vertex groups.
     43 * '''STEP 7''' In the "Vertex Groups" box in the Object Data panel, you should see a vertex group called "Bone" selected. This vertex group corresponds to the bone in the armature. To make that bone move all the vertices in the cube, select all the vertices of the cube using the A key with your mouse over the 3D View, then press the "Assign" button under the list of vertex groups. Note here that you can change the name of the bone (this will matter for exportation in 0 A.D.)
    3344
    3445[[Image(http://i.imgur.com/aCqKh.png)]] [[Image(http://i.imgur.com/cDbq4.png)]]
     
    3950
    4051 * '''STEP 9''' Select the bone. Press G to move it around, and R to rotate it. When you have it in the position you want it in, left-click to set its location. To to move it or rotate it around only one axis, use this panel: [[Image(http://i.imgur.com/6p1Pj.png)]] to add the "widgets" to your 3D view that let you.
     52
    4153If you want to cancel the transform, right-click or press Esc. After setting its location, press I and select one of the options. The one I use is LocRotScale, which means it'll make a keyframe which includes the location change, the rotation change, and the scale change. 0 A.D. doesn't actually support scale, though.
    4254
     
    4456
    4557 * '''STEP 10''' Use the left and right arrow keys to change which frame you're working on. When you've changed the frame to the one you want to add a keyframe, repeat step 9. You can tell which frame you're on by this number: [[Image(http://i.imgur.com/G5pdr.png)]]
     58
    4659To play back your animation, press Alt+A. To change the length of the animation, go into the "Render" panel in the Properties panel and look at the Frame Range in the Dimensions section.
    4760
    4861[[Image(http://i.imgur.com/SNOas.png)]] [[Image(http://i.imgur.com/jirAX.png)]]
     62
     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:
     67
     68{{{
     69TODO
     70}}}
     71 * '''STEP 2 ''': Todo