STEP 3 - EDIT the SOURCE CODE
STEP 3
EDIT the SOURCE CODE
Edit myairplane.sca to create the animated parts, texture swapping and/or the application of bullet holes.

"Wait a second! My model is already animated. Why do I have to create animated parts?"

After generating a simple animated model, I used the SCASM compiler to create a .bgl file from the object source file (.sca) without changing a single character. I copied the resulting .bgl code and pasted it back into the model file.

After loading the model into CFS2, I was delighted to see the exact model I had created with FSDS, but nothing was animated ... no ailerons, no flaps, no elevator, no rudder ... nothing moved!

NOTE
The FSDS-generated object source code file (.sca) contains only the SCASM code needed to render the physical model, which it considers to be a piece of scenery. The only way to create animated parts using the object source code is to do it with the SCASM language.

Since you have to work with the FSDS-generated object source code, you should get familiar with the structure of an object source file.

The object source code produced by FSDS code follows a kind of "template" for rendering each model part. In the following SCASM code examples, the items to target for editing are highlighted in red.

For breaking parts without the Pre-Process Condition "Parts Visible" ...

; Part: name
:PartName
Transform_Mat(
   X    Z    Y        ;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] [texture] )        ;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 ...

For non-breaking parts with the Pre-Process Condition "Parts Visible" ...

; 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(
   X    Z    Y        ;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] [texture] )        ;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 ...

Before you start tinkering, it helps to have a plan of attack and an understanding of what you're going to do ... so let's get to it.

Open your object source file myairplane.sca in your text editor and take a close look at the code.

 Clean up your labels. Rename them if it helps make things more clear.

 Add carriage returns after every Return command to help break up the code and isolate parts.

 Add comments that briefly explain what's being done. Any line beginning with a semi-colon is treated as a comment and is disregarded when the SCA file is compiled.

 Which parts are going to have damage textures applied and under what conditions? You'll need to apply a pre-process condition to every break away part to test part visibility. This is the event trigger you will use to swap part textures.

 If you are using the polygon method to apply bullet holes, which parts are going to display the holes? Make sure each bullet hole polygon has the correct parent part so that any transformation of the parent applies to the bullet hole polygon as well.

You'll have to apply a visibility test to every bullet hole polygon on a breaking part to decide whether or not to render the decal for that bullet hole. If you don't and you're going to use texture swapping, you could end up with bullet holes "hanging in space."

 Edit the object source code in stages. Make your changes to only one part or one part group at a time. Don't try to edit the entire file in a single session.

The changes you make to myairplane.sca may or may not work the first time. The odds are better than even they won't. That's why I recommend you edit the code in stages, one part at a time. It's much easier to find your mistakes.

For example, work only on the right wingtip. Finish steps 4 - 7 and test your changes. If it works as it should, copy the edited code and save it in myairplane.sca. Come back to step 3 and work on another part or part group.

DESIGN

TIP
PROTECT YOUR WORK! Open the source code file you created in STEP 2 (myairplane.sca) in your text editor. Save it again with the name myairplaneORG.sca. This will always be your original code file. Save it again as myairplaneSCA.sca. This is the file you will edit.

Once you get the SCASM code to work the way it should, just copy the code from that part of myairplaneSCA.sca and paste it into the same place in myairplane.sca. This way, you'll always have an .sca file containing code you know will work.

Now it's on to STEP 4, where you use the SCASM Compiler to convert your object source code into a scenery object file (.bgl).

STEP 2 The Process STEP 4