The application in this chapter, Shooter3D, contains a gun (actually a
cone mounted on a cylinder) which fires a laser beam at the point on
the checkered floor clicked on by the user. The flight of the laser
beam (actually a red cylinder) is accompanied by a suitable sound,
and followed by an explosion (an animated series of images and another
sound).
There are three screenshots of Shooter3D on this page. The first one has
the laser beam in mid-flight, the second captures the explosion, and the
third is another explosion after the user has clicked on a different
part of the floor, from a different viewpoint.
Note how the cone head rotates to aim at the target point. Also,
the animated explosion always faces the user's viewpoint.
Java 3D and Java features illustrated by this example:
the user's clicking on the floor is dealt with by Java 3D picking;
the laser beam and explosion sounds are PointSound objects;
the rotations of the cone and the laser beam are handled by
AxisAngle4d objects;
the explosion visual is created with our ImagesSeries class,
which simplifies the loading and displaying of a sequence of
transparent GIFs as an animation;
the delivery of the laser beam, and subsequent explosion, are managed
by a FireBeam thread, showing how Java threads and the built-in
threading of Java 3D can co-exist;
the overall complexity of this application is greatly reduced by
using OO design principles -- each of the main entities (the gun,
the laser beam, the explosion) are represented by its own class.