Version 10 (modified by wraitii, 6 years ago) (diff)

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

Basic Animation Exporting

In this tutorial we are going to animate the crate/box object created in the previous 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.

Since this process is not extremely straightforward, I will preface this tutorial with some information about the game's 3D engine regarding animations.

Animations in 0 A.D.

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.

  • Animations: obviously, those files define animations. Each file can only define one animation.
  • 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.

Using 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.
With that in mind, let's start.

3D Animation

  • STEP 2 Press space and type in "Armature" in the search box that comes up, and press enter. (This will activate the first option that Blender finds)

  • STEP 3 Find Properties panel. If you can't find it, then set one of your panels (other than the 3D View) to the Properties panel.

  • STEP 4 Select "Object Data" in the tab bar on the Properties panel.

  • STEP 4 Check X-Ray in the "Display" box. This will allow you to see the bones through the mesh so you can manipulate the bones even when the bones are enveloped by the mesh they deform.

  • STEP 5 Select the mesh and then the armature in that order, and press Ctrl+P. Blender will give you 6 options of how the mesh should interact with the rig. Rigs for 0 A.D. should use vertex groups (which allow you to select exactly which vertices move with which bones) so the deformations can be made to look as natural as possible. (Bone envelopes, which are basically automatic groups, often will make the deformation look totally wrong.)

  • STEP 6 Select the mesh and go into edit mode using the menu on the left side of the bar along the bottom of the 3D View, or by pressing Tab.

  • 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.)

  • STEP 8 Exit edit mode using the menu or by pressing Tab, then select the armature. Go into "Pose Mode" using the same menu. This will allow you to move the bone around and have the cube move with it while animating.

  • 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: to add the "widgets" to your 3D view that let you.

If 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.

  • 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:

To 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.

Exporting the animated Model to 0 A.D.

  • 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.
    • 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).
      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).
      (screenshot here)
      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).
    • 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:
  • STEP 2 : Todo