Java Reference
In-Depth Information
Obviously, Image B rendered with antialiasing appears smoother and looks better than
Image A. This is because when a slanted line is drawn on a computer screen with limited
resolution, it will actually be painted in a series of “steps” as shown in Figure 5. While
this “aliasing” effect cannot be eliminated, the line will appear smoother if the graphic
engine invokes an antialiasing process to paint adjacent pixels using some appropriate
intermediate color or brightness.
pointattributes
Beginning with PointAttributes, we will now start to discuss the important NodeComponent
classes and illustrate how they can be used through some simple examples. Of course, for
Figure 6. Code segment PointAttributesExample1.java and result, illustrating PointAt-
tributes
1. // create a PointAttributes with point width = size
2. public class aPoint extends Shape3D {
3.
4. public aPoint(float xo, float yo, float zo, float size ) {
5.
this.setGeometry(createPoint(xo, yo, zo));
6.
this.setAppearance(createPointApp(size));
7. }
8.
9. private Geometry createPoint(float x, float y, float z) {
10.
// x, y, z are (x, y, z) coordinate of the point
11.
PointArray pt = new PointArray(1, GeometryArray.COORDINATES);
12.
pt.setCoordinate(0, new Point3f(x, y, z));
13.
return pt;
14. }
15.
16. private Appearance createPointApp(float size) {
17. Appearance app = new Appearance();
18. // and Point antialiasing = false
19. PointAttributes pointAtt = new PointAttributes(size, false);
20.
app.setPointAttributes(pointAtt);
21.
return app;
22. }
23.
24. }
25.
26. public BranchGroup createSceneGraph() {
27. BranchGroup objRoot = new BranchGroup();
28. // add more point here with different coordinates and point width
29. objRoot.addChild(new aPoint(0.3f, 0.4f, 0.0f, 4f));
30. objRoot.addChild(new aPoint(0.4f, -0.3f, 0.0f, 8f));
31. objRoot.addChild(new aPoint(-0.2f, 0.6f, 0.0f, 20f));
32. objRoot.compile();
33.
return objRoot;
34. }
Search WWH ::




Custom Search