Targetware: 3D Dev Guide


Building Your Own Instruments

Let's say you are a realism hound, and you want exactly what was in your cockpit in the real thing, but having searched through the shared instruments folder, you found that no one has modeled the Japanese Army's Type 98 Altimeter. You will have to build it yourself. This section will show you how.

Guidelines

  • Save all instrument graphics (textures and meshes) in the shared instruments folder so that other planes will be able to re-use it.
     
  • Get the Z part of your offset in the anm to within 1 mm of the panel. If the instruments are further away than that, the dials won't line up right with the 2D panel texture because of perspective. They would look fine if the pilot viewed them from straight on, but the pilot views them at a 45 degree angle from above.
     
  • Whatever the backmost (furthest from pilot) segment of an instrument is, that part should be at 0.0 in the Z plane for all instruments. Having all instruments follow this RULE makes it a lot easier to place and move the instruments around in your anm files predictably, since you can then use the same Z offset for all instruments within a cockpit anm. Example of it done right: for a turn and slip indicator, the back of the white ball tube is at 0,0,0, the ball is at -0.5mm, the main instrument face is at -1.0mm, and the needle is at -1.5 mm.
     
  • Succeeding layers (needles, sandwich faces, etc) should be no more than 0.5 mm forward of the preceeding face. If they are further away, needles and other layers in the foreground will appear to be off-center when viewed in the cockpit, because of the top-down aspect angle. If layers are too close, you could run into a Z-buffer rendering problem on some cards.
     
  • Child order is important when building the instrument .anm file. It MUST go in order, objects furthest from pilot, to objects nearest to pilot. If you do a needle first, then the dial face, the alpha won't look right. For example, with a slip indicator, a typical instrument might have children in this order: slip tube background > slip ball > dial face > turn rate needle. The order of whole instruments within a cockpit .anm, vis a vis each other, doesn't matter.
     
  • Instruments should interact properly with the cockpit's instrument panel. Some instruments will be sunken into the panel, affixed from behind. On other planes, instruments are inserted from the front, and have obvious bezels showing. Our suggestion (TR people: this is a rule for you) is to draw all screw heads, shadows, bevels (for depressed instruments), and non-standard knobs, etc., onto the instrument panel of the airplane using 2D artwork. This is the best way to make the instruments blend into the panel, and not seem as if they are simply floating on it. This requires some extra work on the part of the 2D artist, but the results are definitely worth it.
     

Step-by-Step Instrument Construction

1. Prepare cockpit model.

Have a completed cockpit, with final or placeholder art for the instrument panel that shows the location and size of the instruments.

Cockpit with mockup instruments

2. Make 2D art for instrument face and needle.

Dial faces should be 128x128 pixels, 32 bit TGAs with an alpha layer. Use the alpha layer to cut out the circular (or other) shape of the dial from the background. You will be placing this 2D art only a 2-triangle polygon square, so all shape will be determined by the alpha layer. Needles should also be drawn with alpha layers, you should be able to fit multiple needles onto a 128x128 sheet. You can probably also just use the texture of needles that have already been drawn, check for x_needleset.tga files to see if any match the instrument you are looking for.

2D artwork for a Japanese Army Airspeed Indicator

3. Create a 3D shape for the instrument back face.

A simple 2 triangle polygon shape will suffice, since we are using the 2D alpha layer to establish the visible shape. Texture map your 2D art from step 2 to the 3D rectangle you just made. Make sure your object has the same orientation as all other shared instruments! Place a copy of your instrument up against your cockpit's instrument panel and scale it to match, noting the scale percentage (see section below on aircraft instrument sizes). Go back to your original, and scale it to match. You might also want to jot down the offsets at this point.

A dial face consisting of 2 triangles, mapped to your 2D artwork

4. Create a needle for the instrument.

Again, use a 2 triangles, and let the alpha layer on the needle artwork determine the exact shape of the needle. In most cases, you will want to place the needle so that the point about which is rotates is at 0,0.

A needle for the Airspeed Indicator. Note that we are using a special version of the TGA which shows the alpha cutouts, making it easier to texture map the needle mesh.

5. Establish Z plane offsets.

If the back face of the instrument will be the part of the instrument furthest from the pilot, place it so that it is even with X plane (at Z: 0.000). If it is not the furthermost part of the instrument, move it forward as appropriate. Each layer should be offset by .5mm in the Z plane, starting at 0, and building back towards the pilot. Center the X and Y aspect of the polygon on 0,0. If there is a point about which a needle or other instrument will rotate, that should be at 0,0. Note in the above illustrations that the instrument face is aligned exactly along the X axis. The next part of the instrument, the needle, is aligned 1/2 mm forwards of the back face.

6. Animate the instrument.

The next step is to create an .anm file that will move the needle in response to flight engine feedback. Looking at the list of animation links, we can see that we want link # 108, Indicated Airspeed. Looking at our instrument, we note that the top speed is 700 kph, which is reached after the needle goes through 660 degrees of clockwise motion (we measured this in our modeler, by placing the needle over the dial face and spinning it until it pointed at the "700" mark). Noting that link #108, IAS, goes from 0 km/h to 10,000 km/h, we come up with a time index of 0.0700 as the upper cap of this instrument. At time 0.0, we want the needle at 0 rotation, facing straight down. At time 0.0700, the plane will be at 700 km/h, and the needle will be rotated 660 degrees. Here is the code:

  #IJA Type 98 Airspeed Indicator
[Object]
geometry = /tr/planes/_instruments/ija_airspeed_t98.lwo
num_children = 1

[Child 1]
#IJA Type 98 Airspeed Indicator Needle
name = none
geometry = /tr/planes/_instruments/ija_airspeed_t98_n.lwo
num_path = 1

[Child 1 Path 1]
link = 108
num_anim = 2

[Child 1 Path 1 Anim 1]
type = rotate
time = 0.0050
rotate = -9, 0, 0
origin = 0, 0, 0

[Child 1 Path 1 Anim 2]
type = rotate
time = 0.0700
rotate = -660, 0, 0
origin = 0, 0, 0

If you look closely at the face of this instrument, you'll see it's not a linear readout. We'd have to add more anims to it, with various time indexes and rotation settings, to make it read accurately at any time but 0.0 and 0.0700. That is too long for this example, but you can open the actual .anm for this instrument if you want to see how it is done. You full .anm file is:

  /data/tr/planes/_instruments/ija_airspeed_98.anm.

7. Determine the Correct Offset and Initial Rotation for Your Cockpit.

See the previous section for instructions on determining the correction initial rotation and offset for your particular aircraft. Don't forget to link to your new instrument from your cockpit .anm file!

That's it. Fire up the flight sim and give it a try.

 

Instrument Example 1: Four Part Altimeter

Here is an example of a more complicated instrument. It has a back-face showing the altitude in hundreds of meters. Behind that, visible through a small window near the bottom of the dial face, is a wheel which shows the altitude in thousands of meters. It has two needles, one which reads hundreds of meters, one which reads thousands of meters. From this, we know we need 4 layers, and 4 parts. First create the dial face, and size it. Then create the wheel and needles. The wheel has to be legible at a small size, so it gets its own 128x128 texture sheet. The needles we take from our shared Japanese needle set. After creating the objects, align them so they are centered, left/right, up/down with the dial face. Then position them, from back to front, with 1/2mm between layers, as below:

4 part instrument, laid out in order of depth, 1.5mm to 0mm

Now we're ready to export the parts and build our .anm file for this instrument:

  #IJA Type 97 Altimeter
[Object]
geometry = /tr/planes/_instruments/ija_alt_t97.lwo
num_children = 3
num_path = 0

[Child 1]
#altimeter back wheel (1000s of meters)
name = none
geometry = /tr/planes/_instruments/ija_alt_t97_w.lwo
offset = 0,0,0
rotation = 0,0,0
num_path = 1

[Child 1 Path 1]
link = 111
num_anim = 1

[Child 1 Path 1 Anim 1]
type = rotate
time = 0.105
rotate = -315, 0, 0
#315 deg rotation = 10500 meters, which is time .105
origin = 0, 0, 0

[Child 2]
#altimeter short needle (1000s of meters)
name = none
geometry = /tr/planes/_instruments/ija_alt_t97_n2.lwo
offset = 0,0,0
rotation = 0,0,0
num_path = 1

[Child 2 Path 1]
link = 111
num_anim = 1

[Child 2 Path 1 Anim 1]
type = rotate
time = 1.0
rotate = -3600, 0, 0
#1 rotation = 10000 meters, max 100,000 meters at time 1.0
origin = 0, 0, 0

[Child 3]
#altimeter long needle (hundreds of meters)
name = none
geometry = /tr/planes/_instruments/ija_alt_t97_n1.lwo
offset = 0,0,0
rotation = 0,0,0
num_path = 1

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

[Child 3 Path 1 Anim 1]
type = rotate
time = 1.0
rotate = -36000, 0, 0
#1 rotation = 1000 meters, max 100,000 meters at time 1.0
origin = 0, 0, 0

 

Instrument Example 2: Switch

t.b.a

 

Instrument Example 3: Magnetic Compass

t.b.a