Difference between revisions of "Track element building"

From Stunts Wiki
m (Track element assembly moved to Track element building: Calling things "assembly" at this stage is confusing =D)
 
(3 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
==General observations==
 
==General observations==
  
Track elements have two different models. The '''graphical model''' consists of a [[Resource file format#3d shapes|3D shape]] stored in either of GAME1.P3S or GAME2.P3S . Like any regular 3D shape, it can be modified using [[stressed]]. The graphical model, however, only controls the looks of the element. Actual physical behaviour is determined by a '''physical model'''. The physical model data appears to be spread over a number of files, and only parts of such data were located thus far. Briefly, track elements are made of potentially several plane surfaces, whose description is stored at the ''plan'' resource of GAME.PRE . Such plane surfaces, which are in principle boundless, are then weld together by a set of rules stored elsewhere. Another important piece of data which is not in ''plan'' is the type of surface associated with each plane (asphalt, grass, etc.). It is important to notice that plane surfaces in ''plan'' are not unique - for instance, the same planes are used for creating hill slopes and bridge ramps, and thus alterations to the plane surfaces will be reflected in both elements. The difference between the two elements is merely one of assembly - that is, where the planes are cut within the track tile in order to result in the track element shape. A similar situation is observed for the [[cork l/r]] and the [[pipe]] round surface. GAME.PRE also contains the ''wall'' resource, which stores data for non-drivable surfaces (such as bridge and building walls) in a poorly understood format.  
+
Track elements have two different models. The '''graphical model''' consists of a [[Resource file format#3d shapes|3D shape]] stored in either of GAME1.P3S or GAME2.P3S . Like any regular 3D shape, it can be modified using [[stressed]]. The graphical model, however, only controls the looks of the element. Actual physical behaviour is determined by a '''physical model'''. The physical model is only partly stored in resource files. Briefly, track elements are made of potentially several plane surfaces, whose description is stored at the ''plan'' resource of GAME.PRE . Such plane surfaces, which are in principle boundless, are then weld together by a set of rules hard coded within the game engne. Another important piece of data which is not in ''plan'' is the type of surface associated with each plane (asphalt, grass, etc.). It is important to notice that plane surfaces in ''plan'' are not unique - for instance, the same planes are used for creating hill slopes and bridge ramps, and thus alterations to the plane surfaces will be reflected in both elements. The difference between the two elements is merely one of assembly - that is, where the planes are cut within the track tile in order to result in the track element shape. A similar situation is observed for the [[cork l/r]] and the [[pipe]] round surface. GAME.PRE also contains the ''wall'' resource, which stores data for non-drivable surfaces (such as bridge and building walls) in a poorly understood format.
  
 
==GAME.PRE data==
 
==GAME.PRE data==
Line 12: Line 12:
  
 
  struct PLANE {
 
  struct PLANE {
 +
    WORD angleXY;
 
     WORD angleYZ;
 
     WORD angleYZ;
    WORD angleXY;
 
 
     VECTOR origin;
 
     VECTOR origin;
 
     VECTOR normal;
 
     VECTOR normal;
Line 27: Line 27:
 
  };
 
  };
  
''origin'' sets a point in space belonging to the plane (coordinate system is the same track tile system of the 3D shapes in GAME1/2), and ''normal'' sets a normal vector to the plane "normalized" to a length of 8192. These two vectors are enough to define a (boundless) plane. ''angleYZ'' and ''angleXY'' appear to contain the inclination of the planes (given in units of 360/1024 degree, with values ranging form 0 to 1023). Since such data is made redundant by ''origin'' and ''normal'' and the values have no obvious effect on the surface behaviour their actual function is unknown. Finally, ''rotationMatrix'' appears to be a rotation matrix (of column vectors "normalized" to 16384) which changes the orientation of the car normal vector when it changes surfaces. It must be correctly set so that the surface displays reasonable physical behaviour.
+
''origin'' sets a point in space belonging to the plane (coordinate system is the same track tile system of the 3D shapes in GAME1/2), and ''normal'' sets a normal vector to the plane "normalized" to a length of 8192. These two vectors are enough to define a (boundless) plane. ''angleXY'' and ''angleYZ'' appear to contain the inclination of the planes (given in units of 360/1024 degree, with values ranging form 0 to 1023). Since such data is made redundant by ''origin'' and ''normal'' and the values have no obvious effect on the surface behaviour their actual function is unknown. Finally, ''rotationMatrix'' appears to be a rotation matrix (of column vectors "normalized" to 16384) which changes the orientation of the car normal vector when it changes surfaces. It must be correctly set so that the surface displays reasonable physical behaviour.
  
 
The 536 structures in ''plan'' are arranged in 134 sets of 4 plane surfaces. Each plane in these quartets corresponds to the same part of the associated track element(s), the only difference being orientation relative to the track grid. The order on each quartet is predictable: the first one is in S->N orientation (pointing to +z) and the others correspond to counter-clockwise rotations (for pieces of bridge corners and banked roads, the first plane of the quartet is from the corner going S->W, the second one E->S and so on.).
 
The 536 structures in ''plan'' are arranged in 134 sets of 4 plane surfaces. Each plane in these quartets corresponds to the same part of the associated track element(s), the only difference being orientation relative to the track grid. The order on each quartet is predictable: the first one is in S->N orientation (pointing to +z) and the others correspond to counter-clockwise rotations (for pieces of bridge corners and banked roads, the first plane of the quartet is from the corner going S->W, the second one E->S and so on.).
Line 91: Line 91:
 
|25 ||97 ||103E ||Banked corner
 
|25 ||97 ||103E ||Banked corner
 
|-
 
|-
|26 ||101 ||10C6 ||Banked road entrance (1st orientation is inner=left)
+
|26 ||101 ||10C6 ||Banked road entrance B (1st orientation is inner=left)
 
|-
 
|-
|27 ||105 ||114E ||Banked road entrance
+
|27 ||105 ||114E ||Banked road entrance B
 
|-
 
|-
|28 ||109 ||11D6 ||Banked road entrance
+
|28 ||109 ||11D6 ||Banked road entrance B
 
|-
 
|-
|29 ||113 ||125E ||Banked road entrance
+
|29 ||113 ||125E ||Banked road entrance B
 
|-
 
|-
|30 ||117 ||12E6 ||Banked road entrance
+
|30 ||117 ||12E6 ||Banked road entrance B
 
|-
 
|-
|31 ||121 ||136E ||Banked road entrance
+
|31 ||121 ||136E ||Banked road entrance B
 
|-
 
|-
|32 ||125 ||13F6 ||Banked road entrance
+
|32 ||125 ||13F6 ||Banked road entrance B
 
|-
 
|-
|33 ||129 ||147E ||Banked road entrance
+
|33 ||129 ||147E ||Banked road entrance B
 
|-
 
|-
|34 ||133 ||1506 ||Banked road entrance
+
|34 ||133 ||1506 ||Banked road entrance B
 
|-
 
|-
|35 ||137 ||158E ||Banked road entrance
+
|35 ||137 ||158E ||Banked road entrance B
 
|-
 
|-
|36 ||141 ||1616 ||(unknown)
+
|36 ||141 ||1616 ||Banked road entrance A
 
|-
 
|-
|37 ||145 ||169E ||(unknown)
+
|37 ||145 ||169E ||Banked road entrance A
 
|-
 
|-
|38 ||149 ||1726 ||(unknown)
+
|38 ||149 ||1726 ||Banked road entrance A
 
|-
 
|-
|39 ||153 ||17AE ||(unknown)
+
|39 ||153 ||17AE ||Banked road entrance A
 
|-
 
|-
|40 ||157 ||1836 ||(unknown)
+
|40 ||157 ||1836 ||Banked road entrance A
 
|-
 
|-
|41 ||161 ||18BE ||(unknown)
+
|41 ||161 ||18BE ||Banked road entrance A
 
|-
 
|-
|42 ||165 ||1946 ||(unknown)
+
|42 ||165 ||1946 ||Banked road entrance A
 
|-
 
|-
|43 ||169 ||19CE ||(unknown)
+
|43 ||169 ||19CE ||Banked road entrance A
 
|-
 
|-
|44 ||173 ||1A56 ||(unknown)
+
|44 ||173 ||1A56 ||Banked road entrance A
 
|-
 
|-
|45 ||177 ||1ADE ||(unknown)
+
|45 ||177 ||1ADE ||Banked road entrance A
 
|-
 
|-
 
|46 ||181 ||1B66 ||Loop surface
 
|46 ||181 ||1B66 ||Loop surface
Line 301: Line 301:
 
|130 ||517 ||4806 ||Right-handed cork u/d
 
|130 ||517 ||4806 ||Right-handed cork u/d
 
|-
 
|-
|131 ||521 ||488E ||RH corh u/d bridge
+
|131 ||521 ||488E ||RH cork u/d bridge
 
|-
 
|-
|132 ||525 ||4916 ||
+
|132 ||525 ||4916 ||S/F line auxiliary
 
|-
 
|-
|133 ||529 ||499E ||
+
|133 ||529 ||499E ||S/F line auxiliary
 
|-
 
|-
 
|134 ||533 ||4A26 ||Tunnel roof
 
|134 ||533 ||4A26 ||Tunnel roof
Line 327: Line 327:
  
 
[[Category:Modding]]
 
[[Category:Modding]]
 +
[[Category:Internals]]

Latest revision as of 04:15, 13 March 2019

This article aims to present what is currently know on how Stunts stores the data which is used to assemble track elements such as roads, bridges, loops and scenery. The ultimate goal is to be able to effectively modify the existing elements and create new ones. There is still much to learn before that becomes possible, though - which also means there will be large gaps on this article for the time being.

General observations

Track elements have two different models. The graphical model consists of a 3D shape stored in either of GAME1.P3S or GAME2.P3S . Like any regular 3D shape, it can be modified using stressed. The graphical model, however, only controls the looks of the element. Actual physical behaviour is determined by a physical model. The physical model is only partly stored in resource files. Briefly, track elements are made of potentially several plane surfaces, whose description is stored at the plan resource of GAME.PRE . Such plane surfaces, which are in principle boundless, are then weld together by a set of rules hard coded within the game engne. Another important piece of data which is not in plan is the type of surface associated with each plane (asphalt, grass, etc.). It is important to notice that plane surfaces in plan are not unique - for instance, the same planes are used for creating hill slopes and bridge ramps, and thus alterations to the plane surfaces will be reflected in both elements. The difference between the two elements is merely one of assembly - that is, where the planes are cut within the track tile in order to result in the track element shape. A similar situation is observed for the cork l/r and the pipe round surface. GAME.PRE also contains the wall resource, which stores data for non-drivable surfaces (such as bridge and building walls) in a poorly understood format.

GAME.PRE data

The plan resource

plan is composed of 536 structures of 34 bytes each, each associated with a plane which in turn forms part of a drivable surface. The structures consist of:

struct PLANE {
    WORD angleXY;
    WORD angleYZ;
    VECTOR origin;
    VECTOR normal;
    VECTOR[3] rotationMatrix;
};

In the above, WORD = 2-byte signed integer and:

struct VECTOR {
    WORD x;
    WORD y;
    WORD z;
};

origin sets a point in space belonging to the plane (coordinate system is the same track tile system of the 3D shapes in GAME1/2), and normal sets a normal vector to the plane "normalized" to a length of 8192. These two vectors are enough to define a (boundless) plane. angleXY and angleYZ appear to contain the inclination of the planes (given in units of 360/1024 degree, with values ranging form 0 to 1023). Since such data is made redundant by origin and normal and the values have no obvious effect on the surface behaviour their actual function is unknown. Finally, rotationMatrix appears to be a rotation matrix (of column vectors "normalized" to 16384) which changes the orientation of the car normal vector when it changes surfaces. It must be correctly set so that the surface displays reasonable physical behaviour.

The 536 structures in plan are arranged in 134 sets of 4 plane surfaces. Each plane in these quartets corresponds to the same part of the associated track element(s), the only difference being orientation relative to the track grid. The order on each quartet is predictable: the first one is in S->N orientation (pointing to +z) and the others correspond to counter-clockwise rotations (for pieces of bridge corners and banked roads, the first plane of the quartet is from the corner going S->W, the second one E->S and so on.).

List of planes

Collapsed table - use the "show" button to view it.

The wall resource

wall is composed of the following structures:

struct WALL {
    WORD angleXZ;
    WORD x;
    WORD z;
};

The data in these structures appear to be ground-plane projections of wall segments, with x and z making endpoints and angleXZ defining segment angles. Verification of that, and identification of wall pieces, is best performed by plotting the x and z values. There must be additional pieces of data involved in wall assembly through, as there is no info on wall heights, nor any obvious link to data in plan; also, simple alterations to wall pieces associated with elements such as block houses or slalom blocks do not work as intended.

External links