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 |
|
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 |
|
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 |
Symbol |
Lane |
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 |
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 |
|
|
|
0 = none (standard space) |
40 = pit garage, Team 1 Color |
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:
|
Lane Position
= 13.4 |
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. |
|
|
|
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.
|
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. |
|
1 = Gap Start Space. 2 = Gap End Space. |
|
3 = Partial Lane Start Space. 4 = Patial Lane End Space. |
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: |
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!
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é.