cyberarm_engine 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/assets/shaders/fragment/g_buffer.glsl +8 -8
  3. data/assets/shaders/fragment/lighting.glsl +15 -9
  4. data/assets/shaders/include/material_struct.glsl +16 -0
  5. data/assets/shaders/vertex/g_buffer.glsl +17 -17
  6. data/assets/shaders/vertex/lighting.glsl +16 -9
  7. data/lib/cyberarm_engine/builtin/intro_state.rb +1 -1
  8. data/lib/cyberarm_engine/common.rb +2 -2
  9. data/lib/cyberarm_engine/console.rb +10 -10
  10. data/lib/cyberarm_engine/game_object.rb +1 -1
  11. data/lib/cyberarm_engine/gosu_ext/draw_arc.rb +98 -0
  12. data/lib/cyberarm_engine/gosu_ext/draw_circle.rb +31 -0
  13. data/lib/cyberarm_engine/gosu_ext/draw_path.rb +17 -0
  14. data/lib/cyberarm_engine/model.rb +7 -6
  15. data/lib/cyberarm_engine/notification.rb +83 -0
  16. data/lib/cyberarm_engine/notification_manager.rb +242 -0
  17. data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +16 -10
  18. data/lib/cyberarm_engine/opengl/renderer/renderer.rb +12 -1
  19. data/lib/cyberarm_engine/opengl/shader.rb +2 -2
  20. data/lib/cyberarm_engine/stats.rb +181 -10
  21. data/lib/cyberarm_engine/text.rb +3 -0
  22. data/lib/cyberarm_engine/ui/element.rb +45 -14
  23. data/lib/cyberarm_engine/ui/elements/container.rb +86 -27
  24. data/lib/cyberarm_engine/ui/elements/slider.rb +4 -3
  25. data/lib/cyberarm_engine/ui/elements/text_block.rb +11 -1
  26. data/lib/cyberarm_engine/ui/gui_state.rb +28 -18
  27. data/lib/cyberarm_engine/ui/style.rb +2 -1
  28. data/lib/cyberarm_engine/vector.rb +35 -16
  29. data/lib/cyberarm_engine/version.rb +1 -1
  30. data/lib/cyberarm_engine/window.rb +35 -8
  31. data/lib/cyberarm_engine.rb +8 -2
  32. data/mrbgem.rake +29 -0
  33. metadata +10 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c883f949982d339928785f9dbcbe710a7df483ba698ce6e3e95d38d300cf4e03
4
- data.tar.gz: 17364dddce1f68533a01b9b69d591792bf4c9495341fc3a9726d77e70fa8246f
3
+ metadata.gz: 5af070a65180730f1435091615fa8160c0763fbdc552918c63c93037b41571f0
4
+ data.tar.gz: f426d50db35a7f6b520a239bda8f9eed39d6e1b77ea77a1a7f9cca1c0b9edb0e
5
5
  SHA512:
6
- metadata.gz: cd9fdd1da003de3a01e1d56ba1cedff869ef702ed0f070725f8a234f5a4686bd7798bc1239a0f346d0191fd2709e2c91816a461a20bb7c862fdff940ca3968c6
7
- data.tar.gz: 7d6afa770c285bd0c841607eda82d1bc36f1b70b15f5c6864db837822855f54243d5a44c64395ae6bf161c74d424ac9a529b5241161c520f481844df06ef1b5d
6
+ metadata.gz: dbe115990e1e9ae8f7c86a2152a16e7ff7dd752cd84029b2e30b41cbce533b9649abea04009bf2c763b033ec64be89c85f60ef8d07040c450ba57e4fb1a1fe95
7
+ data.tar.gz: 18bf468ce8ccb6547e6f578f668f0cb9774d0833f60f8956ac4e98d68c5de61d4b3c1f3079e12e5032a92f4d3a2335a18ae7b4ac7ab15f7eeccd531ae0c64e0a
@@ -5,25 +5,25 @@ layout (location = 1) out vec4 fragColor;
5
5
  layout (location = 2) out vec3 fragNormal;
6
6
  layout (location = 3) out vec3 fragUV;
7
7
 
8
- in vec3 outPosition, outColor, outNormal, outUV, outFragPos, outCameraPos;
8
+ in vec3 out_position, out_color, out_normal, out_uv, out_frag_pos, out_camera_pos;
9
9
  out vec4 outputFragColor;
10
- flat in int outHasTexture;
10
+ flat in int out_has_texture;
11
11
 
12
12
  uniform sampler2D diffuse_texture;
13
13
 
14
14
  void main() {
15
15
  vec3 result;
16
16
 
17
- if (outHasTexture == 0) {
18
- result = outColor;
17
+ if (out_has_texture == 0) {
18
+ result = out_color;
19
19
  } else {
20
- result = texture(diffuse_texture, outUV.xy).xyz + 0.25;
20
+ result = texture(diffuse_texture, out_uv.xy).xyz + 0.25;
21
21
  }
22
22
 
23
- fragPosition = outPosition;
23
+ fragPosition = out_position;
24
24
  fragColor = vec4(result, 1.0);
25
- fragNormal = outNormal;
26
- fragUV = outUV;
25
+ fragNormal = out_normal;
26
+ fragUV = out_uv;
27
27
 
28
28
  float gamma = 2.2;
29
29
  outputFragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma));
@@ -1,22 +1,23 @@
1
1
  #version 330 core
2
- out vec4 FragColor;
2
+ out vec4 frag_color;
3
3
 
4
4
  @include "light_struct"
5
5
  const int DIRECTIONAL = 0;
6
6
  const int POINT = 1;
7
7
  const int SPOT = 2;
8
8
 
9
- in vec2 outTexCoords;
10
- flat in Light outLight[1];
9
+ flat in Light out_lights[7];
10
+ in vec2 out_tex_coords;
11
+ flat in int out_light_count;
11
12
 
12
13
  uniform sampler2D diffuse, position, texcoord, normal, depth;
13
14
 
14
15
  vec4 directionalLight(Light light) {
15
- vec3 norm = normalize(texture(normal, outTexCoords).rgb);
16
- vec3 diffuse_color = texture(diffuse, outTexCoords).rgb;
17
- vec3 fragPos = texture(position, outTexCoords).rgb;
16
+ vec3 norm = normalize(texture(normal, out_tex_coords).rgb);
17
+ vec3 diffuse_color = texture(diffuse, out_tex_coords).rgb;
18
+ vec3 frag_pos = texture(position, out_tex_coords).rgb;
18
19
 
19
- vec3 lightDir = normalize(light.position - fragPos);
20
+ vec3 lightDir = normalize(light.position - frag_pos);
20
21
  float diff = max(dot(norm, lightDir), 0);
21
22
 
22
23
  vec3 _ambient = light.ambient;
@@ -59,5 +60,10 @@ vec4 calculateLighting(Light light) {
59
60
  }
60
61
 
61
62
  void main() {
62
- FragColor = texture(diffuse, outTexCoords) * calculateLighting(outLight[0]);
63
- }
63
+ frag_color = vec4(0.0);
64
+
65
+ for(int i = 0; i < out_light_count; i++)
66
+ {
67
+ frag_color += texture(diffuse, out_tex_coords) * calculateLighting(out_lights[i]);
68
+ }
69
+ }
@@ -0,0 +1,16 @@
1
+ struct Material {
2
+ vec3 color;
3
+ vec3 roughness;
4
+ vec3 metalic;
5
+ vec3 specular;
6
+
7
+ bool use_color_texture;
8
+ bool use_roughness_texture;
9
+ bool use_metalic_texture;
10
+ bool use_specular_texture;
11
+
12
+ sampler2D color_tex;
13
+ sampler2D roughness_tex;
14
+ sampler2D metalic_tex;
15
+ sampler2D specular_tex;
16
+ };
@@ -1,28 +1,28 @@
1
1
  # version 330 core
2
2
 
3
- layout(location = 0) in vec3 inPosition;
4
- layout(location = 1) in vec3 inColor;
5
- layout(location = 2) in vec3 inNormal;
6
- layout(location = 3) in vec3 inUV;
3
+ layout(location = 0) in vec3 in_position;
4
+ layout(location = 1) in vec3 in_color;
5
+ layout(location = 2) in vec3 in_normal;
6
+ layout(location = 3) in vec3 in_uv;
7
7
 
8
8
  uniform mat4 projection, view, model;
9
- uniform int hasTexture;
10
- uniform vec3 cameraPos;
9
+ uniform int has_texture;
10
+ uniform vec3 camera_pos;
11
11
 
12
- out vec3 outPosition, outColor, outNormal, outUV;
13
- out vec3 outFragPos, outViewPos, outCameraPos;
14
- flat out int outHasTexture;
12
+ out vec3 out_position, out_color, out_normal, out_uv;
13
+ out vec3 out_frag_pos, out_view_pos, out_camera_pos;
14
+ flat out int out_has_texture;
15
15
 
16
16
  void main() {
17
17
  // projection * view * model * position
18
- outPosition = inPosition;
19
- outColor = inColor;
20
- outNormal= normalize(transpose(inverse(mat3(model))) * inNormal);
21
- outUV = inUV;
22
- outHasTexture = hasTexture;
23
- outCameraPos = cameraPos;
18
+ out_position = in_position;
19
+ out_color = in_color;
20
+ out_normal= normalize(transpose(inverse(mat3(model))) * in_normal);
21
+ out_uv = in_uv;
22
+ out_has_texture = has_texture;
23
+ out_camera_pos = camera_pos;
24
24
 
25
- outFragPos = vec3(model * vec4(inPosition, 1.0));
25
+ out_frag_pos = vec3(model * vec4(in_position, 1.0));
26
26
 
27
- gl_Position = projection * view * model * vec4(inPosition, 1.0);
27
+ gl_Position = projection * view * model * vec4(in_position, 1.0);
28
28
  }
@@ -1,17 +1,24 @@
1
1
  #version 330 core
2
2
  @include "light_struct"
3
3
 
4
- layout (location = 0) in vec3 inPosition;
5
- layout (location = 1) in vec2 inTexCoords;
4
+ layout (location = 0) in vec3 in_position;
5
+ layout (location = 1) in vec2 in_tex_coords;
6
6
 
7
7
  uniform sampler2D diffuse, position, texcoord, normal, depth;
8
- uniform Light light[1];
8
+ uniform int light_count;
9
+ uniform Light lights[7];
9
10
 
10
- out vec2 outTexCoords;
11
- flat out Light outLight[1];
11
+ out vec2 out_tex_coords;
12
+ flat out int out_light_count;
13
+ flat out Light out_lights[7];
12
14
 
13
15
  void main() {
14
- gl_Position = vec4(inPosition.x, inPosition.y, inPosition.z, 1.0);
15
- outTexCoords = inTexCoords;
16
- outLight = light;
17
- }
16
+ gl_Position = vec4(in_position.x, in_position.y, in_position.z, 1.0);
17
+ out_tex_coords = in_tex_coords;
18
+ out_light_count = light_count;
19
+
20
+ for(int i = 0; i < light_count; i++)
21
+ {
22
+ out_lights[i] = lights[i];
23
+ }
24
+ }
@@ -18,7 +18,7 @@ module CyberarmEngine
18
18
 
19
19
  @gosu_logo = generate_proxy("Gosu", "Game Library", 0xff_111111)
20
20
  @ruby_logo = generate_proxy("Ruby", "Programming Language", 0xff_880000)
21
- @opengl_logo = generate_proxy("OpenGL", "Graphics API", 0xff_5586a4) if defined?(OpenGL)
21
+ @opengl_logo = generate_proxy("OpenGL", "Graphics API", 0xff_5586a4) if RUBY_ENGINE != "mruby" && defined?(OpenGL)
22
22
 
23
23
  base_time = Gosu.milliseconds
24
24
 
@@ -52,7 +52,7 @@ module CyberarmEngine
52
52
  end
53
53
 
54
54
  def lighten(color, amount = 25)
55
- if defined?(color.alpha)
55
+ if color.respond_to?(:alpha)
56
56
  Gosu::Color.rgba(color.red + amount, color.green + amount, color.blue + amount, color.alpha)
57
57
  else
58
58
  Gosu::Color.rgb(color.red + amount, color.green + amount, color.blue + amount)
@@ -60,7 +60,7 @@ module CyberarmEngine
60
60
  end
61
61
 
62
62
  def darken(color, amount = 25)
63
- if defined?(color.alpha)
63
+ if color.respond_to?(:alpha)
64
64
  Gosu::Color.rgba(color.red - amount, color.green - amount, color.blue - amount, color.alpha)
65
65
  else
66
66
  Gosu::Color.rgb(color.red - amount, color.green - amount, color.blue - amount)
@@ -103,7 +103,7 @@ module CyberarmEngine
103
103
 
104
104
  def button_down(id)
105
105
  case id
106
- when Gosu::KbEnter, Gosu::KbReturn
106
+ when Gosu::KB_ENTER, Gosu::KB_RETURN
107
107
  return unless @text_input.text.length.positive?
108
108
 
109
109
  @history.text += "\n<c=999999>> #{@text_input.text}</c>"
@@ -113,12 +113,12 @@ module CyberarmEngine
113
113
  handle_command
114
114
  @text_input.text = ""
115
115
 
116
- when Gosu::KbUp
116
+ when Gosu::KB_UP
117
117
  @command_history_index -= 1
118
118
  @command_history_index = 0 if @command_history_index.negative?
119
119
  @text_input.text = @command_history[@command_history_index]
120
120
 
121
- when Gosu::KbDown
121
+ when Gosu::KB_DOWN
122
122
  @command_history_index += 1
123
123
  if @command_history_index > @command_history.size - 1
124
124
  @text_input.text = "" unless @command_history_index > @command_history.size
@@ -127,7 +127,7 @@ module CyberarmEngine
127
127
  @text_input.text = @command_history[@command_history_index]
128
128
  end
129
129
 
130
- when Gosu::KbTab
130
+ when Gosu::KB_TAB
131
131
  split = @text_input.text.split(" ")
132
132
 
133
133
  if !@text_input.text.end_with?(" ") && split.size == 1
@@ -142,7 +142,7 @@ module CyberarmEngine
142
142
  cmd.autocomplete(self)
143
143
  end
144
144
 
145
- when Gosu::KbBacktick
145
+ when Gosu::KB_BACKTICK
146
146
  # Remove backtick character from input
147
147
  @text_input.text = if @text_input.text.size > 1
148
148
  @text_input.text[0..@text_input.text.size - 2]
@@ -151,7 +151,7 @@ module CyberarmEngine
151
151
  end
152
152
 
153
153
  # Copy
154
- when Gosu::KbC
154
+ when Gosu::KB_C
155
155
  if control_down? && shift_down?
156
156
  @memory = @text_input.text[caret_start..caret_end - 1] if caret_start != caret_end
157
157
  p @memory
@@ -160,7 +160,7 @@ module CyberarmEngine
160
160
  end
161
161
 
162
162
  # Paste
163
- when Gosu::KbV
163
+ when Gosu::KB_V
164
164
  if control_down? && shift_down?
165
165
  string = @text_input.text.chars.insert(caret_pos, @memory).join
166
166
  _caret_pos = caret_pos
@@ -170,7 +170,7 @@ module CyberarmEngine
170
170
  end
171
171
 
172
172
  # Cut
173
- when Gosu::KbX
173
+ when Gosu::KB_X
174
174
  if control_down? && shift_down?
175
175
  @memory = @text_input.text[caret_start..caret_end - 1] if caret_start != caret_end
176
176
  string = @text_input.text.chars
@@ -182,7 +182,7 @@ module CyberarmEngine
182
182
  end
183
183
 
184
184
  # Delete word to left of caret
185
- when Gosu::KbW
185
+ when Gosu::KB_W
186
186
  if control_down?
187
187
  split = @text_input.text.split(" ")
188
188
  split.delete(split.last)
@@ -190,7 +190,7 @@ module CyberarmEngine
190
190
  end
191
191
 
192
192
  # Clear history
193
- when Gosu::KbL
193
+ when Gosu::KB_L
194
194
  @history.text = "" if control_down?
195
195
  end
196
196
  end
@@ -42,7 +42,7 @@ module CyberarmEngine
42
42
  @radius = if options[:radius]
43
43
  options[:radius]
44
44
  else
45
- defined?(@image.width) ? ((@image.width + @image.height) / 4) * scale : 1
45
+ @image.respond_to?(:width) ? ((@image.width + @image.height) / 4) * scale : 1
46
46
  end
47
47
  end
48
48
  end
@@ -0,0 +1,98 @@
1
+ module Gosu
2
+ # Draw an arc around the point x and y.
3
+ #
4
+ # Color accepts the following: *Gosu::Color*, *Array* (with 2 colors), or a *Hash* with keys: _from:_ and _to:_ both colors.
5
+ #
6
+ # With a *Gosu::Color* the arc will be painted with color
7
+ #
8
+ # With an *Array* the first *Gosu::Color* with be the innermost color and the last *Gosu::Color* with be the outermost color
9
+ #
10
+ # With a *Hash* the arc will smoothly transition from the start of the arc to the end
11
+ # @example
12
+ # # Using a Hash
13
+ # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, {from: Gosu::Color::BLUE, to: Gosu::Color::GREEN}, 0, :default)
14
+ #
15
+ # # Using an Array
16
+ # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, [Gosu::Color::BLUE, Gosu::Color::GREEN], 0, :default)
17
+ #
18
+ # # Using a Gosu::Color
19
+ # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, Gosu::Color::BLUE, 0, :default)
20
+ #
21
+ #
22
+ # @param x X position.
23
+ # @param y Y position.
24
+ # @param radius radius of arc, in pixels.
25
+ # @param percentage how complete the segment is, _0.0_ is 0% and _1.0_ is 100%.
26
+ # @param segments how many segments for arc, more will appear smoother, less will appear jagged.
27
+ # @param thickness how thick arc will be.
28
+ # @param color [Gosu::Color, Array<Gosu::Color, Gosu::Color>, Hash{from: start_color, to: end_color}] color or colors to draw the arc with.
29
+ # @param z Z position.
30
+ # @param mode blend mode.
31
+ #
32
+ # @note _thickness_ is subtracted from radius, meaning that the arc will grow towards the origin, not away from it.
33
+ #
34
+ # @return [void]
35
+ def self.draw_arc(x, y, radius, percentage = 1.0, segments = 128, thickness = 4, color = Gosu::Color::WHITE, z = 0, mode = :default)
36
+ segments = 360.0 / segments
37
+
38
+ return if percentage == 0.0
39
+
40
+ 0.step((359 * percentage), percentage > 0 ? segments : -segments) do |angle|
41
+ angle2 = angle + segments
42
+
43
+ point_a_left_x = x + Gosu.offset_x(angle, radius - thickness)
44
+ point_a_left_y = y + Gosu.offset_y(angle, radius - thickness)
45
+
46
+ point_a_right_x = x + Gosu.offset_x(angle2, radius - thickness)
47
+ point_a_right_y = y + Gosu.offset_y(angle2, radius - thickness)
48
+
49
+ point_b_left_x = x + Gosu.offset_x(angle, radius)
50
+ point_b_left_y = y + Gosu.offset_y(angle, radius)
51
+
52
+ point_b_right_x = x + Gosu.offset_x(angle2, radius)
53
+ point_b_right_y = y + Gosu.offset_y(angle2, radius)
54
+
55
+ if color.is_a?(Array)
56
+ Gosu.draw_quad(
57
+ point_a_left_x, point_a_left_y, color.first,
58
+ point_b_left_x, point_b_left_y, color.last,
59
+ point_a_right_x, point_a_right_y, color.first,
60
+ point_b_right_x, point_b_right_y, color.last,
61
+ z, mode
62
+ )
63
+ elsif color.is_a?(Hash)
64
+ start_color = color[:from]
65
+ end_color = color[:to]
66
+
67
+ color_a = Gosu::Color.rgba(
68
+ (end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
69
+ (end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
70
+ (end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
71
+ (end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
72
+ )
73
+ color_b = Gosu::Color.rgba(
74
+ (end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
75
+ (end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
76
+ (end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
77
+ (end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
78
+ )
79
+
80
+ Gosu.draw_quad(
81
+ point_a_left_x, point_a_left_y, color_a,
82
+ point_b_left_x, point_b_left_y, color_a,
83
+ point_a_right_x, point_a_right_y, color_b,
84
+ point_b_right_x, point_b_right_y, color_b,
85
+ z, mode
86
+ )
87
+ else
88
+ Gosu.draw_quad(
89
+ point_a_left_x, point_a_left_y, color,
90
+ point_b_left_x, point_b_left_y, color,
91
+ point_a_right_x, point_a_right_y, color,
92
+ point_b_right_x, point_b_right_y, color,
93
+ z, mode
94
+ )
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,31 @@
1
+ module Gosu
2
+ ##
3
+ # Draw a filled circled around point X and Y.
4
+ #
5
+ # @param x X position.
6
+ # @param y Y position.
7
+ # @param radius radius of circle, in pixels.
8
+ # @param step_size resolution of circle, more steps will apear smoother, less will appear jagged.
9
+ # @param color color to draw circle with.
10
+ # @param mode blend mode.
11
+ #
12
+ # @return [void]
13
+ def self.draw_circle(x, y, radius, step_size = 36, color = Gosu::Color::WHITE, z = 0, mode = :default)
14
+ step_size = (360.0 / step_size).floor
15
+
16
+ 0.step(359, step_size) do |angle|
17
+ angle2 = angle + step_size
18
+
19
+ point_lx = x + Gosu.offset_x(angle, radius)
20
+ point_ly = y + Gosu.offset_y(angle, radius)
21
+ point_rx = x + Gosu.offset_x(angle2, radius)
22
+ point_ry = y + Gosu.offset_y(angle2, radius)
23
+
24
+ Gosu.draw_triangle(
25
+ point_lx, point_ly, color,
26
+ point_rx, point_ry, color,
27
+ x, y, color, z, mode
28
+ )
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ module Gosu
2
+ PathNode = Struct.new(:x, :y)
3
+
4
+ def self.draw_path(nodes, color = Gosu::Color::WHITE, z = 0, mode = :default)
5
+ last_node = nodes.first
6
+
7
+ nodes[1..nodes.size - 1].each do |current_node|
8
+ Gosu.draw_line(
9
+ last_node.x, last_node.y, color,
10
+ current_node.x, current_node.y, color,
11
+ z, mode
12
+ )
13
+
14
+ last_node = current_node
15
+ end
16
+ end
17
+ end
@@ -49,8 +49,9 @@ module CyberarmEngine
49
49
 
50
50
  @objects.each { |o| @vertex_count += o.vertices.size }
51
51
 
52
- start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
52
+ # start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
53
53
  # build_collision_tree
54
+ # puts " Building mesh collision tree took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond) - start_time) / 1000.0).round(2)} seconds"
54
55
  end
55
56
 
56
57
  def parse(parser)
@@ -150,24 +151,24 @@ module CyberarmEngine
150
151
  glBindBuffer(GL_ARRAY_BUFFER, @positions_buffer_id)
151
152
  gl_error?
152
153
 
153
- # inPosition
154
+ # in_position
154
155
  glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nil)
155
156
  gl_error?
156
157
  # colors
157
158
  glBindBuffer(GL_ARRAY_BUFFER, @colors_buffer_id)
158
- # inColor
159
+ # in_color
159
160
  glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, nil)
160
161
  gl_error?
161
162
  # normals
162
163
  glBindBuffer(GL_ARRAY_BUFFER, @normals_buffer_id)
163
- # inNormal
164
+ # in_normal
164
165
  glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, nil)
165
166
  gl_error?
166
167
 
167
168
  if has_texture?
168
169
  # uvs
169
170
  glBindBuffer(GL_ARRAY_BUFFER, @uvs_buffer_id)
170
- # inUV
171
+ # in_uv
171
172
  glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 0, nil)
172
173
  gl_error?
173
174
  end
@@ -177,7 +178,7 @@ module CyberarmEngine
177
178
  end
178
179
 
179
180
  def build_collision_tree
180
- @aabb_tree = AABBTree.new
181
+ @aabb_tree = IMICFPS::AABBTree.new
181
182
 
182
183
  @faces.each do |face|
183
184
  box = BoundingBox.new
@@ -0,0 +1,83 @@
1
+ module CyberarmEngine
2
+ class Notification
3
+ WIDTH = 500
4
+ HEIGHT = 64
5
+ EDGE_WIDTH = 8
6
+ TRANSITION_DURATION = 750
7
+ PADDING = 8
8
+
9
+ TTL_LONG = 5_000
10
+ TTL_MEDIUM = 3_250
11
+ TTL_SHORT = 1_500
12
+ TIME_TO_LIVE = TTL_MEDIUM
13
+
14
+ BACKGROUND_COLOR = Gosu::Color.new(0xaa313533)
15
+ EDGE_COLOR = Gosu::Color.new(0xaa010101)
16
+ ICON_COLOR = Gosu::Color.new(0xddffffff)
17
+ TITLE_COLOR = Gosu::Color.new(0xddffffff)
18
+ TAGLINE_COLOR = Gosu::Color.new(0xddaaaaaa)
19
+
20
+ TITLE_SIZE = 28
21
+ TAGLINE_SIZE = 18
22
+ ICON_SIZE = HEIGHT - PADDING * 2
23
+
24
+ TITLE_FONT = Gosu::Font.new(TITLE_SIZE, bold: true)
25
+ TAGLINE_FONT = Gosu::Font.new(TAGLINE_SIZE)
26
+
27
+ PRIORITY_HIGH = 1.0
28
+ PRIORITY_MEDIUM = 0.5
29
+ PRIORITY_LOW = 0.0
30
+
31
+ LINEAR_TRANSITION = :linear
32
+ EASE_IN_OUT_TRANSITION = :ease_in_out
33
+
34
+ attr_reader :priority, :title, :tagline, :icon, :time_to_live, :transition_duration, :transition_type
35
+ def initialize(
36
+ host:, priority:, title:, title_color: TITLE_COLOR, tagline: "", tagline_color: TAGLINE_COLOR, icon: nil, icon_color: ICON_COLOR,
37
+ edge_color: EDGE_COLOR, background_color: BACKGROUND_COLOR, time_to_live: TIME_TO_LIVE, transition_duration: TRANSITION_DURATION,
38
+ transition_type: EASE_IN_OUT_TRANSITION
39
+ )
40
+ @host = host
41
+
42
+ @priority = priority
43
+ @title = title
44
+ @title_color = title_color
45
+ @tagline = tagline
46
+ @tagline_color = tagline_color
47
+ @icon = icon
48
+ @icon_color = icon_color
49
+ @edge_color = edge_color
50
+ @background_color = background_color
51
+ @time_to_live = time_to_live
52
+ @transition_duration = transition_duration
53
+ @transition_type = transition_type
54
+
55
+ @icon_scale = ICON_SIZE.to_f / @icon.width if @icon
56
+ end
57
+
58
+ def draw
59
+ Gosu.draw_rect(0, 0, WIDTH, HEIGHT, @background_color)
60
+
61
+ if @host.edge == :top
62
+ Gosu.draw_rect(0, HEIGHT - EDGE_WIDTH, WIDTH, EDGE_WIDTH, @edge_color)
63
+ @icon.draw(EDGE_WIDTH + PADDING, PADDING, 0, @icon_scale, @icon_scale, @icon_color) if @icon
64
+
65
+ elsif @host.edge == :bottom
66
+ Gosu.draw_rect(0, 0, WIDTH, EDGE_WIDTH, @edge_color)
67
+ @icon.draw(EDGE_WIDTH + PADDING, PADDING, 0, @icon_scale, @icon_scale, @icon_color) if @icon
68
+
69
+ elsif @host.edge == :right
70
+ Gosu.draw_rect(0, 0, EDGE_WIDTH, HEIGHT, @edge_color)
71
+ @icon.draw(EDGE_WIDTH + PADDING, PADDING, 0, @icon_scale, @icon_scale, @icon_color) if @icon
72
+
73
+ else
74
+ Gosu.draw_rect(WIDTH - EDGE_WIDTH, 0, EDGE_WIDTH, HEIGHT, @edge_color)
75
+ @icon.draw(PADDING, PADDING, 0, @icon_scale, @icon_scale, @icon_color) if @icon
76
+ end
77
+
78
+ icon_space = @icon ? ICON_SIZE + PADDING : 0
79
+ TITLE_FONT.draw_text(@title, PADDING + EDGE_WIDTH + icon_space, PADDING, 0, 1, 1, @title_color)
80
+ TAGLINE_FONT.draw_text(@tagline, PADDING + EDGE_WIDTH + icon_space, PADDING + TITLE_FONT.height, 0, 1, 1, @tagline_color)
81
+ end
82
+ end
83
+ end