PageRenderTime 14ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/vision/opengl/cube.e

http://github.com/tybor/Liberty
Specman e | 53 lines | 40 code | 13 blank | 0 comment | 0 complexity | e18b459310e6cb40bd7688e0bb8a835b MD5 | raw file
 1class CUBE
 2
 3inherit
 4	GL_OBJECT
 5
 6creation
 7	make_at_origin, make_with_position
 8
 9feature{ANY}
10	build is
11		do
12			create vertices.make(8)
13			vertices.put(create {VERTEX}.make_with_color_object(-1, 1, 1, full_red), 0)
14			vertices.put(create {VERTEX}.make_with_color_object(-1, -1, 1, full_red), 1)
15			vertices.put(create {VERTEX}.make_with_color_object(1, -1, 1, full_green), 2)
16			vertices.put(create {VERTEX}.make_with_color_object(1, 1, 1, full_green), 3)
17			vertices.put(create {VERTEX}.make_with_color_object(1, 1, -1, full_blue), 4)
18			vertices.put(create {VERTEX}.make_with_color_object(-1, 1, -1, full_blue), 5)
19			vertices.put(create {VERTEX}.make_with_color_object(-1, -1, -1, full_magenta), 6)
20			vertices.put(create {VERTEX}.make_with_color_object(1, -1, -1, full_magenta), 7)
21			
22			facets.add_last(create {FACET}.make(vertices.item(0), vertices.item(1), vertices.item(3)))
23			facets.add_last(create {FACET}.make(vertices.item(1), vertices.item(2), vertices.item(3)))
24
25			facets.add_last(create {FACET}.make(vertices.item(3), vertices.item(2), vertices.item(4)))
26			facets.add_last(create {FACET}.make(vertices.item(2), vertices.item(7), vertices.item(4)))
27			
28			facets.add_last(create {FACET}.make(vertices.item(5), vertices.item(6), vertices.item(0)))
29			facets.add_last(create {FACET}.make(vertices.item(6), vertices.item(1), vertices.item(0)))
30			
31			facets.add_last(create {FACET}.make(vertices.item(5), vertices.item(0), vertices.item(4)))
32			facets.add_last(create {FACET}.make(vertices.item(0), vertices.item(3), vertices.item(4)))
33			
34			facets.add_last(create {FACET}.make(vertices.item(1), vertices.item(6), vertices.item(2)))
35			facets.add_last(create {FACET}.make(vertices.item(6), vertices.item(7), vertices.item(2)))
36			
37			facets.add_last(create {FACET}.make(vertices.item(4), vertices.item(7), vertices.item(5)))
38			facets.add_last(create {FACET}.make(vertices.item(7), vertices.item(6), vertices.item(5)))
39
40			set_scale(1.5, 0.5, 0.75)
41		end
42
43	turn(ang_x, ang_y : REAL) is
44		do
45			set_pitch(ang_x)
46			set_heading(ang_y)
47		end
48
49feature {}
50	angle_x, angle_y : REAL
51	vertices: FAST_ARRAY[VERTEX]
52
53end