How to define terrains
by R. Niehoff
What are terrains?
Terrains are PNG bitmaps used for covering the natural surface (not the objects and models). Typical terrains are snow, ice, rock, sand, grass etc. The size of the bitmaps should be 256 x 256. It's possible to define terrains with 512 x 512 or 1024 x 1024 pixels but the larger size doesn't have remarkable advantages. On the contrary, the larger bitmaps slow down the race but don't appear much nicer. Important: all terrain bitmaps must be prepared for getting tiled, that means that the edges of adjacent tiles (of same terrain type) must fit together.
For each terrain a specific color code is defined. The colors appear on the terrain.png and define the terrain covering on the course. The color code can't be changed once it is used on a course. So the colors should be defined cannily. The colors on the terrain map needn't be 100 % exact, the 3 color channels red, green, blue have a tolerance of +/- 15. It's a good idea to use graduated colors with steps of 30, e.g. 60-0-120 or 90-90-210. to keep the compatibility to the classic terrains snow, ice and rock the following color codes are occupied:
255-255-255 (snow)
128-128-128 (rock)
It won't be good to change these codes because many courses already use them.
The properties of all standard terrains are defined in the list "terrains.lst" which is located in the folder data/terains, together with the terrain bitmaps. A typical entry:
[col] 255 255 255 [sound] snow_sound [vol_type] 1 [part] 1 [trackmarks] 1
[shiny] 0 [track_texture] snow_track.png
The properties:
[name] An arbitratry notation to recognize the terrain. The entry is not used internally.
[id] That's the most important entry. The value is internally used to discern the terrain. An ID can't be used twice, so keep care to use an unique number (0 - 63). Default is the snow ID, so if the loading of a terrain fails it will fall back to snow.
[texture] Clear, the filename of the terrain bitmap. If the bitmap doesn't exist, the snow texture is used.
[depth] This value defines how much to dive into the surface. The depth of ice terrain is typically 0. Default = 0.
[friction] The friction coefficent of the terrain. 0 = no friction, 1 = full friction (no motion possible). Default = 0.5.
[col] Color code for the terrain map (3 values in the order red, green blue).
[sound] The sliding sound when Tux touches the surface.
[vol_type] Kind of sliding sound.
[part] A boolean value: 0 = no snow particles when braking or turning, 1 = particles are generated. Default = 0.
[shiny] A boolean value, only for ice: 0 = no reflections, 1 = reflections on the ice. Default = 0.
[trackmarks] A boolean value: 0 = no trackmarks, 1 = with trackmarks. Default = 0.
[track_texture] In the case that [trackmarks] is set to 1 you have to enter a trackmark texture
And your own terrains?
The explanations above relate to the predefined standard terrains. You may want to create a special terrain for your own course which is used only on this particular course. It doesn't make sense to add the terrain to the list of standard terrains since the installation will be too fiddly. So you can write your own terrain list (called "terrains.lst", too) and put it in the course folder, also the terrain bitmaps. To avoid conflicts with the standard IDs you have to use IDs from 64 up to 99. If an ID is not in the range the terrain will be ignored. The structure of the terrain list is the same as of the standard list.