Graphics Programs Reference
In-Depth Information
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// create the viewer or object movement
this.onEnterFrame = function()
{
// check keys to adjust camera movement
if (Key.isDown(Key.UP)) {viewer.z += viewerSpeed;}
else if (Key.isDown(Key.DOWN)) {viewer.z -= viewerSpeed;}
else if (Key.isDown(Key.RIGHT)) {viewer.x += viewerSpeed;}
else if (Key.isDown(Key.LEFT)) {viewer.x -= viewerSpeed;}
// loop over the objects and display them
for (var i:Number = 0; i < numberOfObjects; i++)
{
thisObj = scene3D["object"+i];
displayObj();
}
}
Exercise 7.2: Interactive Navigation in 3D Space
So far our user interaction, whether with the mouse or with arrow keys, has been lim-
ited to movement in two of the three dimensions. Typically, we have used the Up Arrow
and Down Arrow keys to zoom in and out while also using the Left Arrow and Right
Arrow keys to control horizontal movement.
In this exercise we are going to explore navigating in all three dimensions. We will use
the mouse to control horizontal and vertical movement and the Up Arrow and Down
Arrow keys will control zooming in and out. There are other combinations of mouse
and arrow keys that could be used. For example, the mouse might control the horizon-
tal and depth movement, while the Up Arrow and Down Arrow keys would control the
vertical movement. Similarly, but less intuitively, the Left Arrow and Right Arrow keys
could control horizontal movement, while the mouse controls the depth and vertical
movements. There are, of course, other possibilities as well.
Open 7_2_maskCam_DONE.swf to get an idea of where we are headed. Figure 7.7 shows
an example screen of the file. At first, the mouse navigation may seem a little strange
and awkward until you get more comfortable with it. Remember that the mouse is con-
trolling the movement of the viewer and not the objects, so moving the mouse to the
right causes the objects to shift to the left and vice versa.
Search WWH ::




Custom Search