SCASM Animations

If you carefully examine the object source code file for an aircraft model, you'll notice a consistent pattern for part rendering, a pattern that applies to fixed and animated parts alike.

Parts created in FSDS without the Display Condition "Part Visible" produce the following pattern ...

; Part: name
:PartName
Transform_Mat(
       X        Z        Y        ;Floating point coordinates of part reference axis
1.000000    0.000000    0.000000
0.000000    1.000000    0.000000
0.000000    0.000000    1.000000
)
SetMaterial( [mat index] [texture index] )    ;Set part material and/or texture bitmap
DrawTriList( start    ;Draw part triangle polygons
v0 v1 v2
.. .. ..
vn1 vn2 vn3
)
TransformEnd    ;End of part transformation

Return    ;Finished with this part ... Return

Parts created in FSDS with the Display Condition "Part Visible," the pattern looks like this ...

; Part: name
:PartName
IfVarAnd( :ReturnLabel 90 8 )    ;Part visibility test
Jump( :GO_ON )    ;Part is visible

:ReturnLabel
Return    ;Part is not visible

:GO_ON
Transform_Mat(    ;Reorient part reference axis if needed
       X        Z        Y        ;Floating point coordinates of part reference axis
1.000000    0.000000    0.000000
0.000000    1.000000    0.000000
0.000000    0.000000    1.000000
)
SetMaterial( [mat index] [texture index] )    ;Set part material and/or texture bitmap
DrawTriList( start    ;Draw part triangle polygons
v0 v1 v2
.. .. ..
vn1 vn2 vn3
)
TransformEnd    ;End of part transformation

Return    ;Finished with this part ... Return

SCASM lets you access directly the animation-related parameters used in CFS2 that will tell you exactly where each part is in space at a given time.

Here are the animation-related parameters available for you to work with:

CFS2 Animation Parameters
OffsetAnimation Data
0x6ELeft aileron position
0x70Right aileron position
0x72Left flap position
0x74Right flap position
0x76Elevator deflection angle
0x78Rudder deflection angle
0x98Extension / retraction of left gear, including compression.
0x9CExtension / retraction of right gear, including compression.
0xA0Extension / retraction of center gear, including compression.
0xA4Engine 1 Prop position (angle).
0xA6Engine 1 RPM.
0xA8Engine 2 Prop position (angle).
0xAAEngine 2 RPM.
0xACEngine 3 Prop position (angle).
0xAEEngine 3 RPM.
0xB0Engine 3 Prop position (angle).
0xB2Engine 4 Prop position (angle).
0xB4Steer angle of center wheel.
0xB8If non-zero, model should check for crash with user aircraft. Set to non-zero for AI aircraft.
0xBAPercentage of left wing fold, e.g. CFS2 Corsair.
0xBEPercentage of left wing fold, e.g. CFS2 Corsair.
0xC2Cowl flap position for engine 1. Recommended you use cowl_flaps0.
0xC6Primary exit, door, or canopy percentage open.
0xCASecondary exit, door, or canopy percentage open.
0xCEPrimary exit, door, or canopy percentage open.
0xD2Secondary exit, door, or canopy percentage open.
0xD6Primary exit, door, or canopy percentage open.
0xDASecondary exit, door, or canopy percentage open.
0xDEPercentage tail hook is extended.
0xE2Percentage bomb bay is open.
0xEAPosition of center wheel rotation.
0xEEPosition of left wheel rotation.
0xF2Position of right wheel rotation.

NOTE
The above offsets may not reflect the actual values for your model! Be sure to check the content of your VarTable.txt file, which is located in your Abacus Design Studio folder.

Stock Animation

The key to modifying the object source code for stock animation is the SCASM command ...

TransformCall( :Labelname  delta_x  delta_y  delta_z  x_deg  xvar z_deg  zvar  y_deg  yvar )

To use the TransformCall( ... ) command, simply take the delta_x delta_y delta_z values directly from the Transform_Mat( ... ) command and use them as integers in the TransformCall( ... ) command.

For example, the FSDS-generated object code for the rudder in fxanimate.sca is,

Transform_Mat(
   0.000000    -14.935200    -226.466400
   1.000000    0.000000    0.000000
   0.000000    1.000000    0.000000
   0.000000    0.000000    1.000000
   )

The delta_x delta_y delta_z values are; 0 -15 -226.

In order to animate this rudder, we need to know the correct rudder position, or deflection angle. CFS2 carries this data in the variable at offset 0x78 (see above). Thus, the value for yvar is 0x78.

Since the rudder axis always remains parallel to its rotation axis, y-deg will remain 0.00000.

Now we have the final command line ...

TransformCall( :RudderAnim  0  -15  -226  0.00000  0x00  0.00000  0x00  0.00000  0x78 )

If the animated part has "child" parts, then the TransformCall ( ...) command has to be applied to each of those parts in turn using the same CFS2 parameter you applied to the primary "parent" part.

Put another way, if you are animating the rudder and it has eight "children," say eight bullet hole polygons, then you have to apply the TransformCall ( .. ) to each bullet hole polygon as well. The CFS2 parameter will remain the same in each case. Only the delta_x delta_y delta_z values will change to reflect the part axis location for each bullet hole polygon.

This is necessary so that each "child" part remains linked to its parent during animation and moves exactly in sync with the parent when the parent moves!

Keyframe Animation

The key to modifying the object source code for keyframe animation is the SCASM command ...

Animate( vinput_base  vinput  vtable_base  t_offset  xlat_x  xlat_z  xlat_y )
which animates objects using the keyframe data tables built into the model file.

NOTE
FSDS Pro version 2.33 automatically includes keyframe animation tables when generating the object source code file (.sca) for your model!

You can learn quite a bit about the animation process by examining examples of SCASM animations. The following animations are taken from the object source code file fxanimateSFX.sca created with FSDS Pro v2.33.

Ailerons
Flaps
Canopy
Landing Gear
Landing Gear Tires
Wheel Steering
Elevator
Rudder
Cowl Flaps
Propeller
Folding Wings
Tailhook
Bullet Hole

Each animation includes both the original and edited versions of the object source code for comparison.