Targetware: 3D Dev Guide


Animating Moving Parts

Once you have all the parts of your plane in the right place, you're ready to start animating the propellers, gears, control surfaces, and anything else you want to have move. Animation is controlled from two sources: the .anm file via "paths" and "anims", and the .acm file, which controls when and how the animations are activated. Your work as a modeler will concentrate on the .anm file. Leave the .acm file to the engineers, and work within the limits of the plane.

Each child object in your .anm file can have 1 or more animations attached to it. There are three types of animations available: rotation, offset (movement), and replacement (swap meshes). To assign an animation to an object, add one or more PATH sections, and build one or more ANIMation sections under each path.

Example 1: Animating a Rudder (Rotation)

  name = Rudder
geometry = a6m2_rudder.lwo
offset = 0, 0.287, 5.64
rotation = 0, 0, 0

This tells the game to place the rudder 287 cm above the CoG, and 5.64 meters behind the point of origin (the main wing spar). There is no offset left/right, because the rudder is right down the center of the plane. The offset for our left aileron, however, looks like this:

  [Child 1]
name = Rudder
geometry = a6m2_rudder.lwo
offset = 0, 0.287, 5.64
rotation = 0, 0, 0
num_path = 1

[Child 1 Path 1]
link = 0
num_anim = 3

Here is a basic rotation animation from our Zero. We have a single path attached to the rudder part, with three animation states attached to that path (full left, neutral, full right). We only need the rudder to rotate on one axis, with no offset or mesh replacement action.

The activation of the animation is controlled by the link = line in the PATH section. In our example, we have the link set to 0, which means the game will take movement from the flight model object's basic animation paths (gears extending, props rotating, flaps moving, etc). It's important to note that any object to be linked to the Flight Model with link = 0 must use the same exact name the part is given in the .ACM file. You can have more than one model part using the same name (all your gear parts could/should share the same name). We could have used 102, which links the animation to Yaw input from the player, but that won't necessarily be accurate, because the control stick can move faster than the rudder itself, but we will want to use 102 later, when we animate the cockpit.

Hint: There is a full list of link actions in section 2.73.

The ANIMation section specifies the type of movement that will occur, when it should occur, and how far the piece should move:

  [Child 1 Path 1 Anim 1]
time = 0.0
type = rotate
rotate = 0, 0, -30
origin = 0, 0, 0

[Child 1 Path 1 Anim 2]
time = 0.5
type = rotate
rotate = 0, 0, 0
origin = 0, 0, 0

[Child 1 Path 1 Anim 3]
time = 1.0
type = rotate
rotate = 0, 0, 30
origin = 0, 0, 0

The time = n line runs from 0.0 to 1.0. You can set the initial state of animation with time=0.0, the end state with time = 1.0, and the mid-point with 0.5. The actual length of the animation is controlled by whatever part of the FM the path is linked to.

There is one exception to this rule: 'auto-time' animations. If auto_time is set in the PATH section to anything higher than 0.0, that number will be interpreted as the number of seconds you want the animation to run. Instead of being linked to the flight model, auto-time animations keep their own clock. If you set auto_time = 15, for example, any animations associated with that path will run for 15 seconds, then start over. If you want to animate a pilot drinking beer continuously, this is your best bet.

The type is set to rotate, because we want the rudder to swing back and forth. The degree of rotation is set to -30/0/30 degrees. These numbers were taken from the zero's .acm file:

  max_deflection = 30
min_deflection = -30

For control surfaces and such, time = 0.5 is the middle, or neutral, position. All we have to do is plug in the maximum and minimum amount of rotation, and the Flight Model will control the rest.

We set the origin is set to 0, 0, 0 to inform the game that we want the starting point of the animation to be at the rudder mesh's point of origin.

Example 2: Animating Butterfly Flaps on a Ki-44

The Ki-43 and Ki-44 use "butterfly" flaps which extend backwards, rather than rotating downwards. If they did also rotate downwards (and/or sideways), we could add that movement with a second ANIM section. But for this example, we'll assume they only slide backwards.

  [Child 4]
name = Left Flap
geometry = KI44-FLAPLEFT-2A.LWO
offset = -0.9, -1.14, -.629
rotation = 0, 0, 6
num_path = 1

[Child 4 Path 1]
link = 0
num_anim = 1

[Child 4 Path 1 Anim 1]
time = 1.0
type = offset
offset = 0, -0.3, 0

This would slide the Ki-44's left flap back 30 cm over the course of it's deployment. If we wanted to add downward movement, as for a fowler flap, we'd up the num_anim by one, and add this section:

  [Child 4 Path 1 Anim 2]
time = 1.0
type = rotation
rotate = 45, 0, 0
origin = 0, 0, 0

That would cause the flap to rotate downwards to a maximum of 45 degrees while also sliding backwards.

Example 3: Main Gear Animation with Fake Oleo Movement

You know the problem: a landing gear grows shorter in the extended position because it compresses when the plane's weight rests on it. But if you model the gear short enough so that the plane sits at the correct angle on the runway, the gear won't fit back into the gear bay with just a simple rotation. It needs to move and rotate at the same time. Short of having a full system of landing gear 'shock absorbers', which we probably will get some day, you can fake the compression and get the right length for both extended and retracted position. What we're going to do is slide the entire gear assembly up into the wing as we rotate it down.

  [Child 8]
name = Right Main Wheel
geometry = a6m_gear_r.lwo
offset = 1.813, -0.365, -0.484
rotation = 7.2, 0, 0
num_path = 1

[Child 8 Path 1]
link = 0
num_anim = 2

[Child 8 Path 1 Anim 1]
time = 1.0
type = offset
offset = 0, 0.2, 0

[Child 8 Path 1 Anim 2]
time = 1.0
type = rotation
rotate = 85, 0, 0
origin = 0, 0, 0

The offset will move the gear upwards half-way through the animation sequence. At the same time, the gear will be rotating through an arc of 85 degrees (as determined by the FM/.acm file). End result: the plane sits at the right angle when on the runway, and the gear still fits back into the right place in the gear bay.

Example 4: Propellers

For our propellers, we'll need three objects:

  • a prop hub
  • a solid model of the prop blades
  • a flat disc model of the prop with an alpha layer applied to give a blurred motion appearance.

Here is the start of our prop section:

  [Child 28]
name = Engine
geometry = a6m_prop_bladed.lwo
offset = 0, -0.025, 0
rotation = 20, 0, 0
num_path = 2

We've set the initial rotation angle at 20 degrees so that the top prop blade won't start out blocking the pilot's view. When the engine is off, or at low revs, we want to see the solid prop blades, so we start with 'a6m_prop_bladed.lwo', which is our model of solid prop blades.

As the engine starts, we want the prop assembly to begin spinning:

  [Child 28 Path 1]
link = 0
num_anim = 1

[Child 28 Path 1 Anim 1]
type = rotate
time = 1.0
rotate = 360, 0, 0
origin = 0, 0, 0

Now the prop will spin (360 degrees) with the engine revolutions. At a certain RPM, we want the solid prop model to hand off to an alpha-layered prop disc. Here's how we do it:

  [Child 28 Path 2]
link = 202
num_anim = 1

Link #202 tells the game engine to tie this anim path to the propeller RPM status. Now we use a geometry line to specify a different model to sub in for our original 3D object (the bladed prop):

  [Child 28 Path 2 Anim 1]
type = geometry
time = 0.25
geometry = /tr/planes/_shared/a6m_prop_disk.lwo

On the geometry anim, we have set the time to 0.25. In this case, since we are linking to engine RPMs, this can be interpreted as: "Swap parts when engine RPM reaches 25% of maximum."

For the rotation animation, note that the link is set to 0, the standard FM tie-in. Also, the angle of rotation is set to the full 360 degrees.

To finish off our animation, we need to add the prop hub, and apply the rotation animation to it. The hub doesn't need to swap out, since we'll always use the same model.

  [Child 29]
#Prop hub
name = Engine
geometry = a6m_prop_hub_mitsu.lwo
offset = 0, -0.025, 0
rotation = 20, 0, 0
num_path = 1

[Child 29 Path 1]
link = 0
num_anim = 1

[Child 29 Path 1 Anim 1]
type = rotate
time = 1.0
rotate = 360, 0, 0
origin = 0, 0, 0

You could even do the props singly, and set them to show pitch adjustments, using link #204, but we'll leave that for you to experiment with on your own.