Graphics Programs Reference
In-Depth Information
have used the functionality of most of them already in some form or another, in earlier
chapters. The first two buttons, shown at the top of Figure 9.2, control the distance
of the camera to the picture plane. The effect of these buttons is to change the focal
length of the camera.
Camera Zoom In and Out
Translate in x-, y-, z-Directions
Rotate about x-, y-, z-Axes
Scale in x-, y-, z-Directions
Figure 9.2 Object manipulation buttons defined
The remaining buttons control the object. The buttons in the second row of Figure 9.2
are the translation buttons, which enable you to move the object left and right, up
and down, and in and out, respectively. The buttons shown in the third row will let you
rotate the object about the x-axis, y-axis, and z-axis. The buttons in the bottom row of
Figure 9.2 provide new functionality for transforming an object. With these buttons, you
will be able to scale the object horizontally, vertically, and in depth.
Let's look at the script for the buttons. We begin by initializing the variables we will
need to control the camera and object. We are changing only the focal length of the
camera, since the other movements and rotations are equal but opposite to the
1
2
3
4
5
6
7
8
9
// initialize the incremental camera movement
var camdz:Number = 0;
// initialize the incremental object translation,
// rotation, and scale variables
var tx:Number = 0; var ty:Number = 0; var tz:Number = 0;
var rx:Number = 0; var ry:Number = 0; var rz:Number = 0;
var sx:Number = 1; var sy:Number = 1; var sz:Number = 1;
Search WWH ::




Custom Search