TRK FILE LAYOUT v0.2.5.2 12/31/98 If you have any information that contradicts what is listed here please tell me at: jnvngn@aimhi.com ************ * Overview * ************ The TRK file contains information about the track layout necessary to run the simulation aspects (rather than the graphical aspects) of GPL. The main facets of information are - track geometry presence of walls, kerbs etc (for collision detection) track surface (for grip characteristics) The track is divided lengthwise into a number of sections. Each section is either straight or curved. A section has an associated set of walls and surfaces. The track has a number of lines drawn along it at fixed positions across the track. A height is recorded at the intersection of each line and section boundary. This together with the curvature information from the section produces the track layout. I have called these lines traces in this document. Header Sections Pointers Elevation Data Wall Data Section Data There are some 'magic' values used in some fields that appear to normally have a non-magic value. Such values seen so far are - 0x07070707 0x08080808 0x40000000 The following data layouts are specified in 4 byte words. ********** * Header * ********** 92 bytes long = 28 bytes in Header + 64 bytes in trace positions 0 ID 'KART' 1 Version 3000 for GPL 2 Track Length in 1/500 inches 3 Number of traces <= 16 4 Number of sections 5 Length of wall data in bytes 6 Length of section data in bytes Trace Positions --------------- There are always 16 trace positions recorded in the file. Any beyond the 'Number of traces' from the header are unused. Each trace position is a single word representing the offset from the nominal track centreline. Negative values are to the right, positive to the left. ******************** * Section Pointers * ******************** One word for each section, being the offset of that section within the section data. Since each section's data is 52 bytes long, these numbers are just n * 52 ****************** * Elevation Data * ****************** All lengths and heights are defined in 1/500 of an inch. Identical format to N2 trk elevation section. There is one record per trace per section. Each record is 32 bytes long, giving a total length of 32 * traces * sections 0 Zend curvature height at end of polygon 1 Zmid curvature height at end of midpint 2 Zslope slope, height value at end of polygon 3 Zref baseline height 4 Pend pitch (height/angle)at end of polygon Zend * 3 5 Pmid pitch (height/angle) at end of midpoint Zmid * 2 6 X Coordinate / Radius 7 Y Coordinate / null Value Observation Zend Height value at end from Zmid defines curvature from midpoint to end of #E line Z value is additive from midpoint height Zmid. Car not pitched, no effect on car physics. Zmid Height value at midpoint from Zref defines curvature from begin to midpoint of #E line Elevation value is NOT additive from the elevation values of the immediately preceeding polygon #S set. Car not pitched, no effect on car physics. Zslope Delta elevation from #Zref at the end of polygon Creates a slope where car is pitched. No physics effects on car. Zref Reference baseline elevation throughout polygon Pend Curvature and pitch of car at end of polygon Value is angle or elevation? Value is additive from the midpoint value defined in Pmid. Car appears to pitch to this value as it reaches the end. Unknown if it is a distance or an angle value? Value effects car physics. Pmid Curvature and pitch of car at midpoint Pend. See notes to Pend. Value not additive from previous values from different polygon. Word 6 --X coord of the start point of the #E line for straight section. --Radius distance #R to a point on the #E line, for curved section. Word 7 --Y coord of the start point of the #E line for straight section. --Apppears as 07070707h 117901063d for curved section often, but not always. Believed to be null. For a given trace, the start elevation of the next section is always the start elevation of this section plus Zend, Zmid and Zslope (allowing for rounding errors). ************* * Wall Data * ************* All lengths and heights are defined as 1/500 of an inch. This section contains wall data, but it also includes information that is unrelated to the walls. These records are referenced by the section data - each section has its own number of wall records. Each record is 32 bytes long. 0 From 1 To 2 Surface 3 Unknown1 (0,1,3,16,17,19) 4 Height 5 Absortbtion ??? (observed: 0-35,38-39,42,100,140,190) 6 Always zero 7 Always zero The from and to attributes are the lateral positions on the track at the start and end of the section respectively, thus describing a line. This line may or may not be a wall. It is also used as the right margin for an area of grip which extends leftwards to the next line. Some values for the surface are - Negative From is either inside of the track or from pit lane side of the track. Positive is either outside of the track or from opposite of pit lane side. All GPL tracks have pit lane inside of the track so I cannot be sure. Numbers Observed 1 Track apshalt 2 Hard surface (lower grip/non track) 3 Kerbs 4 Grass 5 Dirt 6 Gravel 7 (7 at Rouen section 50) 8 (as 2056 in wood fences at Glen and Ring) 9 (as 2057 at Spa And Zandy) 10 the furthest part of the track only on outside (a boundry) 11 (as 2059 at Watkins) 2048 is sometimes present as a base, which then makes it: 2048 + (surface number) It is always present when both [Unknown1] and [Height] have values not equal to 0. But I have seen it present when [Unknown2] was equal to 0. Unknown1 is either 0, 1, 3, 16, 17, or 19. Strange because it seems to appear at any time. This looks to be very miniscule, so I give up; of course if you know tell me though. :-) It looks as though 0 and 16 are the only important numbers though, just look at Mosport, Monza, and Nring. Although I wonder what it could be, a bump? We'll see. The height is the height of a wall (in 1/500 of an inch) if one is present. Absorbtion, formally -unknown2- appears to be related to absorbtion of the surface. I guess this basically fine tunes while the surface does gross measurements. This is still not for sure, but it very much looks like that this is. Hard walls tend nevr to use this and when I drive into hay bails that have a higher number I can go in further. PLEASE check this out and see if you agree. ------------ OBSERVATIONS ------------ *Walls in General -Absorbing walls use a softer surface texture (4 or more). So far I have noticed that they usually use both unknowns, they also akways have 2048 is added to their surface type. -Hard walls seem to either use a 1, 2, or a 3 surface type. They are a bit more varied in terms of numbers than an absorbing wall. -For an outside of the track it must end with a surface texture of 10, the inside doesn't use this. -Edge of track walldata appears to use 20000 1/500 of an inch to define the edge of raceable area for both inside and outside of track. This may be to define all of wall inside of trk instead of haing it hang into nothing which may make the game crash (speculaion only). -Bushes & Grass walls Bushes appear in Monza a lot. They use gravel texture and can be any height. Grass is Seen at Mexico, NRing, and Silverstone. 6 at Mexico, 0 at Monza, 17 and 26 at NRing, and 10 at Silverstone. (2054/16/#####/##) -Cyclone Fence These are at Watkins Glen and Zandvoort. Then really absorb the car well and actually act sort of like a spring throwing the car back if the car is going fast enough. At Watkins the last number is 0, while at Zandy it's 10. (2053/16/24000/##) -Dirt So far I have only looked at the code for it in Watkins Glen, but it always has the same makeup. (5/16/0/2) -Hay Bails So far I have only looked at them in Mexico and have noticed that they use a grass texture. So far for the last number I have observed: 0(Mon Harbor in)(Zan hairpin2), 3(Mon Lowes in-e), 21(Mon Harbor out), 25(Mon Rascasse out-b), 29(Mon Lowes in-b), 30(Mon Rascasse out-e). (2052/16/(18)(12)000/##) -Wooden Fence These are at Watkins Glen. I've not run into these much so I do not know their properties too well. I've seen the traditional wooden fence at Watkins Glen have 0 for last number and at NRing the wooden fence with only 1 horiztonal bar uses 0, but also at the Nring that wooden fence at the beginning of the circuit with many vertical pieces is 28. (2056/16/#####/##) -Objects other then barriers I have my suspisions that this may not be defined in the trk. Possibly 3do for more accuracy in placement? **************** * Section Data * **************** All lengths and heights are defined as 1/500 of an inch. There is one record for each section. Each record is 52 bytes long 0 Type 1 = Straight, 2 = Curve 1 Start Beginning of section 2 Length of section 3 Heading (2147483648 = 180 deg = x) 4 Always zero 5 Equation 1 / X center of turn 6 Equation 2 / Y center of turn 7 Equation 3 / Half of angle of turn 8 Equation 4 / null 9 always near 1073741824 / null 10 Trace Data Index 11 Wall Data Count 12 Wall Data Index The start of the first section is 0. The start plus the length gives the start of the next section. The total length equals the track length in the header. The orientation is the way the track is pointing at the start of the section. There are sometimes 2 adjacent straight sections with slightly different orientations. The unit is 360 degrees divided by the maximum unsigned 32 bit value + 1. Equation 1 = (0.5 x) cos (-180 heading/x) X center which radius bases itself at to make curve/circle for the turn. Equation 2 = (0.5 x) sin (180 heading/x) Y center which radius bases itself at to make curve/circle for the turn. Equation 3 = (0.5 x) sin (-180 heading/x) Half of angle = (x * Length of section)/(2 * Pi * radius of turn) Equation 4 = (0.5 x) cos (180 heading/x) For turn believed not to be used. These equations end up getting answers ver similar to what Papyrus gets. I have noticed that they did round on some of the answers so that an entire straight would have the same number, but that is only a minor thing that can be corrected by hand. I have not tried setting it to something very wrong to see what exactly they do. The number differences are so miniscule that there would be NO difference. We believe 8 and 9 are nulls for the turn. The trace data index is the index of the first trace for this section, the rest following in multiples of the amount of trace lines. The wall count is the number of wall records for this section. The are sequential from the wall index. ---------------------------------- Information ammended and added by: Jon Van Ginneken jnvngn@aimih.com Original author's work found at: http://www.uea.ac.uk/~w9628525/trkfile.txt