Picking Scene Objects


Scene Creation

WrapShooter3D's createSceneGraph( ) calls makeGun( ) to initialize various elements:

     private void makeGun(Canvas3D canvas3D)     { // starting vector for the gun cone and beam       Vector3d startVec = new Vector3d(0, 2, 0);           // the gun       GunTurret gun = new GunTurret(startVec);       sceneBG.addChild( gun.getGunBG(  ) );           // explosion and sound       PointSound explPS = initSound("Explo1.wav");       ExplosionsClip expl = new ExplosionsClip( startVec, explPS);       sceneBG.addChild( expl.getExplBG(  ) );           // laser beam and sound       PointSound beamPS = initSound("laser2.wav");       LaserBeam laser = new LaserBeam( startVec, beamPS);       sceneBG.addChild( laser.getBeamBG(  ) );           // the behavior that controls the shooting       ShootingBehaviour shootBeh =           new ShootingBehaviour(canvas3D, sceneBG, bounds,                         new Point3d(0,2,0), expl, laser, gun );       sceneBG.addChild(shootBeh);     } // end of makeGun(  ) 

The position vector of the gun cone is hardwired to be (0, 2, 0). The same vector is used to place the laser beam (a red cylinder) inside the cone. The hardwiring makes the coding easier and highlights a major simplification of this example: the base of the gun doesn't move.



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