< Zurück | Inhalt | Weiter >


The time taken to render a point (at least without hardware acceleration) is proportional to the size of the point in pixels.

Note that a single point, when antialiased, approximates a sphere, in that it is never possible to view the point “edge−on” as a disc. When points are rendered without antialiasing, the point approximates a cube with each front face always perpendicular to the viewer. Figures 9.10 and 9.11 illustrate.


Figure 9.10 When rotated, antialiased points appear as spheres


Figure 9.11 When rotated, nonantialiased points appear as squares aligned with the viewer

The figures are taken from the PointTest.java example. The example defines the points to be rendered, as well as Appearances, as follows:

//create a BranchGroup containing an nNumPoints x nNumPoints

//array of points

//the size of the points is set to nPointSize and antialiasing

//is set to bAliased

private BranchGroup createPoints( final int nPointSize, final int nNumPoints, boolean bAliased )


BranchGroup bg = new BranchGroup();

//create a Text3D label describing the points String szText = new String();

szText += ( nNumPoints + "X, Size:" + nPointSize + ", aliased: "

+ bAliased );

Font3D f3d = new Font3D( new Font( "SansSerif", Font.PLAIN, 1), new FontExtrusion() );

Text3D label3D = new Text3D( f3d, szText, new Point3f(−5,0,0) ); Shape3D sh = new Shape3D( label3D );

bg.addChild( sh );

//create the PointArray used to hold the geometry for the points PointArray pointArray = new PointArray( nNumPoints * nNumPoints,

GeometryArray.COORDINATES | GeometryArray.COLOR_3 );

//populate the PointArray that we will be rendering int nPoint = 0;

final double factor = 1.0 / nNumPoints;

for( int n = 0; n <nNumPoints; n++ )


for( int i = 0; i <nNumPoints; i++ )


Point3f point = new Point3f( n − nNumPoints/2,

i − nNumPoints/2, 0.0f ); pointArray.setCoordinate( nPoint, point ); pointArray.setColor( nPoint++,

new Color3f( 0.5f, (float) (n * factor), (float) (i * factor) ) );



//create the Appearance for the points Appearance pointApp = new Appearance();

//enlarge the points and set antialiasing pointApp.setPointAttributes( new PointAttributes

( nPointSize, bAliased ) );

//create a Shape3D for the PointArray and assign the appearance Shape3D pointShape = new Shape3D( pointArray, pointApp );

//add the Shape3D to the BranchGroup and return bg.addChild( pointShape );

return bg;