Vizard 8 » Reference » Matrix transforms » Combining transforms
8.0

Combining transforms

 

Model transformations refer to the mapping from object- to world-coordinates. To do this, Vizard allows you to specify a sequence of transformations. There are three different kinds of transformations that you can apply: translation, rotation, and scale. In Vizard, each layer (an object or collection of objects) has its own independent sequence of transformations. Initially, all sequences are set to the identity transformation, meaning that the mapping from object- to world-space is one-to-one.

 

The order in which transformations are applied is critical, and almost always very different results will occur if applied in the wrong order. In Vizard, which follows the OpenGL convention, transformations are applied to objects in the REVERSE order in which they are specified. This means the last transformation you do to a layer should be the first one you want applied when thinking in terms of the mapping from object- to world-space.

 

As an example, say you have a model of a person facing north (nose pointed along the +Z axis) and centered about the origin. Now you want to move this object due north and rotate so that the person is looking west. Conceptually, you should first rotate the model 90 degrees to the left, and then translate it away from the eye point along the +Z axis. The opposite order of transformations leads to a different result. For instance, if you first pushed the model out along the +Z axis, the rotation would have the effect of "revolving" the model around the world origin (0,0,0); the result would be a person due east of the eye point instead of due north.

 

Be careful when applying scale transformations. The scale transformation will multiply any translations that have already taken place (so it'll affect all those setPosition calls that are issued AFTER a setScale call). So, if you move an object away from the origin by one meter and then scale everything by a factor of 2, it will actually have moved two meters. Another warning about scaling is that unequal scaling along the 3 axes will lead to non-perpendicular rotations that occur before the scale call, which can really make things confusing.

See also

In this section:

Matrix transform basics

Quaternions

Matrix Transforms command table

Other sections:

3D model transforms basics

Example scripts:

Matrix transformations