May 2005
Intermediate to advanced
998 pages
26h
English
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
}
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 ...