How to create a new character figure
by R. Niehoff
First you should mind the following:
- Tux (and other characters) are still composed of spheres. The figures look very nice but drawing them is quite expensive. For better performance the characters should be shaped with a 3D programm, but currently I keep the sphere-orientated method.
- Tux is a hierarchical structure of different nodes. It's a good idea to study this structure first. (see the overview) It might be helpful to print out the picture.
- The shape is defined in the file "char1.lst". The file is written in SP. Remember that all new lines must begin with *; a line without * is appended to the previous line. Each entry has a plausible default value, so you can omit all entries with standard values. At last: the order of the entries is arbitrary since each data field has its own tag.
And now the rules for shaping a friend of Tux:
There are 3 commands: material, create and prop. The materials must be defined first because some of the following commands apply to the material definitions. With create you create a new node. All new nodes refer to a parent node, so the parent must already exist. The predefined root node is parent of all and called "root". Apart from this essential rule the order of creating nodes is arbitrary. The prop command is only used in special cases (see below).
Normally you define a new node in one line, e.g.:
*[cmd] create [node] 13 [par] head
In this case, the name of this node is a number (13), and the parent node is called "head". You are free to use numbers as well as letters. This node is unvisible, to create a visible node you have to add the entry [vis]:
The value of [vis] defines the sphere resolution. 10 is best resolution, a lower value draws a coarser sphere. A negative value (default) makes the node unvisible. You see that the sphere is scaled and has a material.
All nodes can be translated, rotated and scaled. Example:
The translation entry should be clear, the rotation entry has 2 values. The first value defines the rotation axis (1 = x, 2 = y, 3 = z) in the coordinate system, and the second value defines the rotation angle.
And now some words about the prop command. In some cases you can't define all node properties in a single line. A line can contain only one rotation, if there are more you have to enter them in additional prop lines. Of course, the affected node has to be created first.
*[cmd] prop [node] 34 [rot] 1 -90.0
Another reason can be the order of the transformation statements. All transformations are stored in a single 4x4 matrix which is built step-by-step. Without specifying a special order the matrix is built in the order translation -> rotation -> scale. Somestimes you need another order, and you can force it with additional prop lines. Example:
*[cmd] prop [node] 22 [trans] -0.56 0.3 0
*[cmd] prop [node] 22 [rot] 3 45.0
*[cmd] prop [node] 22 [rot] 1 90.0
The first rotation is done in the create line, followed by a translation and two further rotations. And of course, you needn't define any property in the create line. Sometimes it might be clearer to use a particular prop line for each property. The following two examples have the same effect:
*[cmd] create [node] 20 [par] 14 [vis] 5
*[cmd] prop [node] 20 [trans] 0.12 -0.045 0.4
*[cmd] prop [node] 20 [mat] iriscol
*[cmd] prop [node] 20 [rot] 2 18.0
That's all about the syntax. Perhaps you want to experiment with the character shape. You can do it by changing the file char1.lst. For a better view on the result open main.cpp and change the entry "cfg.program_mode" in the function InitConfig () from "RACE" to "TUXSHAPE". Then you will see the following screen. The figure on the right is permanently rotated, so you can view it from all directions.

For testing you can download a template for characters. Change it and see what happens.