Cockpit Editing Tutorial

Cockpit Files
First thing you've got is the STRU chunk - this is info about what mesh is to be used for the cockpit. Naturally, the meshes are stored in the \mesh folder, and are perfectly editable. The name of the mesh is the very first line of the STRU chunk. I don't know what the rest of the chunk does, but I've never had any reason to bother with it. Presumably, some of the numbers may indicate the position relative to the player that the strut mesh should be placed at, but this is something I have not tested.

Next comes the PTUR form. This form contains info about turrets. I assume that it links certain turrets to certain views. The form contains 1 to 3 chunks (if there are no turrets, the form doesn't exist) - LTUR, RTUR, and BTUR - left view, right view, and rear view. To each one, you bind a turret by entering a number (for example, 0 would be the first turret you entered in the ship file; if you have five turrets altogether, 4 would be the last one). Note, however, that this is something I've never tried, so I may be completely wrong.

The next chunk is MESG. I can't find anything in my notes about it, but from what I can remember, this chunk defines the coordinates of where text messages show up on the screen. The chunk contains four numbers - X, Y, X2, and Y2. X and Y define the top left corner, X2 and Y2 define the bottom right. Remember that text will only wrap to the next line when it reaches X2. I don't know what happens if you have a text longer than the amount of space you have for it. From various other experiences, I'd assume the game will crash.

This is followed by the SCAL chunk. What this is, I never bothered to find out. What I do know is that there didn't seem to be any need to touch it for the high-res patch, so you probably won't need to bother with it either.

No more individual chunks from this point onwards - all the other cockpit components have their own forms. A lot of the info stored inside these forms remains black magic, but I was able to prepare the high-res cockpits without delving into these things, so I doubt this will be a problem.

First up, a list of all the forms, and what they contain:
NAVP - a text-based form, shows nav point information.
BACK - the weird blue arc-like things that show up in 3Dfx. For the high-res patch, we actually moved them beyond the edge of the screen, because they couldn't be properly adapted to hi-res without making new images, which we couldn't be bothered with.
SCFG - the fore/aft shield adjusting component.
TARO - target display (shields/armour).
DAMV - a display of your own shields and armour.
RTCL - shooting reticle.
SETS - set speed info.
CURS - current speed info.
MTMR - mission timer.
TARG - target viewcam.
DAMG - damage control (list of damaged components). Text-based, and only contains a single chunk.
OCOM - comm options, also text-based.
PWRD - power distribution diagram.
RADA - radar.
GUNP - gun capacitator.
AFBN - afterburner fuel.
ICOM - comm visuals.
GNSI - what gun(s) you have selected.
MSSI - what missile(s) you have selected.
AUTO - autopilot light.
LOCK - missile lock warning. Was a bit of a nuisance with the hi-res patch.
EJCT - eject warning.

What's missing? Decoys. They do not seem to have their own form. Eder has discovered that decoys are included in the MSSI form - the second DATA chunk. Although I have not tried this, it seems logical because this chunk uses an image 14 by 14 pixels in size, and only decoys use an image that small.

And now, how do we change their positions?

Each component form (except MESG) has a VIEW chunk. This chunk contains four coordinates - you guessed it, top left and bottom right corners. In most cases, this is the only thing you need to edit. For text-based components, don't forget about the bottom right corner. For all others, however, the bottom right corner seems irrelevant. Even if there's only two pixels of space between the top left and bottom right corners, the game WILL display the entire image.

But this is where things get complicated. For certain components, the VIEW chunk contains the following coordinates - 0,0,640,480. A component filling up the entire screen? That would be... strange. But this isn't the case. You will generally see such coordinates in components which consist of more than one image. The best example of what is going on is the LOCK form:

----------------------------------------------------------------------------

FORM "LOCK"
{
CHUNK "VIEW"
{
long 0
long 0
long 640
long 480
}
FORM "QUAD"
{
FORM "HARD"
{
CHUNK "NUMR"
{
long 2
}
CHUNK "DATA"
{
long 903
float 25.0
float 170.0
float 84.0
float 29.0
float 0.06
float 0.43
float 0.38
float 0.54
}
CHUNK "DATA"
{
long 903
float 531.0
float 170.0
float 84.0
float 29.0
long 0
float 0.43
float 0.33
float 0.54
}
}
FORM "SOFT"
{
CHUNK "NUMR"
{
long 2
}
CHUNK "DATA"
{
long 953
float 25.0
float 170.0
float 84.0
float 29.0
float 0.06
float 0.43
float 0.38
float 0.54
}
CHUNK "DATA"
{
long 953
float 531.0
float 170.0
float 84.0
float 29.0
float 0.00
float 0.43
float 0.33
float 0.54
}
}
}
}

----------------------------------------------------------------------------


As you no doubt remember from the game, the LOCK component consists of two images, which show up on either side of the screen when somebody's got a lock on you. So, the programmers defined the VIEW chunk as taking up the entire screen, and went on to specify more precise positions inside the DATA chunks for each image.
Note that, in what I posted above, there are four DATA chunks, two in the HARD form and two in the SOFT form, containing almost the exact same data, except for the first line, which, as you may have guessed, is the number of the MAT file. So, the two forms take the same-sized part from the same coordinates in two different images (903 and 953). What is going on? Apparently, the game has different versions of the images depending on which graphics mode is used.
There are three options - SOFT, which is the Direct3D mode. HARD, which is the software mode (apparently, the meanings of 'soft' and 'hard' are reversed in Origin-land). Finally, there is SHAR - you will only find this one in the BACK form that was mentioned earlier. SHAR is 3Dfx. If a form doesn't have a specific SHAR form (ie., almost always), it will default to using the SOFT form.
It is also worth noting that the two most commonly used images (903 and 953) are in fact hardcoded. What this means is that the image is read directly from the EXE, rather than from the MAT file (and, to make things more interesting, the MAT version of 903 is not quite identical to the EXE version of 903).This means that if you wish to replace the graphics for these components, you need to change the image references so that the game reads data from a MAT file which does not have a hardcoded copy. 

Anyway, let's take a closer look at a single DATA chunk:

----------------------------------------------------------------------------

CHUNK "DATA"
{
long 903
float 25.0
float 170.0
float 84.0
float 29.0
float 0.06
float 0.43
float 0.38
float 0.54
}

----------------------------------------------------------------------------

The next two floats are the coordinates of the top left corner of the image. These are not coordinates on a 640x480 screen (well, in this case they actually are) - they are offsets from the top left corner as defined in the VIEW chunk.
The next two numbers are the length and height of the image. I'm not sure if they are actually used by the game for anything, but they do coe in useful sometimes.
The last four numbers are interesting. These are the top left and bottom right corners of the area to be taken from the MAT file (since 903/953 contains graphics for several different components). However, instead of giving the coordinates in pixels, the programmers used percentage-based coordinates instead. Why they did so, I have no idea whatsoever.

Anyway, we're rapidly approaching the end of my knowledge. One thing that needs to be pointed out now is that some components are in sync with each other. An example of this is the GUNP, AFBN and RADA components. GUNP and AFBN components are positioned on either side of the RADA component. Of course, if you alter the graphics, this may no longer be the case.

 

Tutorial by Quarto