cyberarm_engine 0.19.0 → 0.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -8
  3. data/.rubocop.yml +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +6 -6
  6. data/LICENSE.txt +21 -21
  7. data/README.md +74 -74
  8. data/Rakefile +10 -10
  9. data/bin/console +14 -14
  10. data/bin/setup +8 -8
  11. data/cyberarm_engine.gemspec +39 -39
  12. data/lib/cyberarm_engine/animator.rb +219 -219
  13. data/lib/cyberarm_engine/background.rb +179 -179
  14. data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
  15. data/lib/cyberarm_engine/bounding_box.rb +150 -150
  16. data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
  17. data/lib/cyberarm_engine/cache/download_manager.rb +121 -121
  18. data/lib/cyberarm_engine/cache.rb +4 -4
  19. data/lib/cyberarm_engine/common.rb +113 -113
  20. data/lib/cyberarm_engine/config_file.rb +46 -46
  21. data/lib/cyberarm_engine/console/command.rb +157 -157
  22. data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
  23. data/lib/cyberarm_engine/console/subcommand.rb +99 -99
  24. data/lib/cyberarm_engine/console.rb +248 -248
  25. data/lib/cyberarm_engine/game_object.rb +248 -248
  26. data/lib/cyberarm_engine/game_state.rb +97 -97
  27. data/lib/cyberarm_engine/model/material.rb +21 -21
  28. data/lib/cyberarm_engine/model/model_object.rb +131 -131
  29. data/lib/cyberarm_engine/model/parser.rb +74 -74
  30. data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
  31. data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
  32. data/lib/cyberarm_engine/model.rb +212 -212
  33. data/lib/cyberarm_engine/model_cache.rb +31 -31
  34. data/lib/cyberarm_engine/opengl/light.rb +50 -50
  35. data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
  36. data/lib/cyberarm_engine/opengl/perspective_camera.rb +38 -38
  37. data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
  38. data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +164 -164
  39. data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +298 -298
  40. data/lib/cyberarm_engine/opengl/renderer/renderer.rb +22 -22
  41. data/lib/cyberarm_engine/opengl/shader.rb +406 -406
  42. data/lib/cyberarm_engine/opengl/texture.rb +69 -69
  43. data/lib/cyberarm_engine/opengl.rb +28 -28
  44. data/lib/cyberarm_engine/ray.rb +56 -56
  45. data/lib/cyberarm_engine/stats.rb +21 -21
  46. data/lib/cyberarm_engine/text.rb +197 -197
  47. data/lib/cyberarm_engine/timer.rb +23 -23
  48. data/lib/cyberarm_engine/transform.rb +296 -296
  49. data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
  50. data/lib/cyberarm_engine/ui/dsl.rb +139 -139
  51. data/lib/cyberarm_engine/ui/element.rb +488 -488
  52. data/lib/cyberarm_engine/ui/elements/button.rb +97 -97
  53. data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
  54. data/lib/cyberarm_engine/ui/elements/container.rb +256 -256
  55. data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
  56. data/lib/cyberarm_engine/ui/elements/edit_line.rb +263 -263
  57. data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
  58. data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
  59. data/lib/cyberarm_engine/ui/elements/list_box.rb +88 -82
  60. data/lib/cyberarm_engine/ui/elements/progress.rb +51 -51
  61. data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
  62. data/lib/cyberarm_engine/ui/elements/slider.rb +104 -104
  63. data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
  64. data/lib/cyberarm_engine/ui/elements/text_block.rb +162 -162
  65. data/lib/cyberarm_engine/ui/elements/toggle_button.rb +65 -65
  66. data/lib/cyberarm_engine/ui/event.rb +54 -54
  67. data/lib/cyberarm_engine/ui/gui_state.rb +256 -256
  68. data/lib/cyberarm_engine/ui/style.rb +49 -49
  69. data/lib/cyberarm_engine/ui/theme.rb +207 -207
  70. data/lib/cyberarm_engine/vector.rb +293 -293
  71. data/lib/cyberarm_engine/version.rb +4 -4
  72. data/lib/cyberarm_engine/window.rb +120 -120
  73. data/lib/cyberarm_engine.rb +71 -71
  74. metadata +3 -3
@@ -1,38 +1,38 @@
1
- module CyberarmEngine
2
- class PerspectiveCamera
3
- attr_accessor :position, :orientation, :aspect_ratio, :field_of_view,
4
- :min_view_distance, :max_view_distance
5
-
6
- def initialize(position:, aspect_ratio:, orientation: Vector.new(0, 0, 0),
7
- field_of_view: 70.0, min_view_distance: 0.1, max_view_distance: 1024.0)
8
- @position = position
9
- @orientation = orientation
10
-
11
- @aspect_ratio = aspect_ratio
12
- @field_of_view = field_of_view
13
-
14
- @min_view_distance = min_view_distance
15
- @max_view_distance = max_view_distance
16
- end
17
-
18
- def draw
19
- glMatrixMode(GL_PROJECTION)
20
- glLoadIdentity
21
- gluPerspective(@field_of_view, @aspect_ratio, @min_view_distance, @max_view_distance)
22
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
23
- glRotatef(@orientation.x, 1, 0, 0)
24
- glRotatef(@orientation.y, 0, 1, 0)
25
- glTranslatef(-@position.x, -@position.y, -@position.z)
26
- glMatrixMode(GL_MODELVIEW)
27
- glLoadIdentity
28
- end
29
-
30
- def projection_matrix
31
- Transform.perspective(@field_of_view, @aspect_ratio, @min_view_distance, @max_view_distance)
32
- end
33
-
34
- def view_matrix
35
- Transform.translate_3d(@position * -1) * Transform.rotate_3d(@orientation)
36
- end
37
- end
38
- end
1
+ module CyberarmEngine
2
+ class PerspectiveCamera
3
+ attr_accessor :position, :orientation, :aspect_ratio, :field_of_view,
4
+ :min_view_distance, :max_view_distance
5
+
6
+ def initialize(position:, aspect_ratio:, orientation: Vector.new(0, 0, 0),
7
+ field_of_view: 70.0, min_view_distance: 0.1, max_view_distance: 1024.0)
8
+ @position = position
9
+ @orientation = orientation
10
+
11
+ @aspect_ratio = aspect_ratio
12
+ @field_of_view = field_of_view
13
+
14
+ @min_view_distance = min_view_distance
15
+ @max_view_distance = max_view_distance
16
+ end
17
+
18
+ def draw
19
+ glMatrixMode(GL_PROJECTION)
20
+ glLoadIdentity
21
+ gluPerspective(@field_of_view, @aspect_ratio, @min_view_distance, @max_view_distance)
22
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
23
+ glRotatef(@orientation.x, 1, 0, 0)
24
+ glRotatef(@orientation.y, 0, 1, 0)
25
+ glTranslatef(-@position.x, -@position.y, -@position.z)
26
+ glMatrixMode(GL_MODELVIEW)
27
+ glLoadIdentity
28
+ end
29
+
30
+ def projection_matrix
31
+ Transform.perspective(@field_of_view, @aspect_ratio, @min_view_distance, @max_view_distance)
32
+ end
33
+
34
+ def view_matrix
35
+ Transform.translate_3d(@position * -1) * Transform.rotate_3d(@orientation)
36
+ end
37
+ end
38
+ end
@@ -1,249 +1,249 @@
1
- module CyberarmEngine
2
- class BoundingBoxRenderer
3
- attr_reader :bounding_boxes, :vertex_count
4
-
5
- def initialize
6
- @bounding_boxes = {}
7
- @vertex_count = 0
8
- end
9
-
10
- def render(entities)
11
- entities.each do |entity|
12
- create_bounding_box(entity, color = nil)
13
- draw_bounding_boxes
14
- end
15
-
16
- (@bounding_boxes.keys - entities.map { |e| e.object_id }).each do |key|
17
- @bounding_boxes.delete(key)
18
- end
19
- end
20
-
21
- def create_bounding_box(entity, color = nil)
22
- color ||= entity.debug_color
23
- entity_id = entity.object_id
24
-
25
- if @bounding_boxes[entity_id]
26
- if @bounding_boxes[entity_id][:color] != color
27
- @bounding_boxes[entity_id][:colors] = mesh_colors(color).pack("f*")
28
- @bounding_boxes[entity_id][:color] = color
29
- return
30
- else
31
- return
32
- end
33
- end
34
-
35
- @bounding_boxes[entity_id] = {
36
- entity: entity,
37
- color: color,
38
- objects: []
39
- }
40
-
41
- box = entity.normalize_bounding_box
42
-
43
- normals = mesh_normals
44
- colors = mesh_colors(color)
45
- vertices = mesh_vertices(box)
46
-
47
- @vertex_count += vertices.size
48
-
49
- @bounding_boxes[entity_id][:vertices_size] = vertices.size
50
- @bounding_boxes[entity_id][:vertices] = vertices.pack("f*")
51
- @bounding_boxes[entity_id][:normals] = normals.pack("f*")
52
- @bounding_boxes[entity_id][:colors] = colors.pack("f*")
53
-
54
- entity.model.objects.each do |mesh|
55
- data = {}
56
- box = mesh.bounding_box.normalize(entity)
57
-
58
- normals = mesh_normals
59
- colors = mesh_colors(mesh.debug_color)
60
- vertices = mesh_vertices(box)
61
-
62
- @vertex_count += vertices.size
63
-
64
- data[:vertices_size] = vertices.size
65
- data[:vertices] = vertices.pack("f*")
66
- data[:normals] = normals.pack("f*")
67
- data[:colors] = colors.pack("f*")
68
-
69
- @bounding_boxes[entity_id][:objects] << data
70
- end
71
- end
72
-
73
- def mesh_normals
74
- [
75
- 0, 1, 0,
76
- 0, 1, 0,
77
- 0, 1, 0,
78
- 0, 1, 0,
79
- 0, 1, 0,
80
- 0, 1, 0,
81
-
82
- 0, -1, 0,
83
- 0, -1, 0,
84
- 0, -1, 0,
85
- 0, -1, 0,
86
- 0, -1, 0,
87
- 0, -1, 0,
88
-
89
- 0, 0, 1,
90
- 0, 0, 1,
91
- 0, 0, 1,
92
- 0, 0, 1,
93
- 0, 0, 1,
94
- 0, 0, 1,
95
-
96
- 1, 0, 0,
97
- 1, 0, 0,
98
- 1, 0, 0,
99
- 1, 0, 0,
100
- 1, 0, 0,
101
- 1, 0, 0,
102
-
103
- -1, 0, 0,
104
- -1, 0, 0,
105
- -1, 0, 0,
106
- -1, 0, 0,
107
- -1, 0, 0,
108
- -1, 0, 0,
109
-
110
- -1, 0, 0,
111
- -1, 0, 0,
112
- -1, 0, 0,
113
-
114
- -1, 0, 0,
115
- -1, 0, 0,
116
- -1, 0, 0
117
- ]
118
- end
119
-
120
- def mesh_colors(color)
121
- [
122
- color.red, color.green, color.blue,
123
- color.red, color.green, color.blue,
124
- color.red, color.green, color.blue,
125
- color.red, color.green, color.blue,
126
- color.red, color.green, color.blue,
127
- color.red, color.green, color.blue,
128
- color.red, color.green, color.blue,
129
- color.red, color.green, color.blue,
130
- color.red, color.green, color.blue,
131
- color.red, color.green, color.blue,
132
- color.red, color.green, color.blue,
133
- color.red, color.green, color.blue,
134
- color.red, color.green, color.blue,
135
- color.red, color.green, color.blue,
136
- color.red, color.green, color.blue,
137
- color.red, color.green, color.blue,
138
- color.red, color.green, color.blue,
139
- color.red, color.green, color.blue,
140
- color.red, color.green, color.blue,
141
- color.red, color.green, color.blue,
142
- color.red, color.green, color.blue,
143
- color.red, color.green, color.blue,
144
- color.red, color.green, color.blue,
145
- color.red, color.green, color.blue,
146
- color.red, color.green, color.blue,
147
- color.red, color.green, color.blue,
148
- color.red, color.green, color.blue,
149
- color.red, color.green, color.blue,
150
- color.red, color.green, color.blue,
151
- color.red, color.green, color.blue,
152
- color.red, color.green, color.blue,
153
- color.red, color.green, color.blue,
154
- color.red, color.green, color.blue,
155
- color.red, color.green, color.blue,
156
- color.red, color.green, color.blue,
157
- color.red, color.green, color.blue
158
- ]
159
- end
160
-
161
- def mesh_vertices(box)
162
- [
163
- box.min.x, box.max.y, box.max.z,
164
- box.min.x, box.max.y, box.min.z,
165
- box.max.x, box.max.y, box.min.z,
166
-
167
- box.min.x, box.max.y, box.max.z,
168
- box.max.x, box.max.y, box.max.z,
169
- box.max.x, box.max.y, box.min.z,
170
-
171
- box.max.x, box.min.y, box.min.z,
172
- box.max.x, box.min.y, box.max.z,
173
- box.min.x, box.min.y, box.max.z,
174
-
175
- box.max.x, box.min.y, box.min.z,
176
- box.min.x, box.min.y, box.min.z,
177
- box.min.x, box.min.y, box.max.z,
178
-
179
- box.min.x, box.max.y, box.max.z,
180
- box.min.x, box.max.y, box.min.z,
181
- box.min.x, box.min.y, box.min.z,
182
-
183
- box.min.x, box.min.y, box.max.z,
184
- box.min.x, box.min.y, box.min.z,
185
- box.min.x, box.max.y, box.max.z,
186
-
187
- box.max.x, box.max.y, box.max.z,
188
- box.max.x, box.max.y, box.min.z,
189
- box.max.x, box.min.y, box.min.z,
190
-
191
- box.max.x, box.min.y, box.max.z,
192
- box.max.x, box.min.y, box.min.z,
193
- box.max.x, box.max.y, box.max.z,
194
-
195
- box.min.x, box.max.y, box.max.z,
196
- box.max.x, box.max.y, box.max.z,
197
- box.max.x, box.min.y, box.max.z,
198
-
199
- box.min.x, box.max.y, box.max.z,
200
- box.max.x, box.min.y, box.max.z,
201
- box.min.x, box.min.y, box.max.z,
202
-
203
- box.max.x, box.min.y, box.min.z,
204
- box.min.x, box.min.y, box.min.z,
205
- box.min.x, box.max.y, box.min.z,
206
-
207
- box.max.x, box.min.y, box.min.z,
208
- box.min.x, box.max.y, box.min.z,
209
- box.max.x, box.max.y, box.min.z
210
- ]
211
- end
212
-
213
- def draw_bounding_boxes
214
- @bounding_boxes.each do |key, bounding_box|
215
- glPushMatrix
216
-
217
- glTranslatef(
218
- bounding_box[:entity].position.x,
219
- bounding_box[:entity].position.y,
220
- bounding_box[:entity].position.z
221
- )
222
- draw_bounding_box(bounding_box)
223
- @bounding_boxes[key][:objects].each { |o| draw_bounding_box(o) }
224
-
225
- glPopMatrix
226
- end
227
- end
228
-
229
- def draw_bounding_box(bounding_box)
230
- glEnableClientState(GL_VERTEX_ARRAY)
231
- glEnableClientState(GL_COLOR_ARRAY)
232
- glEnableClientState(GL_NORMAL_ARRAY)
233
-
234
- glVertexPointer(3, GL_FLOAT, 0, bounding_box[:vertices])
235
- glColorPointer(3, GL_FLOAT, 0, bounding_box[:colors])
236
- glNormalPointer(GL_FLOAT, 0, bounding_box[:normals])
237
-
238
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
239
- glDisable(GL_LIGHTING)
240
- glDrawArrays(GL_TRIANGLES, 0, bounding_box[:vertices_size] / 3)
241
- glEnable(GL_LIGHTING)
242
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
243
-
244
- glDisableClientState(GL_VERTEX_ARRAY)
245
- glDisableClientState(GL_COLOR_ARRAY)
246
- glDisableClientState(GL_NORMAL_ARRAY)
247
- end
248
- end
249
- end
1
+ module CyberarmEngine
2
+ class BoundingBoxRenderer
3
+ attr_reader :bounding_boxes, :vertex_count
4
+
5
+ def initialize
6
+ @bounding_boxes = {}
7
+ @vertex_count = 0
8
+ end
9
+
10
+ def render(entities)
11
+ entities.each do |entity|
12
+ create_bounding_box(entity, color = nil)
13
+ draw_bounding_boxes
14
+ end
15
+
16
+ (@bounding_boxes.keys - entities.map { |e| e.object_id }).each do |key|
17
+ @bounding_boxes.delete(key)
18
+ end
19
+ end
20
+
21
+ def create_bounding_box(entity, color = nil)
22
+ color ||= entity.debug_color
23
+ entity_id = entity.object_id
24
+
25
+ if @bounding_boxes[entity_id]
26
+ if @bounding_boxes[entity_id][:color] != color
27
+ @bounding_boxes[entity_id][:colors] = mesh_colors(color).pack("f*")
28
+ @bounding_boxes[entity_id][:color] = color
29
+ return
30
+ else
31
+ return
32
+ end
33
+ end
34
+
35
+ @bounding_boxes[entity_id] = {
36
+ entity: entity,
37
+ color: color,
38
+ objects: []
39
+ }
40
+
41
+ box = entity.normalize_bounding_box
42
+
43
+ normals = mesh_normals
44
+ colors = mesh_colors(color)
45
+ vertices = mesh_vertices(box)
46
+
47
+ @vertex_count += vertices.size
48
+
49
+ @bounding_boxes[entity_id][:vertices_size] = vertices.size
50
+ @bounding_boxes[entity_id][:vertices] = vertices.pack("f*")
51
+ @bounding_boxes[entity_id][:normals] = normals.pack("f*")
52
+ @bounding_boxes[entity_id][:colors] = colors.pack("f*")
53
+
54
+ entity.model.objects.each do |mesh|
55
+ data = {}
56
+ box = mesh.bounding_box.normalize(entity)
57
+
58
+ normals = mesh_normals
59
+ colors = mesh_colors(mesh.debug_color)
60
+ vertices = mesh_vertices(box)
61
+
62
+ @vertex_count += vertices.size
63
+
64
+ data[:vertices_size] = vertices.size
65
+ data[:vertices] = vertices.pack("f*")
66
+ data[:normals] = normals.pack("f*")
67
+ data[:colors] = colors.pack("f*")
68
+
69
+ @bounding_boxes[entity_id][:objects] << data
70
+ end
71
+ end
72
+
73
+ def mesh_normals
74
+ [
75
+ 0, 1, 0,
76
+ 0, 1, 0,
77
+ 0, 1, 0,
78
+ 0, 1, 0,
79
+ 0, 1, 0,
80
+ 0, 1, 0,
81
+
82
+ 0, -1, 0,
83
+ 0, -1, 0,
84
+ 0, -1, 0,
85
+ 0, -1, 0,
86
+ 0, -1, 0,
87
+ 0, -1, 0,
88
+
89
+ 0, 0, 1,
90
+ 0, 0, 1,
91
+ 0, 0, 1,
92
+ 0, 0, 1,
93
+ 0, 0, 1,
94
+ 0, 0, 1,
95
+
96
+ 1, 0, 0,
97
+ 1, 0, 0,
98
+ 1, 0, 0,
99
+ 1, 0, 0,
100
+ 1, 0, 0,
101
+ 1, 0, 0,
102
+
103
+ -1, 0, 0,
104
+ -1, 0, 0,
105
+ -1, 0, 0,
106
+ -1, 0, 0,
107
+ -1, 0, 0,
108
+ -1, 0, 0,
109
+
110
+ -1, 0, 0,
111
+ -1, 0, 0,
112
+ -1, 0, 0,
113
+
114
+ -1, 0, 0,
115
+ -1, 0, 0,
116
+ -1, 0, 0
117
+ ]
118
+ end
119
+
120
+ def mesh_colors(color)
121
+ [
122
+ color.red, color.green, color.blue,
123
+ color.red, color.green, color.blue,
124
+ color.red, color.green, color.blue,
125
+ color.red, color.green, color.blue,
126
+ color.red, color.green, color.blue,
127
+ color.red, color.green, color.blue,
128
+ color.red, color.green, color.blue,
129
+ color.red, color.green, color.blue,
130
+ color.red, color.green, color.blue,
131
+ color.red, color.green, color.blue,
132
+ color.red, color.green, color.blue,
133
+ color.red, color.green, color.blue,
134
+ color.red, color.green, color.blue,
135
+ color.red, color.green, color.blue,
136
+ color.red, color.green, color.blue,
137
+ color.red, color.green, color.blue,
138
+ color.red, color.green, color.blue,
139
+ color.red, color.green, color.blue,
140
+ color.red, color.green, color.blue,
141
+ color.red, color.green, color.blue,
142
+ color.red, color.green, color.blue,
143
+ color.red, color.green, color.blue,
144
+ color.red, color.green, color.blue,
145
+ color.red, color.green, color.blue,
146
+ color.red, color.green, color.blue,
147
+ color.red, color.green, color.blue,
148
+ color.red, color.green, color.blue,
149
+ color.red, color.green, color.blue,
150
+ color.red, color.green, color.blue,
151
+ color.red, color.green, color.blue,
152
+ color.red, color.green, color.blue,
153
+ color.red, color.green, color.blue,
154
+ color.red, color.green, color.blue,
155
+ color.red, color.green, color.blue,
156
+ color.red, color.green, color.blue,
157
+ color.red, color.green, color.blue
158
+ ]
159
+ end
160
+
161
+ def mesh_vertices(box)
162
+ [
163
+ box.min.x, box.max.y, box.max.z,
164
+ box.min.x, box.max.y, box.min.z,
165
+ box.max.x, box.max.y, box.min.z,
166
+
167
+ box.min.x, box.max.y, box.max.z,
168
+ box.max.x, box.max.y, box.max.z,
169
+ box.max.x, box.max.y, box.min.z,
170
+
171
+ box.max.x, box.min.y, box.min.z,
172
+ box.max.x, box.min.y, box.max.z,
173
+ box.min.x, box.min.y, box.max.z,
174
+
175
+ box.max.x, box.min.y, box.min.z,
176
+ box.min.x, box.min.y, box.min.z,
177
+ box.min.x, box.min.y, box.max.z,
178
+
179
+ box.min.x, box.max.y, box.max.z,
180
+ box.min.x, box.max.y, box.min.z,
181
+ box.min.x, box.min.y, box.min.z,
182
+
183
+ box.min.x, box.min.y, box.max.z,
184
+ box.min.x, box.min.y, box.min.z,
185
+ box.min.x, box.max.y, box.max.z,
186
+
187
+ box.max.x, box.max.y, box.max.z,
188
+ box.max.x, box.max.y, box.min.z,
189
+ box.max.x, box.min.y, box.min.z,
190
+
191
+ box.max.x, box.min.y, box.max.z,
192
+ box.max.x, box.min.y, box.min.z,
193
+ box.max.x, box.max.y, box.max.z,
194
+
195
+ box.min.x, box.max.y, box.max.z,
196
+ box.max.x, box.max.y, box.max.z,
197
+ box.max.x, box.min.y, box.max.z,
198
+
199
+ box.min.x, box.max.y, box.max.z,
200
+ box.max.x, box.min.y, box.max.z,
201
+ box.min.x, box.min.y, box.max.z,
202
+
203
+ box.max.x, box.min.y, box.min.z,
204
+ box.min.x, box.min.y, box.min.z,
205
+ box.min.x, box.max.y, box.min.z,
206
+
207
+ box.max.x, box.min.y, box.min.z,
208
+ box.min.x, box.max.y, box.min.z,
209
+ box.max.x, box.max.y, box.min.z
210
+ ]
211
+ end
212
+
213
+ def draw_bounding_boxes
214
+ @bounding_boxes.each do |key, bounding_box|
215
+ glPushMatrix
216
+
217
+ glTranslatef(
218
+ bounding_box[:entity].position.x,
219
+ bounding_box[:entity].position.y,
220
+ bounding_box[:entity].position.z
221
+ )
222
+ draw_bounding_box(bounding_box)
223
+ @bounding_boxes[key][:objects].each { |o| draw_bounding_box(o) }
224
+
225
+ glPopMatrix
226
+ end
227
+ end
228
+
229
+ def draw_bounding_box(bounding_box)
230
+ glEnableClientState(GL_VERTEX_ARRAY)
231
+ glEnableClientState(GL_COLOR_ARRAY)
232
+ glEnableClientState(GL_NORMAL_ARRAY)
233
+
234
+ glVertexPointer(3, GL_FLOAT, 0, bounding_box[:vertices])
235
+ glColorPointer(3, GL_FLOAT, 0, bounding_box[:colors])
236
+ glNormalPointer(GL_FLOAT, 0, bounding_box[:normals])
237
+
238
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
239
+ glDisable(GL_LIGHTING)
240
+ glDrawArrays(GL_TRIANGLES, 0, bounding_box[:vertices_size] / 3)
241
+ glEnable(GL_LIGHTING)
242
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
243
+
244
+ glDisableClientState(GL_VERTEX_ARRAY)
245
+ glDisableClientState(GL_COLOR_ARRAY)
246
+ glDisableClientState(GL_NORMAL_ARRAY)
247
+ end
248
+ end
249
+ end