Controlling the Gun
The GunTurret
class builds the scene graph branch for the cylinder and cone and has two public methods: getGunBG() and makeRotation(). getGunBG() is used by WrapShooter3D to retrieve a reference to the gun's top-level BranchGroup, gunBG, so it can be added to the scene. makeRotation() is called by ShootingBehaviour to rotate the cone to point at the clicked position.
The scene graph branch built inside GunTurret is shown in Figure 23-4.
The GunTurret constructor is:
public GunTurret(Vector3d svec)
{ startVec = svec;
gunBG = new BranchGroup();
Appearance apStone = stoneApp();
placeGunBase(apStone);
placeGun(apStone);
}
startVec contains the position of the gun cone: (0, 2, 0).

Figure 23-4. Scenegraph branch for GunTurret
Tip
There's no particular significance to this coordinate, but it works well, so I've stayed with it.
apStone is a blending of a stone texture and white material, with lighting enabled, which allows lighting effects to be seen on the gun's surfaces. The blending is done using the TextureAttribute.MODULATE setting for the texture mode.
Tip
A similar approach was used in Chapter 21 for the texture applied to the particle system of quads.
placeGunBase() creates the lefthand side of the subgraph shown in Figure 23-4, and placeGun() handles the right side.
The cylinder and cone are unpickable (you only want the gun to shoot at the tiles):
cyl.setPickable(false); ...