Camera Motion Control

The next part of this tutorial focuses on controlling camera motion during an animation. An example is first shown as a typical Alice world with no camera motion (stationary). The example world is then modified to illustrate camera motion using two built-in camera methods: set point of view (definition) and set vehicle (definition).

Stationary Camera (no motion)

In this example world, passenger cars are moving on the skyride . By default, the camera remains in its original position as no instructions have been written to move the camera. Click the Start button to view the animation and the Stop button to end the animation.

Example World for "Stationary Camera"

You need to download Java software in order to view this Alice world. Please visit this page: http://www.alice.org/applet/requirements/

View Stationary Camera program code


Set point of view

In Alice, the set point of view (definition) instruction (located under the methods tag of the camera's details panel) is used to:

  1. Set the camera's position to that of the target object's position
  2. Orient the camera in the same direction as the target object's orientation

In other words, a camera.set point of view(target) instruction moves the camera to the target and has the camera face the same direction as the target is facing. After execution of a set point of view (definition) instruction, the camera will then portray the target object's point of view.

The following example is a modification of the skyride world, with the addition of a set point of view (definition) instruction. In this version of the world, the camera moves to the first cable car (skyride.Car1), which -- at the beginning of the animation -- is still located in the lion's head on the right. Also, the camera's orientation is set to the same orientation as the first cable car. When the camera moves to the position of the first cable car, notice the camera does NOT move along with the car as it rides along the track. Click the Start button to view the animation and the Stop button to end the animation.
                             

Example World for "Set Point of View"

You need to download Java software in order to view this Alice world. Please visit this page: http://www.alice.org/applet/requirements/


View Set Point of View's Program Code

Note: After the camera's set point of view (definition) instruction is executed, one might expect that every time the target object moves, the camera would move along with and maintain the same orientation as the target. But, this is not true. That is to say, it does not repeatedly update. To have the camera move along with and maintain the same orientation as the target object requires additional coding (see the Set Vehicle instruction on this page).


Set vehicle

In Alice, the set vehicle (definition) instruction (located under the methods tag of the camera's details panel) causes the camera to move simultaneously with the target object. After execution of the set vehicle instruction, wherever the target moves, the camera follows along in the same direction. It is important to note that:
  1. Execution of a camera.set vehicle instruction does NOT change the orientation (the direction the camera is facing).
  2. Once the camera's vehicle has been set to a target object, the camera will continue to mimic the object's motion. That is to say, it does a repetitive update. And, instructions that move the camera itself do NOT cancel the camera's vehicle property.

The following example is yet another modification of the skyride world, demonstrating the effect of adding a set vehicle (definition) instruction. The new instruction is added to the previous version of the world, as shown in the set point of view instruction above. The camera now rides along with the cable car as it moves along the track. Thus, the view of the camera is from the perspective of riding the cable car! Click the Start button to view the animation and the Stop button to end the animation.

You need to download Java software in order to view this Alice world. Please visit this page: http://www.alice.org/applet/requirements/


View Set Point of View and Set Vehicle's Program Code


Note: In this third version of the skyride world, both set point of view (definition) and set vehicle (definition) instructions were used. If the set vehicle instruction were invoked without the set point of view instruction being called, the camera would mimic the target object's movement, but would do so from wherever its CURRENT position is!


Back Return to Main