Java Reference
In-Depth Information
Figure 14. Code segment and result of PolygonAttributesExample2.java
1.
public class AppearancePOLYGON_POINT extends Applet
2. {
3. public class Letter_E extends Shape3D
4. {
5.
int vertex = 4;
6.
//constructor
7.
public Letter_E()
8.
{
9.
this.setGeometry(Quad1Geometry());
10.
this.addGeometry(Quad2Geometry());
11.
this.addGeometry(Quad3Geometry());
12.
this.addGeometry(Quad4Geometry());
13.
this.setAppearance(Letter_E_Appearance());
14. }
15. private Appearance Letter_E_Appearance()
16. {
17.
Appearance look = new Appearance();
18.
PolygonAttributes polyAttrib = new PolygonAttributes();
19.
//use only the vertices to render the object
20.
polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_POINT);
21.
//to make both sides of the face appear
22.
polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
23.
look.setPolygonAttributes(polyAttrib);
24.
return look;
25. }
Figure 15. Results from PolygonAttributesExample2.java after changing POLYGON_POINT
to POLYGON_LINE (left) and POLYGON_FILL (right)
Search WWH ::




Custom Search