Java Reference
In-Depth Information
Figure 12. Third code segment of House_Quad_Array.java
51.
`
//front rectangle
52.
new Point3f(midleft), new Point3f (botleft),
53.
new Point3f (botright), new Point3f (midright),
54.
55.
//left trapezium
56.
new Point3f(btopleft), new Point3f (bmidleft),
57.
new Point3f(midleft), new Point3f (topleft),
58.
59.
//right trapezium
60.
new Point3f (topright),new Point3f (midright),
61.
new Point3f (bmidright),new Point3f (btopright),
62.
63.
//back rectangle
64.
new Point3f(bmidleft), new Point3f (bbotleft),
65.
new Point3f (bbotright), new Point3f (bmidright)
66.
};
67.
68.
//define new QuadArray with the above vertices
69.
QuadArray House_struct = new QuadArray(coords.length, QuadArray.COORDINATES);
70.
71.
//coordinates will be filled starting from vertex 0
72.
House_struct.setCoordinates(0, coords);
73.
74.
return House_struct;
75.
76.
} // end of Draw_house method
77.
78.
private Appearance App()
79.
{
80.
Color3f lime = new Color3f(0.0f,2.0f,1.0f);
81.
Appearance look = new Appearance();
82.
ColoringAttributes ca = new ColoringAttributes(lime, ColoringAttributes.FASTEST);
83.
LineAttributes la = new LineAttributes(3, LineAttributes.PATTERN_SOLID, false);
84.
PolygonAttributes pa = new PolygonAttributes();
85.
86.
//to make no fill, only the frame
87.
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
88.
89.
//to make both sides of the face appear
90.
pa.setCullFace(PolygonAttributes.CULL_NONE);
to define the geometry of the created House object. In the same way, the setAppearance()
and App() methods are used to define the appearance of the object.
Lines 39 to 66 give the coordinates of 12 vertices for the object, based on which a
Point3f array is created and initialized using relevant combinations of the coordinates of
Search WWH ::




Custom Search