The user's viewpoint (sometimes called the application camera) is positioned by the view branch part of the scene graph; its main elements are shown in Figure 24-3.
Figure 24-3. The view branch subgraph
You haven't seen the view branch much up to now since it's been built automatically when I've used the
SimpleUniverse utility class to create the scene graph. However, I need to attach the gun-in-hand image to the viewpoint and move it around in response to user key presses.
The viewpoint is represented by the
ViewPlatform node in Figure 24-3 (the triangle) and is repositioned by applying transforms to the TG node above it (TG is short for
TransformGroup). It's possible to add extra
TransformGroups above the
ViewPlatform node to implement more complex forms of movements, but I don't need to do that in this example.
A shape is attached to the viewpoint by storing it in a Java 3D
PlatformGeometry node and connecting it to the
TransformGroup above the
ViewPlatform. This is the how I'll place the gun-in-hand image in front of the viewpoint.
SimpleUniverse offers access to the view branch via several utility classes:
PlatformGeometry, and others. You've seen
ViewingPlatform used several times to move the viewer's starting position.
Java 3D contains several classes that can affect the viewpoint. In previous ...