Targetware: 3D Dev Guide
Coding Moving Parts
Almost home. Your goal in this step is to correctly place and orient the control surfaces, gears, and other moving parts of your plane. There are two techniques that can be used with moving parts. The easiest method is to leave the part in place when you export it, then simply specify a point of origin for it in your anm file. This method will not work with every part, however. See the section on Exporting Parts for details. The second technique is more involved and time consuming. You will want to become familiar with both techniques, to save you time down the road.
Moving Parts: Technique 1
This is a fairly painless task. Here are the steps we'll follow:
- Create a new child object for the moving part
- Set the origin point for the axis of rotation
- Specify how many degrees we want the part to rotate, and/or how far we want it to move, in meters
Let's say we are working the Beaufighter, which has a rudder which hinges around an axis 8.19 meters aft of the model's point of origin. Since the rudder axis is 90 degrees perpendicular to the ground, we don't need to rotate or move the rudder part before exporting. We have left it in place, and saved it as a separate object, in step 2.62 above. Here is the first part of our child object:
|
|
[Child 14]
name = rudder
geometry = beau_ext_rudder.lwo
offset = 0,0,0
rotation = 0,0,0
num_path = 1
|
Note that the name "rudder" matches the name for the rudder section given in the .acm file for the Beaufighter. If it didn't match, the part would never be called on to move. Also, note that offset and initial rotation are still "0,0,0", since we left this part in place before exporting it.
Now we set up the animation that will control movement of the rudder:
|
|
[Child 14 Path 1]
link = 0
auto_time = 0
num_anim = 3
[Child 14 Path 1 Anim 1]
type = rotate
time = 0.0
rotate = 0, 0, 28
origin = 0, 0, 8.19
[Child 14 Path 1 Anim 2]
type = rotate
time = 0.5
rotate = 0, 0, 0
origin = 0, 0, 8.19
[Child 14 Path 1 Anim 3]
type = rotate
time = 1.0
rotate = 0, 0, -28
origin = 0, 0, 8.19
|
Since it's a rudder, it needs 3 anim sections, one each for full left, neutral, and full right. In the case of the Beaufighter, full deflection is 28 degrees in either direction. Note that the "origin = " line means that all we had to do was tell the engine that the axis point for the rudder was 8.19 meters aft of the plane's origin point.
Moving Parts: Technique 2 - Rotated Parts
Be prepared: this can be a frustrating and time-consuming task. Here are the steps we'll follow:
- Create a new child object for the moving part
- Fill in the offset numbers for the part
- Set the initial rotation for the part
- Specify how many degrees we want the part to rotate, and/or how far we want it to move, in meters
The first step is easy: create a new child object for each moving part, just as you did for the non-moving parts in Step 4. When you're finished, you should have a long list of child objects. If you tried running the game, you probably wouldn't see your moving parts.
Create the child object as we did above for the Beaufighter rudder, but this time, pay particular attention to the offset and rotation numbers. If we leave offset at 0,0,0, our part will probably be buried in the middle of the fuselage somewhere, since we moved it to 0, 0, 0 before saving. Now we will move the parts to the right location, using the notes we took earlier, when we exported the part. Enter the distance in meters from the point of origin to the correct location of each object. For example, for our Zero's aileron, we have the following code:
|
|
[Child 4]
name = Left Aileron
geometry = a6m2_ail_l.lwo
offset = -2.29,-0.280,1.10
rotation = -6.15,0,-7.4
num_path = 1
|
This tells the game to place the aileron 2.29 meters to the left of center, 28 cm down from the CoG, and 1.1 meters behind the origin point.
If you have trouble getting these numbers right, you can actually edit them on the fly if you set the Targetware app to open in 'window mode'. Keep it open, edit the text file, save the changes, and then reload the plane by selecting the scenario again. It can also help to use your modeler in vertex/points mode, select the point where the corner of your object should go, and use the location numbers the modeler gives you. You should be able to plop them in and then tweak them by checking the view in game.
Next step: set the initial rotation angles. Here is the left aileron again:
These numbers correspond to the number of degrees in each plane that we had to rotate the control surface to make it lie flat along the axis we want to rotate it about. For the rudder, our initial angle of rotation would be 0,0,0, since no rotation was necessary.
NOTE: initial angle of rotation is not related to the actual movement of the part. This rotation angle is merely used to align the part correctly with the rest of the plane.
Once you have filled in all the rotation angles for your parts, try them out in the game. Everything should line up correctly, and be at the right angle. This is actually the trickiest part of building the animation file. Keep tweaking until you get it just right.
Illustration 2.66_1: Everything in place and lined up
The last step is to animate the actual movement of the part. Here is our Zero aileron again:
|
|
[Child 4 Path 1]
link = 0
auto_time = 0
num_anim = 3
[Child 4 Path 1 Anim 1]
type = rotate
time = 0.0
rotate = 0, -14, 0
origin = 0, 0, 0
[Child 4 Path 1 Anim 2]
type = rotate
time = 0.5
rotate = 0, 0, 0
origin = 0, 0, 0
[Child 4 Path 1 Anim 3]
type = rotate
time = 1.0
rotate = 0, 14, 0
origin = 0, 0, 0
|
Test it out in game again, move the controls around to see the part move. If the part is moving correctly, then congratulations! If you've made it this far, you are 95% done with your model. The hard part is behind you. Everything should display correctly game at this point, it just won't move. That's our next step, setting up the animation. Don't worry, it's easy compared to what you just did!
|