Track Designer Tutorial Logo

 

THE .TRK FILE FORMAT

 The first, probably most important, step in creating a new track for Formula PC is to become familiar with the track file format (.TRK). Understanding the data that a track file contains and how Formula PC uses this data is the only way to truly comprehend what is necessary for a .TRK file to function correctly in the game.

The track files are stored in text format (intentionally) so that anyone can open them in a text editor (I recommend UltraEdit) to see exactly what they're made of. Some editors (namely Tony Crider, the most prolific track designer to date) even modify parts of the raw data when, in certain circumstances, it's the easiest way to "tweak" the track to their liking.

While it isn't 100% necessary to undestand track files to create new circuits, having a grasp on the .TRK format is the only way to really master the art of Formula PC track designing.

THE .TRK HEADER
Here's a look at a raw track file:

Each .TRK has a built-in header that describes all that data that comprises the file:

Here is a sample of the data that corresponds to each item in the header:

;Formula PC Track file - Format 2.0
;Following is the structure of the file:
;Track Name
;Track Description
;Track Location
;Track Version
;Track Build Date
;Track Build Time
;Track Author Name
;Track Designer Version
;Weather Info
;     Rainy (Max)
;     Changeable (Max)
;Start Positions
;     Location (20 entries)




;Lane Position (string)
;     Space(x).Center X coord
;     Space(x).Center Y coord
;     Space(x).Rotation
;     Space(x).Scale (Length)
;     Space(x).Symbol
;     Space(x).Lane Position
;     Space(x).Nxt(0-1) (Left/Right)
;     Space(x).Adj(0-3)
;     Space(x).Segment
;     Space(x).Gap-Part
;Corners
;     Name
;     Stops
;     Long
;     Short
;     Vtx(0).X
;     Vtx(0).Y
;DrawArea Backcolor
;Background Polygons
;     Detail
;     Color(0-1) (Fillcolor-Outline)
;     NumVtx
;          Vtxs()... (Repeated for every vertex in polygon)



"Tutorial Track"
"Track Designer Tutorial"
"Tutorial Location"
2.0
04/18/2001
3:31:40 PM
"ONYX"
1.4.3

7
12
Start Positions
 
63
 2054
 61
 2052

(etc. etc. etc...) (Repeated for all 20 possible Starting Grid Locations))
Left
-99.77625     -778.7175     0    1    50   0   -1   1001    -1   1000    -1     -1    0    
0
100.2238      -778.7175     0    1    0     1    -1   1002    -1   1001    -1     -1    0    
0
300.2238      -778.7175     0    1    0     2    -1   1003    -1   1002    -1     -1    0    
0
500.2238      -778.7175     0    1    0     3    -1   1004    -1   1003    -1     -1    0    
0
700.2238      -778.7175     0    1    0     4    -1   1005    -1   1004    -1     -1    0    
0
900.2236      -778.7175     0    1    0     5    -1   1006    -1   1005    -1     -1    0    
0
1100.224      -778.7175     0    1    0     6    -1   1007    -1   1006    -1     -1    0    
0
1300.224      -778.7175     0    1    0     7    -1   1008    -1   1007    -1     -1    0    
0
1500.224      -778.7175     0    1    0     8    -1   1009    -1   1008    -1     -1    0    
0
(etc. etc. etc...) (Repeated for every Lane and Space)
Corners
"First Corner"
1             14            8            2799.222      -598.3333
"Second Corner"
 1             14            8            -3071.111     640
(etc. etc. etc...... (Repeated for Corner on the track)

Backcolor 2066198
Background Polygons
 2             10461087      10461087      23
2100          -879
2357          -817
2551          -692
 (etc. etc. etc...)... (Repeated for every vertex in every polygon)

 

Now let's take a look at each section of the .TRK file so that we can make sense out of all those numbers above.

 

TRACK INFORMATION
The start of the data area contains descriptive information about the track. This is mostly used by the Track Info dialog of Formula PC, so if you want to see it, just open a new game in Formula PC, then click on the Track Info menu or toolbar button.

Track Name = "Tutorial Track"
Track Description = "Track Designer Tutorial"
Track Location = "Tutorial Location"
Track Version = 1.0
Track Build Date = 03/14/2001
Track Build Time = 9:35:25 PM
Track Author Name = "ONYX"
Track Designer Version = 1.3.9

The track version information is also used for verification purposes, to ensure that two remote players are using the same track file version in their game, otherwise some unexpected things might occur.

 

WEATHER DATA
Next is weather information. This is used to determine the ranges for rolls which affect the weather during the game.
Rainy (Max) = 7
Changeable (Max) = 12

The range for Rainy weather is always 1 to the "Rainy (Max)" value read from the file.
The range for Changeable weather is always the "Rainy (Max)" + 1 to the "Changeable (Max)" value that is read from the file.
Sunny weather is the "Changeable (Max)" + 1 to 20.
So you only need to save 2 values for the game to figure out all the correct weather ranges.

 

START POSITIONS
Next are the entries for Starting Grid Positions.
Start Positions
 
63
 2054
 61
 2052
These are the locations of up to 20 starting grid positions included in the file. Typical Formula De tracks only include starting grid positions for 10 cars, but many players requested the ability to play with more cars. Tracks have been modified to include these extra grid spaces, and this value allows Formula PC to determine how many players can be supported by the .TRK file. If a starting grid position is not used, it's value will be set to -1.
In our example we see that pole position is on lane 0, space 63. The second grid position is on lane 2, space 54, etc. etc. etc.

 

LANE AND SPACE DATA
Next are rows and rows of lane/space data. This is probably the most important aspect of the track file.

Each track is built of Lanes. Usually there are 5 lanes to every circuit.
Left lane
Middle lane
Right lane
Pit lane
Garages

There can be 6 lanes, but I have yet to build a track with them, the ability was included for the future circuits (Like Indianapolis).

In the event that there are 6 lanes (4 track lanes, plus the Pit lane and Garages) then the 2 middle lanes will be
Mid-Left
Mid-Right

The order of lanes is always left to right (oriented to the track's direction of travel), regardless of which side the Pit lane is on, or which side of the Pit lane the Garages are on. You don't have to worry about this order, the Track Designer will set it automatically the first time you save the file. The order is important, because it is how FPC knows which direction to move the cars when they change lanes. Moves to the left are always to a lower-numbered lane and moves to the right are always to a higher-numbered lane.

There can be 2 middle lanes, but I have yet to build a track with them, the ability was included for the future, when people want to create ovals (such as Indianapolis).

Each lane is made up of spaces, the spaces being the spot where the cars land during moves.
Each space holds data that is critical for the game to know how it interacts with surrounding spaces.

If you look at a typical space entry from a .TRK file, here's what you see:

2305.417

-651.3515

0

1

28

13.4

-1

2014

4014

4013

2013

-1

1

0

X coord

Y coord

Rotation

Scale
(Length)

Symbol

Lane
Position

Next(0)

Next(1)

Adjacent(0)

Adjacent(1)

Adjacent(2)

Adjacent(3)

Segment

Gap-Part

(This space is from the middle lane of the Tutorial Track we will be building. You can easily tell what lane you're looking at when you open .TRK files in a text editor because each lane section is labeled with a line reading "Pit", "Garage", "Inside", etc.)
The nice thing about the formatting of the file is that each line of information depicts a single space of the track, so as you scroll down the file you can see how each space compares to the next

Okay, so we see what each item of space data stands for... but what do all those number and labels actually mean?!?!

Center X coord = 2305.417
This is the X coordinate of the space's center, where it will be drawn on the screen. All the points of the space are calculated automatically by Formula PC from this center location. (When combined with the Y coordinate that follows)

Center Y coord = -651.3515
This is the Y coordinate of the space's center, where it will be drawn on the screen. All the points of the space are calculated automatically by Formula PC from this center location. (When combined with the Y coordinate above)

Rotation = 0
This is the angle that the space is rotated around the center point explained above. Rotating each space is how the track is given curves. This will make more sense as we go on. Since this space has a rotation of 0, that means it is lying horizontal, pointing to the right of the screen.
(See example)

Space 0º Rotation Example

Scale (Length) = 1
Spaces can be longer or shorter, depending on where they are on the track and what is necessary for them to "fit in". Take a look at any Formula De track and you'll see how spaces differ in length, depending on their location. This is especially apparent when comparing spaces on the inside/outside of corners.

Symbol = 28
This is the symbol that will appear on the space (Start grid, corner arrow, finish line, etc).

Space Symbol ComboBox


You won't need to know these raw values since the track designer saves a number which represents the familiar name, but in case you're curious:

0 = none (standard space)
25 = arrow, single, heavy (leading into corner)
26 = arrow, single, light (corner)
27 = arrow, double, one forward, one to the left (corner)
28 = arrow, double, one forward, one to the right (corner)
30 = pit lane paint, Team 1 Color
31 = pit lane paint, Team 2 Color
32 = pit lane paint, Team 3 Color
33 = pit lane paint, Team 4 Color
34 = pit lane paint, Team 5 Color
35 = pit lane paint, Team 6 Color
36 = pit lane paint, Team 7 Color
37 = pit lane paint, Team 8 Color
38 = pit lane paint, Team 9 Color
39 = pit lane paint, Team 10 Color

40 = pit garage, Team 1 Color
41 = pit garage, Team 2 Color
42 = pit garage, Team 3 Color
43 = pit garage, Team 4 Color
44 = pit garage, Team 5 Color
45 = pit garage, Team 6 Color
46 = pit garage, Team 7 Color
47 = pit garage, Team 8 Color
48 = pit garage, Team 9 Color
49 = pit garage, Team 10 Color
50 = Finish line across center of space
51 = Finish line across left side of space
52 = Finish line across right side of space


So the space we're looking at has a double arrow, one straight and one to the right, which means it is part of a corner (since those are the only spaces that have double arrows on them).

The space we're looking at might look something like this:

 

Space with Arrows Straight and Right


Lane Position = 13.4
Lane Position is
very important to gameplay, but perhaps a bit difficult to understand. Put simply, Lane Position determines how far along the track your car has traveled.
Now, you could just count spaces, which is fine for straights, but if you look at a typical corner you'll notice that there are more spaces on the outside lane than on the inside, so the Position value needs to be adjusted to compensate for the longer circumference on the outside of the curve.

Space Position Values

Just because a car has traveled more spaces doesn't necessarily mean it is in the lead. This is where Lane Position comes into play, it is what Formula PC uses to determine the order that the cars are in.

Nxt(0-1) (Left/Right) (Two Values) = -1 and 2014
Nxt refers to "Next" spaces. This tells Formula PC what spaces a car can move into if it is sitting on this space. These moves are, of course, modified by traffic, rules, etc. but the Next values in the track file are for the one or two spaces that a car can move into by default.

The first "Next" refers to the space (if any) on the left side that is a valid next move and the second refers to the space (if any) on the right that is a valid next move. Not all spaces will have valid "Next" moves, Formula PC automatically assumes the next space in the same lane is a valid "Next" move, so we don't need to include it in the .TRK file, "Next" values only pertain to next moves in other lanes. Often there are corner arrows which limit a car's ability to change lanes, not to mention, the outside lane will have no "Next-Left" values, cause that would take you off of the track!

 

Now is probably a good time to explain exactly what the Next (and Adjacent, we'll get to them next... hehe.. no pun intended) numbers mean.
A value of -1 means that there is no "Next" move available. So if we look back at our example space:

Next(0-1) (Left/Right) (Two Values) = -1 and 2014

We see that there is no valid "Next" move to the left but there is a valid move to the right. (This would make sense, remember, the space's symbol was a double arrow right, meaning the car can only go straight or to the lane on the right).

The value to the right is a little more complicated. 2014. If you remember, I said that tracks are made up of lanes, usually 5 to a circuit. This is where the number 2014 comes from. It means that the "Next" space to the right of this one is Lane 2, Space 14, hence 2014. (Since we know our example space is from the middle lane, we could guess that its number is probably 3013 or something near that, since it would be close to 2014).

Adj(0-3) (Four Values) = 4014   4013   2013   -1
Adj stands for "Adjacent". This is referring to all spaces that are next to our example. This is important, because it is how Formula PC determines possible collisions. If two cars are in spaces that have been labeled as "Adjacent" then that means the two cars in them are in danger of colliding. Again, Formula PC can't just assume that since two spaces are numerically adjacent that they are actually adjacent on the track. i.e.: 2013, 3013, 4013, the 13'th space of each lane... you would think they were side-by-side, but after you go through one corner, this is no longer true.

Like "Next" spaces, Formula PC automatically assumes that the previous and next space on the same lane are adjacent to the one being checked, and it also assumes that any spaces tagged as "Next" moves are adjacent (after all, if you can move there, it must be connected to your current space) but the .TRK file must store which spaces in other lanes are adjacent if they aren't "Next" moves.

The maximum number of adjacent spaces is 4. I checked quite a few tracks and could never find a situation where more that 4 spaces (not including the two on the same lane, or "Next" moves) were adjacent to any one.

The "Adjacent" spaces stored in the file are not in any order and there is no limit on which lane they are in. In the middle lane of a straight, spaces will have 4 "Adjacent" spaces, 2 from the left lane and 2 from the right.

Straight Next-Adjacent Tag Diagram

 

 

But when you get into corners you often have situations where there is only one adjacent space on one side and 3 on the other.

 

Corner Next-Adjacent Tag Diagram

Segment = 1
Segments allow Formula PC to determine where on the track a car is. Each straight is a segment and each corner is a segment. These segments start at 0 (the main straight with the Starting Grid and Finish Line) and are numbered increasingly as the track progresses. Corner #1 is segment 1, then the following straight is segment 2, the next corner is segment 3, the following straight is segment 4 and so on and so on.

Segments are how Formula PC tells whether a car is in a straight (even-numbered segments) or in a corner (odd-numbered segments). By checking the segment a car was in at the beginning of a move, then checking it as the move progresses, Formula PC can determine when corners have been entered, exited or stopped in. This allows the game to activate rules for rolls, overshoots, etc. at the appropriate time.

Our example space comes from segment 1, which means it is from the first corner.

Gap-Part = 0
Gap-Part is a bit difficult to explain and we won't be using it in our example track, but here's a quick rundown.
If you look at certain tracks like Suzuka and Indianapolis you see that they possess some track features that are not standard. Suzuka has the overpass and Indianapolis (if you're using the infield circuit) goes from 3 lanes to 4 and back to 3 again. To deal with these special areas, Formula PC needs special information, this information is known as the Gap-Part tag (Gap or Partial lane).

There are 5 different types of Gap-Part tags:

0 = Regular space.
It is connected to the previous and following spaces in a normal manner.

Gap-Part 0

1 = Gap Start Space.
This is one of two spaces used to create an "underpass". The space just before the gap uses this tag, which causes a dark "gap" space to be drawn. This allows Formula PC to create cross-over sections, and informs the game engine not to use the "gap" space during car movement.

2 = Gap End Space.
This is the second tag used to create an "underpass". It allows Formula PC to complete the "gap".

 Gap-Part 1 and 2

3 = Partial Lane Start Space.
When a lane exists that does not run the full length of the track, its start and end spaces need to be tagged so that Formula PC knows not to allow a move from the last space of the lane back to the first. On normal lanes the finish line is generally the first space of the lane. When a car reaches the last space of the lane, Formula PC increments the player's lap count and places the car back on the first space. This is what is known as "looping". But if you have a section where the track gets wider for just a short distance, you don't want cars "looping" on the "partial" lane. This tag allows Formula PC to start performing movement limitations that apply to a "partial" lane.

4 = Patial Lane End Space.
This tag allows Formula PC to limit car movement so that players must merge back onto the 3-lane track

Gap-Part 3 and 4

 

So let's review:
The X,Y, Rotation and Scale information isn't too important to us here, it's just so the game knows where to draw the space. But to understand how the .TRK file works it is important to understand the following:

By looking at the raw data for this space we have been able to determine that it is from the middle lane, it is a corner space with one arrow pointing forward and another to the right, its position is 13.4, it has only one valid "Next" move (in addition to the default move of straight forward) which is into the right lane, it has 3 "Adjacent" spaces (in addition to the default ones directly in front of and directly behind) 2 of these are in lane 4 (4013 and 4014) and 1 of them is in lane 2 (2013), the space is part of segment 1, which means it is a part of the first turn on the track, and lastly the gap-part value is 0 which means the space is just a normal space on a normal lane.

There's a good chance our example space is this one:

Example Space

 

CORNER DATA
Following the lane data is the Corner data.
Each corner entry contains 6 distinct pieces of information:
Name
Stops
Long
Short
Vtx(0).X
Vtx(0).Y

 Here's a typical corner entry:
"First Corner"
 2             13            7            2333          -883

Name = "First Corner"
This is the proper name of the corner. Examples would be "Casino" (from Monaco) or "Curva Parabolica" (from Monza)

Stops = 2
The number of required stops in the corner.

Long = 13
The longest path possible through the corner.

Short = 7
The shortest path possible through the corner.

Vtx(0).X = 2333
The X coordinate where the flag will be drawn on the screen.

Vtx(0).Y = -833
The Y coordinate where the flag will be drawn on the screen.

 

BACKGROUND COLOR
After all of the Corner data is the Background Color. This value sets the background color that is drawn behind the track.

Here is an example of a Background Color entry:
Backcolor
25600

 

BACKGROUND POLYGONS
The last part of a .TRK file are the Background Polygons.

The Track Designer includes tools for drawing objects around the track. These can be trees, water, roads, gravel traps, etc. They have no bearing on gameplay and are not required in any way, the simply serve as "eye candy", making the track look better. We will touch on the creation of Background Polygons at the end of this tutorial, but extensive instruction on the use of the polygon tools will be saved for a separate help document.

Each Background Polygon entry contains the following data:
Detail
Color(0-1) (Fillcolor-Outline)
NumVtx
Vtxs()...(Repeated for every vertex in polygon)

Here is a sample Background Polygon entry:
2             10461087      10461087      22
2405          -851
2665          -773
2830          -633
etc, etc...(Repeated for every vertex in polygon)

The sample polygon entry is made up of these components:
Detail = 2
This sets that level of Track Detail at which the polygon will appear. This allows you to set what polygons appear when the user changes the Track Detail Option in Formula PC.

Following is the list of detail levels and how they relate to the numeric data in the .TRK file:
2 - Medium Detail
3 - High Detail
4 - Very High Detail

Polygons can only be set to appear at Medium detail and above because Formula PC turns off polygon display at Track Detail levels "Low" and "Very Low".
Typically you'll want to set the polygon level according to how important the polygon is to the look of the circuit.

Color(0-1) (Fillcolor-Outline) = 10461087 and 10461087
These two numbers set the colors that are used to fill and outline the polygon.

NumVtx = 22
This is the number of vertices making up the polygon

Vtxs() = 2405 -851
Each vertex entry is made up of two values, one for the X coordinate and one for the Y coordinate. The number of lines following the NumVtx value should equal the NumVtx value. In this example there are 22 vertices in the polygon, so there are 22 lines, each with an X,Y value (they have been truncated to save space here).

 

This completes the data that comprises a Formula PC .TRK Track File. As stated before, it is not necessary to know or understand all of the data, but if you do have a clear picture of what the data is and how it is used, you're more than ready to start designing your own tracks... so let's go!

Return to the Contents page

 

CONTACT:
If you have any questions or comments, please feel free to contact me: formulaPC@malagraphixia.com

 

Formula PC ©2000-2001 ONYX (J Boen) This page and all items pertaining to Formula PC
are in no way related to or endorsed by EuroGames, the makers of Formula Dé.