Java Reference
In-Depth Information
Figure 11. Second code segment of House_Quad_Array.java
11. private Geometry Draw_House()
12. {
13. //constants for the front
14. float fz = 0.5f;
15. float tx = 0.25f;
16. float ty = 0.6f;
17. float mx = 0.5f;
18. float my = 0.2f;
19. float bz = -0.6f;
20.
21. // coordinates for the six common vertices
22.
Vector3f topleft = new Vector3f(-tx,ty,fz);
23.
Vector3f midleft = new Vector3f(-mx,my,fz);
24.
Vector3f botleft = new Vector3f(-mx,-ty,fz);
25.
26.
Vector3f topright = new Vector3f(tx,ty,fz);
27.
Vector3f midright = new Vector3f(mx,my,fz);
28.
Vector3f botright = new Vector3f(mx,-ty,fz);
29.
30.
Vector3f btopleft = new Vector3f(-tx,ty,bz);
31.
Vector3f bmidleft = new Vector3f(-mx,my,bz);
32.
Vector3f bbotleft = new Vector3f(-mx,-ty,bz);
33.
34.
Vector3f btopright = new Vector3f(tx,ty,bz);
35.
Vector3f bmidright = new Vector3f(mx,my,bz);
36.
Vector3f bbotright = new Vector3f(mx,-ty,bz);
37.
38. // define a Point3f array to store the coordinates of the vertices
39. Point3f[] coords =
40.
{ //front trapezium
41.
new Point3f(topleft), new Point3f (midleft),
42.
new Point3f (midright), new Point3f (topright),
43.
44. //back trapezium
45. new Point3f(btopleft), new Point3f (bmidleft),
46. new Point3f (bmidright), new Point3f (btopright),
47.
48. //bottom rectangle
49.
new Point3f(botleft), new Point3f (botright),
50.
51. new Point3f (bbotright), new Point3f (bbotleft),
52.
Specifically, lines 5 to 10 correspond to the constructor for the House class, which in-
vokes two private methods, Draw_House() and App(). As the House class is an extension
of the Shape3D class, the setGeometry() method in Shape3D is used with Draw_House()
Search WWH ::




Custom Search