Use a camera path
Source file: CameraPathExample
in jReality, rendering is controlled by an instance of
Camera. A scene graph can contain several cameras (or even a single camera may appear in more than one
SceneGraphComponent). Which of these cameras should be used is determined by the method
setCameraPath(SceneGraphPath sgp) on the
This example shows how to switch from one camera to another while viewing a scene. The first camera path is the default one provided by the JRViewer class, while the example constructs a second one. To run the application:
- Typing '1' toggles between the default camera and the moving camera,
- Typing '2' toggles between moving along the path and stopping.
Here's how it's done:
- The scene is created, based on a (2,3) torus knot.
- This curve is tubed to provide the geometry of the scene.
- A weave texture is applied to the tube.
- A separate node is used to represent a point moving along the curve.
- An instance of
javax.swing.Timeris used to move the point along.
- The necessary transformations are gotten from the frames used to tube the curve (which the tube factory provides upon request).
- The example uses a parallel frame field to minimize roll.
- An instance of
- Preparations are made to use a second camera path:
- An alternative camera and camera path is created, as a child of the moving point node.
- A single light is added as child of this new camera node.
- The lights of the default scene are collected into a list.
- A key listener is added to the Java viewing component of the Viewer.
- When the '1' key is typed, this listener toggles between the two camera paths.
- When the default camera path is used, the moving point is represented by a geometric representation of a coordinate frame, moving along the curve.
- When the camera attached to the moving point is used, the viewer presents a roller-coaster view of the motion.
- Lights are toggled so that each camera has its own illumination.
The following images show the default camera path and the roller coaster camera path (the latter with lighting disabled).