May 2005
Intermediate to advanced
998 pages
26h
English
WrapShooter3D calls initUserControls() to configure the viewpoint. The method carries out four main tasks:
Sets up the user's gun-in-hand image
Positions the user's initial viewpoint
Calls AmmoManager to prepare beams and explosions
Creates a KeyBehavior object to process keyboard input
The initUserControls() method is:
private void initUserControls(Vector3d targetVec)
{
// add a 'gun in hand' image to the viewpoint
ViewingPlatform vp = su.getViewingPlatform();
PlatformGeometry pg = gunHand();
vp.setPlatformGeometry(pg);
// position starting viewpoint
TransformGroup steerTG = vp.getViewPlatformTransform();
Transform3D t3d = new Transform3D();
steerTG.getTransform( t3d );
t3d.setTranslation( new Vector3d(0, 1, Z_START) );
steerTG.setTransform(t3d);
// create ammo (beams and explosions)
AmmoManager ammoMan = new AmmoManager(steerTG, sceneBG, targetVec);
// set up keyboard controls
KeyBehavior keyBeh = new KeyBehavior( ammoMan );
// keyBeh can ask the ammoManager to fire a beam
keyBeh.setSchedulingBounds(bounds);
vp.setViewPlatformBehavior(keyBeh);
} // end of initUserControls()