In Chapter 23, we developed an application containing a stand-alone gun that shot laser beams. This chapter continues the peace-loving theme, so common in games programming, by putting a gun into the user's hand, and allowing him/her to do the shooting. This type of game, typified by Doom and Quake, is called a first-person shooter (FPS).
This page has two screenshots for the FPShooter3D application: the first has the user strafing a robot -- only laser beams that come close enough to the robot explode. The second screenshot shows a similar scene after the user has 'sneaked' behind and close to the robot.
A laser beam that misses the target vanishes after travelling a certain distance. To simplify the coding a little, no sounds are played. Also, the explosions do no 'harm' to the robot, who just keeps standing there.
Java 3D and Java features illustrated by this example:
This chapter reuses (or slightly changes) the techniques of Chapter 23 for creating the laser beams (thin red cylinders) and the animated explosions, so it's advisable to read that chapter before this one.
On Linux, there are case-insensitivity problems when loading some files. For example, the code refers to "Coolrobo.3ds". but the file is actually called "COOLROBO.3DS". The case difference doesn't matter on Windows. On Linux, it triggers an error message about the file not being found.
The fix is to change the name of the file so its case matches that used in the code (e.g. rename "COOLROBO.3DS" to "Coolrobo.3ds"). There's no need to modify the Java code.