Targetware: 3D Dev Guide
Using Shared Instruments
The graphics for all instruments are kept within the /planes/_instruments/ directory. We are currently building a library of instrument graphics that anyone will be able to use. If you are not a stickler about what your instruments look like, and just want functionality, you can populate your cockpit with a full set of instruments without doing any additional graphics work. If you are lucky, all the instruments you need in your plane will have already been done for you. Here's how to build cockpit instrumentation for your plane using pre-built, shared instruments:
1. Research Your Cockpit
Find out what type of instruments you need. Typically, you'll want at least an altimeter, air speed indicator, artificial horizon, compass, vertical speed indicator (climb), and tachometer.
2. Pick a Pre-Built Instrument
Open the /planes/_instruments/ folder and search for instrument .anm files of the type that you need. Instruments are organized by the following scheme:
|
|
service/country of manufacture _ type of instrument _ model, mark, other distinguishing info
|
If, for example, we are looking for an airspeed indicator, we would be interested in these instruments:
|
|
ija_airspeed_t98.anm
ijn_airspeed_m3kai1.anm
us_airspeed_mphf5.anm
|
You'll see a bunch of other files in there that end in things like .x, .lwo, .3ds, and .tga. Those are the actual graphics that make up the instrument, but we can ignore them for now.
Let's say we are building a Japanese Kikka jet, so we'll take the Japanese Navy Model 3 Kai 1 Airspeed Indicator, ijn_airspeed_m3kai1.anm.
3. Link to the Instrument from your Cockpit .ANM file
Let's add the instrument to your airplane. Open up your cockpit .anm file, and augment the num_children line by one. Now make a new child entry, as follows:
|
|
[Child 26]
#air speed indicator
name = Wing Tip Left
offset = 0, 0, 0
rotation = 0, 0, 0
animation = /tr/planes/_instruments/ijn_airspeed_m3kai1.anm
|
Note the format of this child object, which instead of specifying paths and anims within it, simply links to an already complete .anm file within the instruments folder. Save the cockpit .anm, and go ahead and test it in game to make sure it loads without an error. If there is an error, check the animation link path. You'll notice that even without an error, you probably don't see anything in the cockpit. Don't worry, that's only because we haven't set the offset correctly for your airplane.
4. Determine the Correct Orientation for your Cockpit
When we added the link in the last step, we left the initial offset and rotation numbers at 0, 0, 0. So the instrument is actually drawing in the cockpit, but it's probably facing the wrong way, and it's positioned on the origin point of the cockpit, not on the instrument panel. Our next step is to get the instrument oriented correctly for your airplane.
All shared instrument use the same arbitrary 3D orientation. Since there is no agreement between 3D applications on what the default orientation of a 3D model is, there is a good chance the orientation of the shared instruments won't match your cockpit. Don't worry, this is very easy to work with. You just have to figure out the right initial rotation once, then you can use that with all the instruments, for all your planes. There might be a scientific way of discovering it, but experimenting with 90 degree chunks should get you there fairly quickly. Change it, update it and check it. Repeat until you get the right rotation. Remember, you just need to do this once, ever.
We have included a few simple and very large rectangle meshes in the /_instruments folder that might help you, as they are easier to see than the little instruments. Here are rotations for a few modeling programs:
- 3D Exploration VRML Conversion: 180, 0, -180
- LightWave: 0, 0, 0
- Cinema4D: -90, 0, -90 (via VRML export and 3D Exploration)
- AC3D: tbd
5. Determine the Correct Offset for Your Cockpit
The final step is to determine the correct location for the instrument within your cockpit. Open your cockpit model in your modeler. Hopefully, you already have a 2D texture applied to your instrument panel that shows the location of the various instruments. Find the airspeed indicator, and mark down the exact location of the center of the gauge. Measure from the point the needle rotates around. Write down this number on a pad of paper. Typically, it will be something like: 125mm left (X plane), 200mm up (Y plane), 600mm forward (Z plane). Locations must be relative to the point of origin of the cockpit.
Now go back to your cockpit .anm file, and plug your numbers into the offset line. The offset line is measure in meters, so using our numbers from above, we'd have an offset line that looked like this:
|
|
offset = -0.125, 0.200, 0.600
|
Save it, and run the game again. If you have left the game running in a window, you can use the ".update /modname/planes/myplane/myplane_pit.anm" buffer command. If the instrument doesn't show up, it's either the initial rotation isn't set correctly for your cockpit, or one or more of the offset numbers is positive when it should be negative, or vice versa. Edit the cockpit .anm, and try again until it shows up in the right place.
If it shows up in the cockpit, it should be working, so you're done!
|