Managing the Ammunition


Initializing the User's Viewpoint

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(  ) 



Killer Game Programming in Java
Killer Game Programming in Java
ISBN: 0596007302
EAN: 2147483647
Year: 2006
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net