BRender Tutorial Guide:3 Positioning Actors

3 Positioning Actors

Your Second Program
In chapter two, you were introduced to your first BRender program. You now know how to display a revolving grey cube! No doubt you are anxious to expand your BRender repertoire. You will be pleased to know that this will not be as difficult as you might have expected. You have already learnt the fundamentals. By the time you have worked through the following short chapters, your ability to produce complex 3D applications will be limited only by your imagination and the extent of your C programming skills. This chapter is devoted to 3D transformations - placing and moving models in a 3D scene.

The fundamental transformations: Translation, Rotation and Scaling, were introduced in Chapter 1. These can be represented in a number of different ways. In fact six different transformation types are available in BRender.

The simplest is the Identity Transform, which specifies the identity matrix as the transformation matrix. The identity matrix does not alter an actor's shape or position. It makes an actor effectively share its parent's co-ordinate space. The Translation transformation is used to implement a translation (useful when no rotation or scaling are involved in a transformation). The Translation transformation type is represented in BRender as a vector that is added to an actor's co-ordinates. Euler, Look-Up and Quaternion transformations all specify a translation and an orientation.

The Euler transform applies three separate rotations in turn, in a specified order. Euler angles are the generalisation of the pitch-yaw-and-roll of flight simulators.

A look-up transformation is a convenient method of making an actor, often a camera actor, point towards a particular position. A look vector is used to specify the view direction, and an up vector to define the orientation.

The unit quaternion transform represents a rotation about an arbitrary vector. Quaternions are used in computer animations for interpolating the positions of tumbling bodies between key frames.

The most general representation is the Matrix Transform (BR_TRANSFORM_MATRIX34). All the transformation types discussed above can be implemented using matrices (refer to Chapter 1 of this guide and to br_matrix34 in your technical reference manual for details of how matrix transforms are performed). You will recall from Chapter 1 that matrices can be concatenated, allowing a complex sequence of transformations to be pre-processed into a single transformation matrix. Not surprisingly then, computer graphics systems normally represent transformations internally using matrices.

The transformations implemented in our tutorial programs use the BR_TRANSFORM_MATRIX34 representation. Feel free to experiment with the other available implementations. Refer to your technical reference manual for details of relevant structures and data types.

Generated with CERN WebMaker