LaserShot object creates and manipulates a subgraph holding a beam (a thin red cylinder) and explosion (an animation laid over a quad). The subgraph shown in Figure 24-6 is created by
Figure 24-6. Scenegraph branch for LaserShot
beamTG, moves the beam (and explosion), and the
Switch allows the beam, explosion, or nothing to be displayed. The
beamDir TransformGroup initially positions and orients the cylinder so it's pointing into the scene and appears close to the nozzle of the gun image.
The cylinder has a radius of 0.05 units and a height of 0.5; it's rotated by 90 degrees, moved down by 0.3, and into the scene by 0.25 units. This means that the center of its tail is located at (0, -0.3, 0) relative to the coordinate space of
class is almost identical to the
ImagesSeries class in Chapter 23. The two differences are:
The object doesn't load its own GIFs. Instead, an array of
ImageComponent2D objects is passed to it in the constructor.
The shape's position is specified with a center point.
The call to
ImageCsSeries's constructor is carried out in
// create explosion, centered at (0,0,0), size 2.0f explShape = new ImageCsSeries( new Point3f(), 2.0f, exploIms);
The explosion is a child of the same
TransformGroup as the beam (
beamTG), so placing its center at (0, 0, 0) will make it appear ...