Java Reference
In-Depth Information
renderingattributes
RenderingAttributes controls how a graphical object will be rendered. It is best illustrated
by using the code segment in Figures 20 and 21.
The code segment in lines 34 to 37 give rise to the instantiation of a new RenderingAt-
tribute object, using which two different per-pixel rendering operations, the depth buffer
test and the alpha test, can be controlled. As can be seen from the result in Figure 21 for
this case when the rendering attributes are at their default values, the three rectangles are
intercepted and partially blocked by the sphere.
The result of changing the first two rendering parameters, depthBufferEnable and dep-
thBufferWriteEnable, in the rendering attribute constructor from true to false is shown in
Figure 22. As can be seen, the parts of the rectangles that are behind and originally blocked
have become visible and no longer blocked. This is because there is now no comparison
Figure 20. First segment of render.java
1.
public class rectangle extends Shape3D
2.
{
3.
public rectangle()
4.
{
5.
this.setGeometry(CreateGeometry(0.0f, 0.8f));
6.
this.addGeometry(CreateGeometry(0.2f, 1.0f));
7.
this.addGeometry(CreateGeometry(-0.2f, 0.3f));
8.
this.setAppearance(CreateApp());
9.
}
10.
11. private Geometry CreateGeometry(float z, float alpha)
12. {
13. QuadArray rect = new
14. QuadArray(4,QuadArray.COORDINATES|QuadArray.COLOR_4);
15.
rect.setCoordinate(0,new Point3f(-0.5f, 0.2f,z));
16.
rect.setCoordinate(1,new Point3f(-0.5f, -0.2f,z));
17.
rect.setCoordinate(2,new Point3f(0.5f, -0.2f,z));
18.
rect.setCoordinate(3,new Point3f(0.5f, 0.2f,z));
19.
20.
Color4f yellow = new Color4f(1.0f,1.0f,0.0f,alpha);
21.
22.
rect.setColor(0,yellow);
23.
rect.setColor(1,yellow);
24.
rect.setColor(2,yellow);
25.
rect.setColor(3,yellow);
26.
return rect;
27.
}
28.
Search WWH ::




Custom Search