ezii 0.0.0.1 → 1.0.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.
- checksums.yaml +5 -5
- data/eezee-3-aka-game-x-engine.zip +0 -0
- data/eezee-3-aka-game-x-engine/README.md +5 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/functions/base_command.rb +20 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/functions/mouse_y_axis_to_3d_z_axis.rb +4 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/functions/rotate_camera_axis_using_mouse_drag.rb +37 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/functions/selection_cube.rb +35 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/gam.rb +467 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/gems.locked +77 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/gems.rb +10 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/lib/drb_server.rb +13 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/lib/mittsu_monkeypatches/box_geometry.rb +5 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/runnable.rb +9 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/shapes/cube.rb +33 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/sig/runable.rbi +9 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/test.sh +5 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/test/commands/test_selection_cube.rb +31 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/test/test_command_remapping.rb +30 -0
- data/eezee-3-aka-game-x-engine/managables/programs/game_aided_manufacturing/test/test_helper.rb +75 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/chat.txt +15 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/chatbot.rb +718 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/gems.locked +50 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/gems.rb +13 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/setup-mac-os-x.sh +0 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/setup.sh +1 -0
- data/eezee-3-aka-game-x-engine/managables/services/chat-bot-integrations/start.sh +3 -0
- data/eezee-3-aka-game-x-engine/managables/services/error-inspect/simplest-log +1 -0
- data/eezee-3-aka-game-x-engine/managables/services/error-inspect/simplest-log-init +1 -0
- data/eezee-3-aka-game-x-engine/managables/services/livestream-interactive/Twitch.Tv/gems.locked +17 -0
- data/eezee-3-aka-game-x-engine/managables/services/livestream-interactive/Twitch.Tv/gems.rb +5 -0
- data/eezee-3-aka-game-x-engine/managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb +112 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/README.md +3 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/__main__.js +58 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/black-out-random-word.js +74 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-sentence.js +57 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-wikipedia-page.js +25 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-words.js +34 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/rare-enough-word.js +41 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/wikipedia-page.js +35 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/package.json +20 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/statistics/count-word.js +12 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/utils/log-to-natural-database.js +10 -0
- data/eezee-3-aka-game-x-engine/managables/services/stdlib-dot-com/koma/qanda-api@dev/word2vec-models/test-text8-vector.bin +0 -0
- data/eezee-3-aka-game-x-engine/managament_interface/gems.locked +13 -0
- data/eezee-3-aka-game-x-engine/managament_interface/gems.rb +3 -0
- data/eezee-3-aka-game-x-engine/managament_interface/management_interface +4 -0
- data/eezee-3-aka-game-x-engine/managament_interface/runnable.rb +30 -0
- data/eezee-3-aka-game-x-engine/start.sh +2 -0
- data/ezii.gemspec +1 -1
- metadata +49 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 04cc97a422d1ad21da0334fd1f5e7be4139e6f8b9e48b413be66d06c3dd0bb35
|
|
4
|
+
data.tar.gz: b32a4caeb05e6bfa31d640fba5318123dc9fa020e07a6869cdd2697b4658a362
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98c7347c85fde99a3d315946f08688db27a33bedffd7cec293af21ff021a4502698f5a74ebcec1caefd1cddbc5bca7aa2799cffdd81d012f6529a4a82c23e2a4
|
|
7
|
+
data.tar.gz: b173ebd5dab2902fa8a67c33d5f061224082c2b8a138efe907240becfe28418b7dcdc2544f06eecc7af37510de8737fa64d08be2c3152aaf8e17685db6412f4b
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
class BaseCommand
|
|
3
|
+
def initialize(gam_main_instance)
|
|
4
|
+
@active = true
|
|
5
|
+
@gam_main_instance = gam_main_instance
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def active?
|
|
9
|
+
@active
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def finish
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def mouse_down(vector)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def mouse_up(vector)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
class RotateCameraAxisUsingMouseDrag
|
|
3
|
+
def initialize(gam_main_instance)
|
|
4
|
+
@active = true
|
|
5
|
+
@gam_main_instance = gam_main_instance
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def active?
|
|
9
|
+
@active
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def finish
|
|
13
|
+
@active = false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def mouse_down(vector)
|
|
17
|
+
@mouse_down = true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def mouse_move(vector)
|
|
21
|
+
unless @last_point.nil?
|
|
22
|
+
difference_vector = @last_point.sub(vector)
|
|
23
|
+
|
|
24
|
+
@gam_main_instance.camera.rotation.x += difference_vector.x
|
|
25
|
+
@gam_main_instance.camera.rotation.y += difference_vector.y
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if @mouse_down
|
|
29
|
+
@last_point = vector
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def mouse_up(vector)
|
|
34
|
+
@mouse_down = false
|
|
35
|
+
finish
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_relative '../shapes/cube'
|
|
2
|
+
|
|
3
|
+
class SelectionCube
|
|
4
|
+
def initialize(gam_main_instance)
|
|
5
|
+
@active = true
|
|
6
|
+
@gam_main_instance = gam_main_instance
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def active?
|
|
10
|
+
@active
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def finish
|
|
14
|
+
@active = false
|
|
15
|
+
|
|
16
|
+
difference_vector = @second_point.sub(@first_point)
|
|
17
|
+
|
|
18
|
+
z_size = 2 # unsure how to tackle z size for now, so i'll set it to a default 2 until i found a better solution, then it would be `difference_vector.z.abs`
|
|
19
|
+
size_vector = Mittsu::Vector3.new(difference_vector.x.abs, difference_vector.y.abs, z_size)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@selection_cube = Cube.new(size_vector: size_vector)
|
|
23
|
+
@selection_cube.position = @first_point
|
|
24
|
+
@gam_main_instance.scene.add(@selection_cube.mittsu_object)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def mouse_down(vector)
|
|
28
|
+
@first_point = vector
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def mouse_up(vector)
|
|
32
|
+
@second_point = vector
|
|
33
|
+
self.finish
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
require 'mittsu'
|
|
2
|
+
require_relative 'shapes/cube.rb'
|
|
3
|
+
require 'pry-remote'
|
|
4
|
+
require 'ast'
|
|
5
|
+
require 'byebug'
|
|
6
|
+
|
|
7
|
+
# Monkey patching Object like it's the golden old days
|
|
8
|
+
|
|
9
|
+
class Object
|
|
10
|
+
def recursive_find(method_name, &find_condition_block)
|
|
11
|
+
if find_condition_block.call(self)
|
|
12
|
+
return self
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if self.respond_to?(method_name)
|
|
16
|
+
enumerable = self.public_send(method_name)
|
|
17
|
+
elsif self.respond_to?(:each)
|
|
18
|
+
enumerable = self.each
|
|
19
|
+
else
|
|
20
|
+
return nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
enumerable.each do |item|
|
|
24
|
+
result = item.recursive_find(method_name, &find_condition_block)
|
|
25
|
+
|
|
26
|
+
if not result.nil?
|
|
27
|
+
return result
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class PlayedCommands
|
|
36
|
+
def initialize
|
|
37
|
+
@played_commands = []
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def played_commands
|
|
41
|
+
@played_commands
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def any?
|
|
45
|
+
@played_commands.any?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def last
|
|
49
|
+
@played_commands.last
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def push(command)
|
|
53
|
+
@played_commands.push(command)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class FunctionWrapper
|
|
58
|
+
attr_accessor :function_class, :file_path
|
|
59
|
+
def initialize(file_path)
|
|
60
|
+
@file_path = file_path
|
|
61
|
+
@abstract_syntax_tree = RubyVM::AbstractSyntaxTree
|
|
62
|
+
.parse_file(file_path)
|
|
63
|
+
|
|
64
|
+
get_command_class_name
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def get_command_class_name
|
|
68
|
+
# if class is deeper than first level, let's invent Enumerable#recursive_find
|
|
69
|
+
@command_class_node = @abstract_syntax_tree.recursive_find(:children) do |child|
|
|
70
|
+
child.class == RubyVM::AbstractSyntaxTree::Node && child.type == :CLASS
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
@command_class_name = @command_class_node
|
|
74
|
+
.children
|
|
75
|
+
.first
|
|
76
|
+
.pretty_print_inspect
|
|
77
|
+
.match(/:(\w+)\)\Z/)[1]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def new_command_instance(gam_main_instance)
|
|
81
|
+
load(@file_path)
|
|
82
|
+
|
|
83
|
+
# SEC-TODO: fix eval, especially when considering downloadable functions
|
|
84
|
+
command_instance = eval(@command_class_name).new(gam_main_instance)
|
|
85
|
+
|
|
86
|
+
return command_instance
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def command_class_name
|
|
90
|
+
@command_class_name
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class Gam
|
|
95
|
+
SELECTED_CUBE_COLOR = 0xf4e842
|
|
96
|
+
RED = 0xf441dc
|
|
97
|
+
|
|
98
|
+
# TODO: cubes array needds to be eliminated
|
|
99
|
+
CUBES = []
|
|
100
|
+
attr_accessor :functions, :key_map, :scene, :camera
|
|
101
|
+
|
|
102
|
+
def cubes
|
|
103
|
+
CUBES
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def initialize
|
|
107
|
+
self.functions = []
|
|
108
|
+
self.key_map = {}
|
|
109
|
+
@played_commands = PlayedCommands.new
|
|
110
|
+
load_local_functions
|
|
111
|
+
|
|
112
|
+
legacy_initialize
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def played_commands
|
|
116
|
+
@played_commands
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def execute_command(command_wrapper)
|
|
120
|
+
played_commands.push(command_wrapper.new_command_instance(self))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def active_command(&block)
|
|
124
|
+
if played_commands.any? && played_commands.last.active?
|
|
125
|
+
block.call(played_commands.last)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def forever
|
|
130
|
+
sleep 1
|
|
131
|
+
while true; yield; end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def legacy_initialize
|
|
135
|
+
@cube_index = 0
|
|
136
|
+
|
|
137
|
+
@screen_width = 800
|
|
138
|
+
@screen_height = 600
|
|
139
|
+
aspect = @screen_width.to_f / @screen_height
|
|
140
|
+
|
|
141
|
+
@renderer = Mittsu::OpenGLRenderer.new(
|
|
142
|
+
width: @screen_width,
|
|
143
|
+
height: @screen_height,
|
|
144
|
+
title: 'TOOLX'
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
@scene = Mittsu::Scene.new
|
|
148
|
+
|
|
149
|
+
@camera = Mittsu::PerspectiveCamera.new(75.0, aspect, 0.1, 1000.0)
|
|
150
|
+
@camera.position.z = 5.0
|
|
151
|
+
|
|
152
|
+
@plane = Mittsu::Mesh.new(
|
|
153
|
+
Mittsu::BoxGeometry.new(1.0, 10.0, 10.0),
|
|
154
|
+
Mittsu::MeshBasicMaterial.new(color: 0x00ff00)
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
@scene.add(@plane)
|
|
158
|
+
|
|
159
|
+
waiting_for_w_console_command = false
|
|
160
|
+
|
|
161
|
+
console_function = -> {
|
|
162
|
+
unless waiting_for_w_console_command
|
|
163
|
+
waiting_for_w_console_command = true
|
|
164
|
+
puts 'Enter ruby code that will be evaluated in the current session:'
|
|
165
|
+
|
|
166
|
+
user_input = gets
|
|
167
|
+
puts "Running code u entered #{user_input}"
|
|
168
|
+
eval(user_input)
|
|
169
|
+
waiting_for_w_console_command = false
|
|
170
|
+
end
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
previously_selected_cube_color = nil
|
|
174
|
+
@renderer.window.on_key_typed do |key|
|
|
175
|
+
case key
|
|
176
|
+
when GLFW_KEY_A
|
|
177
|
+
@plane.rotation.x += 0.5
|
|
178
|
+
when GLFW_KEY_B
|
|
179
|
+
@plane.rotation.y += 0.5
|
|
180
|
+
when GLFW_KEY_C
|
|
181
|
+
@plane.rotation.x -= 0.5
|
|
182
|
+
when GLFW_KEY_D
|
|
183
|
+
@plane.rotation.y -= 0.1
|
|
184
|
+
when GLFW_KEY_E
|
|
185
|
+
@camera.position.x -= 0.1
|
|
186
|
+
when GLFW_KEY_F
|
|
187
|
+
@camera.position.y -= 0.1
|
|
188
|
+
when GLFW_KEY_G
|
|
189
|
+
@camera.position.z -= 0.1
|
|
190
|
+
when GLFW_KEY_H
|
|
191
|
+
@camera.position.x += 0.1
|
|
192
|
+
when GLFW_KEY_I
|
|
193
|
+
@camera.position.y += 0.1
|
|
194
|
+
when GLFW_KEY_J
|
|
195
|
+
@camera.position.z += 0.1
|
|
196
|
+
when GLFW_KEY_K
|
|
197
|
+
@scene.add(Cube.new(color: 0x42e5f4).mittsu_object)
|
|
198
|
+
when GLFW_KEY_L
|
|
199
|
+
@scene.add(Cube.new(color: 0xf44941).mittsu_object)
|
|
200
|
+
when GLFW_KEY_M
|
|
201
|
+
@scene.add(Cube.new(color: 0xf441dc).mittsu_object)
|
|
202
|
+
when GLFW_KEY_N
|
|
203
|
+
CUBES[@cube_index].position.x += 0.1
|
|
204
|
+
when GLFW_KEY_O
|
|
205
|
+
CUBES[@cube_index].position.x -= 0.1
|
|
206
|
+
when GLFW_KEY_P
|
|
207
|
+
CUBES[@cube_index].position.y += 0.1
|
|
208
|
+
when GLFW_KEY_R
|
|
209
|
+
CUBES[@cube_index].position.y -= 0.1
|
|
210
|
+
when GLFW_KEY_S
|
|
211
|
+
CUBES[@cube_index].material.color.set_hex(previously_selected_cube_color) if previously_selected_cube_color != nil
|
|
212
|
+
@cube_index += 1
|
|
213
|
+
if @cube_index == CUBES.length
|
|
214
|
+
@cube_index = 0
|
|
215
|
+
end
|
|
216
|
+
previously_selected_cube_color = CUBES[@cube_index].material.color.hex
|
|
217
|
+
CUBES[@cube_index].material.color.set_hex(SELECTED_CUBE_COLOR)
|
|
218
|
+
when GLFW_KEY_T
|
|
219
|
+
CUBES[@cube_index].material.color.set_hex(previously_selected_cube_color) if previously_selected_cube_color != nil
|
|
220
|
+
@cube_index -= 1
|
|
221
|
+
if @cube_index == -1
|
|
222
|
+
@cube_index = [CUBES.length - 1, 0].min
|
|
223
|
+
end
|
|
224
|
+
previously_selected_cube_color = CUBES[@cube_index].material.color.hex
|
|
225
|
+
CUBES[@cube_index].material.color.set_hex(SELECTED_CUBE_COLOR)
|
|
226
|
+
when GLFW_KEY_U
|
|
227
|
+
@scene.remove(@plane)
|
|
228
|
+
when GLFW_KEY_V
|
|
229
|
+
@scene.add(@plane)
|
|
230
|
+
when GLFW_KEY_W
|
|
231
|
+
CUBES.sample.fall_down
|
|
232
|
+
|
|
233
|
+
# while true
|
|
234
|
+
# forever { CUBES.sample.fall_down }
|
|
235
|
+
|
|
236
|
+
# sleep 0.002
|
|
237
|
+
|
|
238
|
+
# CUBES.sample.fall_down
|
|
239
|
+
# end
|
|
240
|
+
|
|
241
|
+
@cube_fall_down = true
|
|
242
|
+
|
|
243
|
+
# byebug
|
|
244
|
+
# instance_exec(&console_function)
|
|
245
|
+
when GLFW_KEY_X
|
|
246
|
+
print_local_functions
|
|
247
|
+
when GLFW_KEY_Y
|
|
248
|
+
remap_functions
|
|
249
|
+
when GLFW_KEY_Z
|
|
250
|
+
# binding.remote_pry
|
|
251
|
+
|
|
252
|
+
self.execute_command(self.key_map['z'])
|
|
253
|
+
# print_remote_functions
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
@renderer.window.on_resize do |width, height|
|
|
258
|
+
on_resize(width, height)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
raycaster = Mittsu::Raycaster.new
|
|
262
|
+
|
|
263
|
+
object_being_moved_by_mouse = nil
|
|
264
|
+
|
|
265
|
+
previously_selected_cube_color_1 = nil
|
|
266
|
+
@renderer.window.on_mouse_button_pressed do |button, position|
|
|
267
|
+
click_to_world_var = mouse_position_to_3d_position(position)
|
|
268
|
+
|
|
269
|
+
active_command do |command|
|
|
270
|
+
command.mouse_down(click_to_world_var)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
normalized = normalize_2d_screen_position(position)
|
|
274
|
+
raycaster.set_from_camera(normalized, @camera)
|
|
275
|
+
object_being_moved_by_mouse = raycaster
|
|
276
|
+
.intersect_objects(CUBES)
|
|
277
|
+
.map \
|
|
278
|
+
do |intersected_object_and_meta_information|
|
|
279
|
+
intersected_object_and_meta_information[:object]
|
|
280
|
+
end
|
|
281
|
+
.first
|
|
282
|
+
|
|
283
|
+
if object_being_moved_by_mouse
|
|
284
|
+
previously_selected_cube_color_1 = object_being_moved_by_mouse.material.color
|
|
285
|
+
object_being_moved_by_mouse.material.color = SELECTED_CUBE_COLOR
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
@renderer.window.on_mouse_move do |position|
|
|
291
|
+
click_to_world_var = mouse_position_to_3d_position(position)
|
|
292
|
+
|
|
293
|
+
active_command do |command|
|
|
294
|
+
command.mouse_move(click_to_world_var)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
unless object_being_moved_by_mouse.nil?
|
|
298
|
+
object_being_moved_by_mouse.position.x = click_to_world_var.x
|
|
299
|
+
object_being_moved_by_mouse.position.y = click_to_world_var.y
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
@renderer.window.on_mouse_button_released do |_button, position|
|
|
304
|
+
click_to_world_var = mouse_position_to_3d_position(position)
|
|
305
|
+
|
|
306
|
+
active_command do |command|
|
|
307
|
+
command.mouse_up(click_to_world_var)
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
unless object_being_moved_by_mouse.nil?
|
|
311
|
+
object_been_moved_by_mouse = object_being_moved_by_mouse
|
|
312
|
+
object_being_moved_by_mouse = nil
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
object_been_moved_by_mouse.position.x = click_to_world_var.x
|
|
316
|
+
object_been_moved_by_mouse.position.y = click_to_world_var.y
|
|
317
|
+
|
|
318
|
+
object_been_moved_by_mouse.material.color = previously_selected_cube_color_1
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
@renderer.window.on_scroll do |offset|
|
|
323
|
+
@camera.position.z += offset.y
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def on_resize(width, height)
|
|
328
|
+
@screen_width = width
|
|
329
|
+
@screen_height = height
|
|
330
|
+
|
|
331
|
+
@renderer.width = width
|
|
332
|
+
@renderer.height = height
|
|
333
|
+
|
|
334
|
+
@camera.aspect = width.to_f / height
|
|
335
|
+
@camera.update_projection_matrix
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def print_local_functions
|
|
339
|
+
p self.functions
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def load_local_functions
|
|
343
|
+
Dir[File.dirname(__FILE__) + '/functions/*.rb'].each do |file_path|
|
|
344
|
+
functions.push(FunctionWrapper.new(file_path))
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def normalize_2d_screen_position(position)
|
|
349
|
+
new_position = Mittsu::Vector2.new
|
|
350
|
+
new_position.x = (((position.x * 2)/@screen_width)*2.0-1.0)
|
|
351
|
+
new_position.y = (((position.y * 2)/@screen_height)*-2.0+1.0)
|
|
352
|
+
new_position
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def screen_to_world(vector, camera)
|
|
356
|
+
vector.unproject(camera).sub(camera.position).normalize
|
|
357
|
+
distance = -camera.position.z / vector.z
|
|
358
|
+
vector.multiply_scalar(distance).add(camera.position)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def mouse_position_to_3d_position(position)
|
|
362
|
+
normalized = normalize_2d_screen_position(position)
|
|
363
|
+
normalized_3d = Mittsu::Vector3.new(
|
|
364
|
+
normalized.x,
|
|
365
|
+
normalized.y,
|
|
366
|
+
0 # object_been_moved_by_mouse.position.z
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
screen_to_world(normalized_3d, @camera)
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
def remap_functions
|
|
373
|
+
print_local_functions
|
|
374
|
+
|
|
375
|
+
p 'Enter index of unmapped function:'
|
|
376
|
+
index_of_unmapped_function = gets.to_i
|
|
377
|
+
|
|
378
|
+
p 'Enter key to map function to:'
|
|
379
|
+
keyboard_key = gets
|
|
380
|
+
|
|
381
|
+
keyboard_key.chomp!
|
|
382
|
+
|
|
383
|
+
key_map[keyboard_key] = functions[index_of_unmapped_function]
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
def start
|
|
387
|
+
ticks = 0
|
|
388
|
+
@renderer.window.run do
|
|
389
|
+
if @cube_fall_down
|
|
390
|
+
CUBES.sample.fall_down
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
if !( (cube = CUBES).sample.nil? || @plane.nil? )
|
|
394
|
+
cube = TeZiiCube.new(cube)
|
|
395
|
+
plane = TeZiiCube.new(@plane)
|
|
396
|
+
|
|
397
|
+
fail if cube.intersects_with?(plane)
|
|
398
|
+
|
|
399
|
+
if @plane.position.y > CUBES.sample.position.y
|
|
400
|
+
ticks = 0 if ticks > 50
|
|
401
|
+
ticks += 1
|
|
402
|
+
# fail "whatever"
|
|
403
|
+
previous_color = @plane.material.color.hex
|
|
404
|
+
|
|
405
|
+
if ticks > 10
|
|
406
|
+
@plane.material.color.set_hex(0x00ff00)
|
|
407
|
+
else
|
|
408
|
+
@plane.material.color.set_hex(RED)
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
@renderer.render(@scene, @camera)
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# T for Teamwork
|
|
419
|
+
class TeZiiCube
|
|
420
|
+
attr_accessor :wrapped_3d_object
|
|
421
|
+
|
|
422
|
+
def size
|
|
423
|
+
[
|
|
424
|
+
# fail(self.wrapped_3d_object.instance_variable_get(:@geometry).instance_variable_get(:@parameters).inspect),
|
|
425
|
+
self.wrapped_3d_object.instance_variable_get(:@geometry).instance_variable_get(:@parameters)[:width].inspect,
|
|
426
|
+
self.wrapped_3d_object.instance_variable_get(:@geometry).instance_variable_get(:@parameters)[:height].inspect,
|
|
427
|
+
self.wrapped_3d_object.instance_variable_get(:@geometry).instance_variable_get(:@parameters)[:depth].inspect
|
|
428
|
+
]
|
|
429
|
+
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def initialize(wrapped_3d_object)
|
|
433
|
+
@wrapped_3d_object = wrapped_3d_object
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# type of argument: TeZiiCube
|
|
437
|
+
def intersects_with?(other_t_ezii_cube)
|
|
438
|
+
width = other_t_ezii_cube.size[0]
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
height = other_t_ezii_cube.size[1]
|
|
442
|
+
|
|
443
|
+
depth = other_t_ezii_cube.size[2]
|
|
444
|
+
|
|
445
|
+
position = other_t_ezii_cube.instance_variable_get(:@wrapped_3d_object).position
|
|
446
|
+
|
|
447
|
+
width_self = self.size[0]
|
|
448
|
+
height_self = self.size[1]
|
|
449
|
+
depth_self = self.size[2]
|
|
450
|
+
|
|
451
|
+
position_self = self.instance_variable_get(:@wrapped_3d_object).position
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
condition_1 = position.x > self_position.x && position.y > self_position.y && position.z > self_position.z
|
|
455
|
+
condition_2 = true
|
|
456
|
+
# condition_2 = position.y > self_position.x && position.y > self_position.y && position.z > self_position.z
|
|
457
|
+
# condition_3
|
|
458
|
+
# condition_4
|
|
459
|
+
# condition_5
|
|
460
|
+
# condition_6
|
|
461
|
+
condition_7 = width > width_self && height > height_self && depth > depth_self
|
|
462
|
+
|
|
463
|
+
if condition_1 && condition_2 && condition_7
|
|
464
|
+
return true
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
end
|