Camera Control Tutorial - Duke Computer Science

12 downloads 209 Views 3MB Size Report
Why make a tutorial on controlling the camera? It should be obvious, shouldn't it? For some it might be, but it took me
Camera Control Tutorial 0. Why?

Why make a tutorial on controlling the camera? It should be obvious, shouldn't it? For some it might be, but it took me some practice to get used to it, and there are a couple of tricks that are incredibly useful to know if you want to write any kind of program where the camera has to change positions. However, here's a way of figuring out whether this tutorial is useful for you: If you are able to arrange the four characters in the shape of a diamond (on the ground), and then return the camera to its position at the initial state of the world, you probably don't need to be reading this. 1. Loading the World

Download the file that we'll be working with today here. Save it in a directory that you can find again, and then start Alice and open it in Alice. NB: You cannot double-click the file to open it; Windows will not know what to use, and even if you select Alice from a list of programs, the loading will fail. If your computer does not know about Alice worlds, it sometimes changes the extension to zip when you save it. You will have to change it back before you can load it in Alice.

After you have opened the file, we want to go into the "Layout" mode, so click on the green Add Objects Button (The button is gray in the screenshot below, because my mouse is over it).

The window with the graphics should enlarge to take up a larger proportion of the screen, and the righthand side should show some controls for manipulating objects, as shown below:

The pictures at the bottom are folders such as Amusement Park, which contain objects like rollar coasters and carousels.

2. Saving the Current Camera Angle - Learning to Drop Dummies Before we even begin to move the camera, we will learn how to "save" a particular camera position. In the right hand frame of the layout mode we just entered, click the gray "More Controls" button.

Next, click on the grey "drop dummy at camera" button.

This action will save the current camera position in the form of a "Dummy Object," which will appear on the left-hand frame, under a folder named "Dummy Objects."

Now, move the camera randomly, by hitting various blue arrows. Here is a random position I managed to put my camera in; your camera may even no longer be pointing at the characters.

To get back to the original camera position, right-click on "camera" in the left pane, and select "methods," "set point of view," "Dummy Objects", and finally "Dummy." The camera should return to the location at the beginning. Alternately, you can use the "move camera to dummy" drop-down menu on the right hand side. I am showing you the first way because it works even when you're in the programming mode of Alice.

This technique is very useful for at least two occasions I can think of. The first is if you are zooming in really close on something to position things, such as a blackboard into a wall, you want to save the camera angle that you want your viewer to view the scene, so that you can return to it easily. Also, when we learn to program Alice, you can set the camera to a particular dummy's point of view in the middle of your program. I will also note here that you can rename dummies with more meaningful names, so you remember which dummy referred to which position. Simply right-click on the dummy and click "rename," type the new name, and press Enter. This is actually how you rename anything.

3. Camera Movement - Left, Right, Up, Down, Forward, Backwards

I want to make sure you understand the difference between moving the camera and changing the angle of the camera. We are looking strictly at Camera motion. All of these movements do NOT change the angle of the camera. The direction controls for Up, Down, Left, and Right are the leftmost blue set of arrows.

The direction controls for Forward and Backward motion are the top and bottom of the second set of arrows.

Play with these until you completely comfortable with just shifting the position of the camera.

4. Camera Angling

Now that you're comfortable with moving the camera physically in the Alice 3D environment, we can look at adjusting the angle of the camera. The Left and Right arrows in the middle set of controls allow you to turn the camera left and right. To see this, you can click and hold one of them until you've made the camera do one full revolution, so you wind up back where you started. Just be careful not to be moving backwards and forwards while you're doing it, because Alice allows you to use two controls at once.

Finally, we can tilt the camera up or down using the last two arrows. The upper arrow tilts the camera down, and the lower arrow tilts it up. Again, remember that the camera's location in the world is fixed when we're using these controls - we are simply changing the angle that it's facing.

5. Getting a Bird's Eye View (without using quad-view) - Combining Motion with Angling

Now, we will do the exercise specified at the top of this page. We want a bird's eye view so we can easily arrange our shapes into the form of a diamond. To do this, let us first return the camera to the original position, by setting the camera's point of view at the first dummy we made earlier together (for all I know, you could have made ten more while you were playing with the camera). Then, we want to raise the camera, high into the sky, so we click and hold the Up arrow:

Next, we want to tilt the camera down, straight at the ground, To do this, we use the Up arrow on the rightmost control.

Now, occasionally, we find that we didn't go up far enough, so when we tilt down, see the characters below at some angle that is not straight vertical. Alternating between the two controls should get us where we want.

When you are done, the view should look something like this:

You might want to save this camera view to a dummy object so you can get to it quickly if you want to experiment.

While we are here, I would like to briefly digress and note something subtle about the camera controls. In this bird's eye view, if you press the Forward or Backward arrow, your view will be shifted up or down. If you press Up or Down, it will look like your view is being zoomed in and out. In other words, the controls Forward, Backwards, Up and Down are absolute, and carry out the same action regardless of how the camera is oriented. Think about it this way: You're in the air, looking down at the ground. If you go "Down" in the absolute sense, then you're getting closer to the ground so it's as if you're zooming in. Similarly, If you're in the sky looking down and you move forward, it will look like the

ground is shifting up or down. On the other hand, if you use the left and right controls on the leftmost arrow pad, you'll notice that these controls move Left or Right relative to your camera angle.

Now that you are in bird's eye view, you can simply click to drag the characters to arrange them in a diamond shape.

Finally, set the camera back to the view of the first dummy to see your work.