Graphics Programs Reference
In-Depth Information
corresponding object movements and rotations. We have seen tx , ty , tz , and ry in
previous chapters. The scale factors sx , sy , and sz are initially set to 1, or 100%.
The button actions follow the variable initialization, and are all simple one-line func-
tions that set the appropriate variables. The camera and move amounts are in pixels,
and although they are hard-coded here, it is easy to define additional variables such
as camSpeed , xMoveAmount , and so forth. The rotation variables rx , ry , and rz are
each measured in degrees.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// -----------------------------------------------------
// define the button actions
camIn_btn.onPress = function() { camdz = -5; }
camIn_btn.onRelease = function() { camdz = 0; }
camOut_btn.onPress = function() { camdz = 5; }
camOut_btn.onRelease = function() { camdz = 0; }
moveLeft_btn.onPress = function() { tx = -5; }
moveLeft_btn.onRelease = function() { tx = 0; }
moveRight_btn.onPress = function() { tx = 5; }
moveRight_btn.onRelease = function() { tx = 0; }
moveUp_btn.onPress = function() { ty = 5; }
moveUp_btn.onRelease = function() { ty = 0; }
moveDn_btn.onPress = function() { ty = -5; }
moveDn_btn.onRelease = function() { ty = 0; }
moveIn_btn.onPress = function() { tz = -5; }
moveIn_btn.onRelease = function() { tz = 0; }
moveOut_btn.onPress = function() { tz = 5; }
moveOut_btn.onRelease = function() { tz = 0; }
xRot_btn.onPress = function() { rx = -5; }
xRot_btn.onRelease = function() { rx = 0; }
yRot_btn.onPress = function() { ry = -5; }
yRot_btn.onRelease = function() { ry = 0; }
zRot_btn.onPress = function() { rz = 5; }
zRot_btn.onRelease = function() { rz = 0; }
The scale variables sx , sy , and sz , are handled a little differently. Unlike the other vari-
ables, which are used to add or subtract values, the scale variables are used to multiply
Search WWH ::




Custom Search