A script keeps one current transform, a 4 × 4 matrix that starts as the identity. Each
transform command changes it, and every vertex, primitive and prototype instance that
follows is put through it. The commands are used in HUMAN.RWX and
TRIAD.RWX, which settle the points the text says are checked.
The order commands apply in
Each Translate, Rotate,
Scale and Transform multiplies the
current transform by its own matrix on the right, as in OpenGL. The result is that the
commands nearest the geometry act on it first: Translate then
Scale then a shape scales the shape and moves it.
TransformBegin
Translate 1.2 0 0
Scale 0.02 0.02 0.02
ProtoInstanceGeometry X
TransformEnd
TRIAD.RWX: the letter X, which is eight units wide, is scaled to 0.16 and then put at x = 1.2, the end of the x axis. In the other order it would end up at 0.024.The commands
| Command | Arguments | Effect |
|---|---|---|
Identity | none | Sets the current transform back to the identity: no move, turn or scale. |
Translate | x y z | Moves what follows by that distance along each axis. |
Rotate | x y z degrees | Turns what follows about the axis through the origin along (x, y, z), by an angle in degrees. The axis need not be a unit vector, and a zero axis does nothing. |
Scale | x y z | Multiplies the distances along each axis, so an unequal scale squashes or stretches. HUMAN.RWX makes a foot with Scale 0.4 0.4 1.0 before a sphere. |
Transform | sixteen numbers | Multiplies by a 4 × 4 matrix. The viewer takes the numbers row by row as the matrix of a row vector (x, y, z, 1), so the last row holds the translation. No sample file uses it, and that layout is from memory of RenderWare’s convention. |
IdentityJoint, TranslateJoint, RotateJoint, TransformJoint | as the commands above | Joint transforms, for parts that an animation bends. The viewer draws the model in the pose the file gives and treats each as the command of the same name without Joint. |
The direction of Rotate is fixed by TRIAD.RWX. It draws the
arrow along y, then turns copies with Rotate 0 0 1 -90 for the x axis and
Rotate 1 0 0 90 for the z axis, and puts the letters X and Z at
Translate 1.2 0 0 and Translate 0 0 1.2. A turn of −90° about
z takes +y to +x, and one of 90° about x takes +y to +z, which is what the standard
rotation matrix does (a positive angle turns y towards z about x). The same file turns
the letter Y by Rotate 0 1 0 45 and the letter Z by
Rotate 0 1 0 90.
Only RotateJoint appears in the demonstration scripts on this Mac, twice,
in the arm of HUMAN.RWX: RotateJoint 1 0 0 -45 for the elbow
and RotateJoint 0 0 1 30 for the wrist. The other three joint commands are
from memory.
Scopes and clumps
TransformBegin saves the current transform and
TransformEnd sets it back. It is how a script moves one
part into place without moving the next: nearly every part of
HUMAN.RWX is wrapped in one, and so is each arrow of
TRIAD.RWX. Only the transform is saved; the material in force is not
touched. A ClumpBegin also saves and restores the transform, and what
the clump sets on top of it is relative to the clump around it, so a hand follows its
forearm and the forearm its arm.
ClumpBegin # Fore arm
Translate 0.0 -0.4 0.0
RotateJoint 0.0 0.0 1.0 30.0
ClumpBegin # Hand
Color 1.0 0.0 0.0
Rotate 1.0 0.0 0.0 180.0
Cone 0.2 0.04 12
ClumpEnd
ClumpEnd
HUMAN.RWX: the hand’s cone is placed by the forearm’s move and turn as well as its own.A prototype is drawn with the transform in force at the instance, so one
ProtoBegin can be put in many places with a Translate in front
of each ProtoInstance. Vertices are put through the transform when the
Vertex command is read (see
Vertices and faces).
That clumps, as well as TransformBegin, set the transform back at their end
is how this viewer does it. No sample file has a transform command that would reach
past a ClumpEnd, so none shows it.
Not described
The order of Translate, Rotate and Scale and the direction of Rotate are confirmed by TRIAD.RWX; the following is not.
- Reference: the Transform matrix layout (row vectors) is from memory; no sample file uses Transform.
- Reference: only RotateJoint is in a sample file; what the joint commands mean to an animation is not described.
- Reference: whether a clump restores the transform at its end is how the viewer does it, unconfirmed.
- Viewer: treats the joint commands as their plain forms and draws only the pose the file gives.