For basic track generation the trackgen
utility in torcs is sufficient.
The included accc
utility is used to combine various track elements in the final track description.
To use accc
you will also need the stripe
utility in your path.
Firstly, create a directory tracks/category/name
where category
is one of dirt, speedway, road, circuit and name
is the name of your track.
Create the track .xml file. You can take one of the available tracks to start with. The file shall contain one entry for the 3d description, which should be name.ac
For initial testing of your track, issue the command trackgen -n name -c category
. See that the track is OK by loading it with torcs.
To test shading, issue the command trackgen -a -E 1 -n name
-c category
from the top level directory. The track step and
border step parameters in the Terrain Generation section of the xml
file define the complexity of the terrain generation. If it takes too
long, make them larger. This will create an elevation file,
name-elv.png
It is possible to create a simple shading scheme with the gimp. Open the image, select Filter &rarr Distorts &rarr Emboss. Select the parameters and apply the filter. Save the file as shadow2.rgb
. If it is not a power of 2 in size, you have to resize it so that it has dimensions (x,y)=(2a, 2b)
However this scheme is not very good. It does produce soft shadows, but it is not much different than the light produced by the light source in the .xml file. A possibility is to do the following. After you Emboss the image, select Filters &rarr Blur &rarr Motion Blur. Select an angle that is 360 - a, where a is the angle that you have chosen for Emboss, if in the latter your elevation degrees was smaller than 90. If it was larger than 90, set angle to a. Select the appropriate length (between 10 and 50 is OK) and copy the image into a new buffer. Reopen the old image and place the new image as a layer on top of it. Now select either Multiply, or Darken Only and adjust the opacity to around 50. This should result in some shadows appearing to be cast from the sharper edges of your massif. Replace the previous shadows image with this one.
Now do cd tracks/category/name
and issue the command
cp name.ac name-bak.acto have a backup of the original track description. This can then be used to generate a shading file that will use
shadow2.rgb
as a texture, with the following command:accc +shad name-bak.ac name-shade.ac
Now you can combine the two descriptions into one using
accc -g name.ac -l0 name-bak.ac -l1 name-shade.ac -d3 1000 -d2 500 -d1 300 -S 300 -esIf the output is too much for your terminal you can always redirect it to /dev/null
Test your new track with torcs.
It is possible to create elevation files by issuing the command
trackgen -a -E x -n name -c category
, where x
selects which elevation file should be generated.
0: all elevatation files 1: elevation file of terrain + track 2: elevation file of terrain with track white 3: track only 4: track elevations with height stepsEach one of those will be useful for some purpose. I personally use 1 and 3. Number 3 can also be used to create a track preview. It can also be used to get an idea of where the track is so you can take this into account when changing the elevation map. The procedure is as follows:
Using either the track or terrain+track map as a template create a black and white image. The whiter a pixel is, the higher. Then save the images as elevation-map.png
. You will then need to insert the following lines in the Terrain Geneartion section of name.xml
<section name="Terrain Generation"/> .... <attstr name="elevation map" val="elevation-map.png"/> <attnum name="maximum altitude" val="30"/> <attnum name="minimum altitude" val="-30"/> ...The maximum and mimimum altitude specify what the altitude corresponding to the brightest and darkest pixel in the image, respectively. You might need to fiddle around with that a bit until you get it right.
Of course, as seen in the previous section you can use the elevation map that you have created to generate shadows.
The group size is used to split the terrain in smaller objects to help the scene graph make his job. If all the terrain is done in one object, it will never be culled and performance will be awful. This is done after the mesh generation, so it's not related to the mesh geometry.
<attstr name="relief file" val="track-relief.ac"/>
You can use additional ac3d files initially for setting altitude on the terrain. However the same points are also used in the generated mesh, thus possibly resulting in a better mesh. If a <track>-relief.ac file exists in the directory it will be used for the terrain generation by trackgen.
You can use additional ac3d files (see e-track-6-relief.ac in the sources) initially for setting altitude on the terrain but as the points are used in the generated mesh, it can be useful to give better mesh.
If a <track>-relief.ac file exists in the directory it will be used for the terrain generation by trackgen.
The mesh generator stops on closed polys, so if you want a hole in the mesh, you can draw closed polys, else you draw lines and they participate to the mesh.
If you supply the external border in the "relief" file, you can used the trackgen option "-B" to use it as external border instead of generating the default rectangular border.
Lastly, you have to set properties to your lines and polys in the "relief" files : "internal" for the inner mesh and "external" for outer mesh.