Skip to Main Content
Killer Game Programming in Java
book

Killer Game Programming in Java

by Andrew Davison
May 2005
Intermediate to advanced content levelIntermediate to advanced
998 pages
26h
English
O'Reilly Media, Inc.
Content preview from Killer Game Programming in Java

Creating the Scene

The WrapParticles3D object is passed two integers from the command line: the number of points to be used when creating a particle system and an integer between 1 and 3, which selects a particular system. The selection is done inside the createSceneGraph() method:

    switch(fountainChoice) {
      case 1: addPointsFountain(numParts); break;
      case 2: addLinesFountain(numParts); break;
      case 3: addQuadFountain(numParts); break;
      default: break;   // do nothing
    }
The Particles3D classes

Figure 21-5. The Particles3D classes

The three particle systems all render variants of a fountain, which explains the prevalence of the word "fountain." The three addFountain() methods are similar, with addPointsFountain() the longest:

    private void addPointsFountain(int numParts)
    {
      PointParticles ptsFountain = new PointParticles(numParts, 20);  
      // 20ms time delay between updates
   
      // move particles start position to (2,0,1)
      TransformGroup posnTG = new TransformGroup();
      Transform3D trans = new Transform3D();
      trans.setTranslation( new Vector3d(2.0f, 0.0f, 1.0f) );
      posnTG.setTransform(trans);
      posnTG.addChild(ptsFountain);
      sceneBG.addChild( posnTG );
   
      // timed behavior to animate the fountain
      Behavior partBeh = ptsFountain.getParticleBeh();
      partBeh.setSchedulingBounds( bounds );
      sceneBG.addChild(partBeh);
    }

The particle system (together with its GeometryUpdater and Behavior objects) is created by the PointParticles() constructor, which ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Game Development with LibGDX: From Beginner to Professional

Java Game Development with LibGDX: From Beginner to Professional

Lee Stemkoski

Publisher Resources

ISBN: 0596007302Supplemental ContentErrata Page