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.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/.rubocop.yml +7 -7
- data/.travis.yml +5 -5
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +74 -74
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/cyberarm_engine.gemspec +39 -39
- data/lib/cyberarm_engine/animator.rb +219 -219
- data/lib/cyberarm_engine/background.rb +179 -179
- data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
- data/lib/cyberarm_engine/bounding_box.rb +150 -150
- data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
- data/lib/cyberarm_engine/cache/download_manager.rb +121 -121
- data/lib/cyberarm_engine/cache.rb +4 -4
- data/lib/cyberarm_engine/common.rb +113 -113
- data/lib/cyberarm_engine/config_file.rb +46 -46
- data/lib/cyberarm_engine/console/command.rb +157 -157
- data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
- data/lib/cyberarm_engine/console/subcommand.rb +99 -99
- data/lib/cyberarm_engine/console.rb +248 -248
- data/lib/cyberarm_engine/game_object.rb +248 -248
- data/lib/cyberarm_engine/game_state.rb +97 -97
- data/lib/cyberarm_engine/model/material.rb +21 -21
- data/lib/cyberarm_engine/model/model_object.rb +131 -131
- data/lib/cyberarm_engine/model/parser.rb +74 -74
- data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
- data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
- data/lib/cyberarm_engine/model.rb +212 -212
- data/lib/cyberarm_engine/model_cache.rb +31 -31
- data/lib/cyberarm_engine/opengl/light.rb +50 -50
- data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
- data/lib/cyberarm_engine/opengl/perspective_camera.rb +38 -38
- data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
- data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +164 -164
- data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +298 -298
- data/lib/cyberarm_engine/opengl/renderer/renderer.rb +22 -22
- data/lib/cyberarm_engine/opengl/shader.rb +406 -406
- data/lib/cyberarm_engine/opengl/texture.rb +69 -69
- data/lib/cyberarm_engine/opengl.rb +28 -28
- data/lib/cyberarm_engine/ray.rb +56 -56
- data/lib/cyberarm_engine/stats.rb +21 -21
- data/lib/cyberarm_engine/text.rb +197 -197
- data/lib/cyberarm_engine/timer.rb +23 -23
- data/lib/cyberarm_engine/transform.rb +296 -296
- data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
- data/lib/cyberarm_engine/ui/dsl.rb +139 -139
- data/lib/cyberarm_engine/ui/element.rb +488 -488
- data/lib/cyberarm_engine/ui/elements/button.rb +97 -97
- data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
- data/lib/cyberarm_engine/ui/elements/container.rb +256 -256
- data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
- data/lib/cyberarm_engine/ui/elements/edit_line.rb +263 -263
- data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
- data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
- data/lib/cyberarm_engine/ui/elements/list_box.rb +88 -82
- data/lib/cyberarm_engine/ui/elements/progress.rb +51 -51
- data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
- data/lib/cyberarm_engine/ui/elements/slider.rb +104 -104
- data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
- data/lib/cyberarm_engine/ui/elements/text_block.rb +162 -162
- data/lib/cyberarm_engine/ui/elements/toggle_button.rb +65 -65
- data/lib/cyberarm_engine/ui/event.rb +54 -54
- data/lib/cyberarm_engine/ui/gui_state.rb +256 -256
- data/lib/cyberarm_engine/ui/style.rb +49 -49
- data/lib/cyberarm_engine/ui/theme.rb +207 -207
- data/lib/cyberarm_engine/vector.rb +293 -293
- data/lib/cyberarm_engine/version.rb +4 -4
- data/lib/cyberarm_engine/window.rb +120 -120
- data/lib/cyberarm_engine.rb +71 -71
- metadata +3 -3
@@ -1,21 +1,21 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class Model
|
3
|
-
class Material
|
4
|
-
attr_accessor :name, :ambient, :diffuse, :specular
|
5
|
-
attr_reader :texture_id
|
6
|
-
|
7
|
-
def initialize(name)
|
8
|
-
@name = name
|
9
|
-
@ambient = Color.new(1, 1, 1, 1)
|
10
|
-
@diffuse = Color.new(1, 1, 1, 1)
|
11
|
-
@specular = Color.new(1, 1, 1, 1)
|
12
|
-
@texture = nil
|
13
|
-
@texture_id = nil
|
14
|
-
end
|
15
|
-
|
16
|
-
def set_texture(texture_path)
|
17
|
-
@texture_id = Texture.new(path: texture_path).id
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class Model
|
3
|
+
class Material
|
4
|
+
attr_accessor :name, :ambient, :diffuse, :specular
|
5
|
+
attr_reader :texture_id
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@ambient = Color.new(1, 1, 1, 1)
|
10
|
+
@diffuse = Color.new(1, 1, 1, 1)
|
11
|
+
@specular = Color.new(1, 1, 1, 1)
|
12
|
+
@texture = nil
|
13
|
+
@texture_id = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_texture(texture_path)
|
17
|
+
@texture_id = Texture.new(path: texture_path).id
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,131 +1,131 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class Model
|
3
|
-
class ModelObject
|
4
|
-
attr_reader :id, :name, :vertices, :uvs, :normals, :materials, :bounding_box, :debug_color
|
5
|
-
attr_accessor :faces, :scale
|
6
|
-
|
7
|
-
def initialize(id, name)
|
8
|
-
@id = id
|
9
|
-
@name = name
|
10
|
-
@vertices = []
|
11
|
-
@uvs = []
|
12
|
-
@normals = []
|
13
|
-
@faces = []
|
14
|
-
@materials = []
|
15
|
-
@bounding_box = BoundingBox.new
|
16
|
-
@debug_color = Color.new(1.0, 1.0, 1.0)
|
17
|
-
|
18
|
-
@scale = 1.0
|
19
|
-
|
20
|
-
# Faces array packs everything:
|
21
|
-
# vertex = index[0]
|
22
|
-
# uv = index[1]
|
23
|
-
# normal = index[2]
|
24
|
-
# material = index[3]
|
25
|
-
end
|
26
|
-
|
27
|
-
def has_texture?
|
28
|
-
@materials.find { |mat| mat.texture_id } ? true : false
|
29
|
-
end
|
30
|
-
|
31
|
-
def reflatten
|
32
|
-
@vertices_list = nil
|
33
|
-
@uvs_list = nil
|
34
|
-
@normals_list = nil
|
35
|
-
|
36
|
-
flattened_vertices
|
37
|
-
flattened_uvs
|
38
|
-
flattened_normals
|
39
|
-
end
|
40
|
-
|
41
|
-
def flattened_vertices
|
42
|
-
unless @vertices_list
|
43
|
-
@debug_color = @faces.first.material.diffuse
|
44
|
-
|
45
|
-
list = []
|
46
|
-
@faces.each do |face|
|
47
|
-
face.vertices.each do |v|
|
48
|
-
next unless v
|
49
|
-
|
50
|
-
list << v.x * @scale
|
51
|
-
list << v.y * @scale
|
52
|
-
list << v.z * @scale
|
53
|
-
list << v.weight
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
@vertices_list_size = list.size
|
58
|
-
@vertices_list = list.pack("f*")
|
59
|
-
end
|
60
|
-
|
61
|
-
@vertices_list
|
62
|
-
end
|
63
|
-
|
64
|
-
def flattened_vertices_size
|
65
|
-
@vertices_list_size
|
66
|
-
end
|
67
|
-
|
68
|
-
def flattened_uvs
|
69
|
-
unless @uvs_list
|
70
|
-
list = []
|
71
|
-
@faces.each do |face|
|
72
|
-
face.uvs.each do |v|
|
73
|
-
next unless v
|
74
|
-
|
75
|
-
list << v.x
|
76
|
-
list << v.y
|
77
|
-
list << v.z
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
@uvs_list_size = list.size
|
82
|
-
@uvs_list = list.pack("f*")
|
83
|
-
end
|
84
|
-
|
85
|
-
@uvs_list
|
86
|
-
end
|
87
|
-
|
88
|
-
def flattened_normals
|
89
|
-
unless @normals_list
|
90
|
-
list = []
|
91
|
-
@faces.each do |face|
|
92
|
-
face.normals.each do |n|
|
93
|
-
next unless n
|
94
|
-
|
95
|
-
list << n.x
|
96
|
-
list << n.y
|
97
|
-
list << n.z
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
@normals_list_size = list.size
|
102
|
-
@normals_list = list.pack("f*")
|
103
|
-
end
|
104
|
-
|
105
|
-
@normals_list
|
106
|
-
end
|
107
|
-
|
108
|
-
def flattened_materials
|
109
|
-
unless @materials_list
|
110
|
-
list = []
|
111
|
-
@faces.each do |face|
|
112
|
-
material = face.material
|
113
|
-
next unless material
|
114
|
-
|
115
|
-
face.vertices.each do # Add material to each vertex
|
116
|
-
list << material.diffuse.red
|
117
|
-
list << material.diffuse.green
|
118
|
-
list << material.diffuse.blue
|
119
|
-
# list << material.alpha
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
@materials_list_size = list.size
|
124
|
-
@materials_list = list.pack("f*")
|
125
|
-
end
|
126
|
-
|
127
|
-
@materials_list
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class Model
|
3
|
+
class ModelObject
|
4
|
+
attr_reader :id, :name, :vertices, :uvs, :normals, :materials, :bounding_box, :debug_color
|
5
|
+
attr_accessor :faces, :scale
|
6
|
+
|
7
|
+
def initialize(id, name)
|
8
|
+
@id = id
|
9
|
+
@name = name
|
10
|
+
@vertices = []
|
11
|
+
@uvs = []
|
12
|
+
@normals = []
|
13
|
+
@faces = []
|
14
|
+
@materials = []
|
15
|
+
@bounding_box = BoundingBox.new
|
16
|
+
@debug_color = Color.new(1.0, 1.0, 1.0)
|
17
|
+
|
18
|
+
@scale = 1.0
|
19
|
+
|
20
|
+
# Faces array packs everything:
|
21
|
+
# vertex = index[0]
|
22
|
+
# uv = index[1]
|
23
|
+
# normal = index[2]
|
24
|
+
# material = index[3]
|
25
|
+
end
|
26
|
+
|
27
|
+
def has_texture?
|
28
|
+
@materials.find { |mat| mat.texture_id } ? true : false
|
29
|
+
end
|
30
|
+
|
31
|
+
def reflatten
|
32
|
+
@vertices_list = nil
|
33
|
+
@uvs_list = nil
|
34
|
+
@normals_list = nil
|
35
|
+
|
36
|
+
flattened_vertices
|
37
|
+
flattened_uvs
|
38
|
+
flattened_normals
|
39
|
+
end
|
40
|
+
|
41
|
+
def flattened_vertices
|
42
|
+
unless @vertices_list
|
43
|
+
@debug_color = @faces.first.material.diffuse
|
44
|
+
|
45
|
+
list = []
|
46
|
+
@faces.each do |face|
|
47
|
+
face.vertices.each do |v|
|
48
|
+
next unless v
|
49
|
+
|
50
|
+
list << v.x * @scale
|
51
|
+
list << v.y * @scale
|
52
|
+
list << v.z * @scale
|
53
|
+
list << v.weight
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
@vertices_list_size = list.size
|
58
|
+
@vertices_list = list.pack("f*")
|
59
|
+
end
|
60
|
+
|
61
|
+
@vertices_list
|
62
|
+
end
|
63
|
+
|
64
|
+
def flattened_vertices_size
|
65
|
+
@vertices_list_size
|
66
|
+
end
|
67
|
+
|
68
|
+
def flattened_uvs
|
69
|
+
unless @uvs_list
|
70
|
+
list = []
|
71
|
+
@faces.each do |face|
|
72
|
+
face.uvs.each do |v|
|
73
|
+
next unless v
|
74
|
+
|
75
|
+
list << v.x
|
76
|
+
list << v.y
|
77
|
+
list << v.z
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
@uvs_list_size = list.size
|
82
|
+
@uvs_list = list.pack("f*")
|
83
|
+
end
|
84
|
+
|
85
|
+
@uvs_list
|
86
|
+
end
|
87
|
+
|
88
|
+
def flattened_normals
|
89
|
+
unless @normals_list
|
90
|
+
list = []
|
91
|
+
@faces.each do |face|
|
92
|
+
face.normals.each do |n|
|
93
|
+
next unless n
|
94
|
+
|
95
|
+
list << n.x
|
96
|
+
list << n.y
|
97
|
+
list << n.z
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
@normals_list_size = list.size
|
102
|
+
@normals_list = list.pack("f*")
|
103
|
+
end
|
104
|
+
|
105
|
+
@normals_list
|
106
|
+
end
|
107
|
+
|
108
|
+
def flattened_materials
|
109
|
+
unless @materials_list
|
110
|
+
list = []
|
111
|
+
@faces.each do |face|
|
112
|
+
material = face.material
|
113
|
+
next unless material
|
114
|
+
|
115
|
+
face.vertices.each do # Add material to each vertex
|
116
|
+
list << material.diffuse.red
|
117
|
+
list << material.diffuse.green
|
118
|
+
list << material.diffuse.blue
|
119
|
+
# list << material.alpha
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
@materials_list_size = list.size
|
124
|
+
@materials_list = list.pack("f*")
|
125
|
+
end
|
126
|
+
|
127
|
+
@materials_list
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -1,74 +1,74 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
TextureCoordinate = Struct.new(:u, :v, :weight)
|
3
|
-
Point = Struct.new(:x, :y)
|
4
|
-
Color = Struct.new(:red, :green, :blue, :alpha)
|
5
|
-
Face = Struct.new(:vertices, :uvs, :normals, :colors, :material, :smoothing)
|
6
|
-
|
7
|
-
class Model
|
8
|
-
class Parser
|
9
|
-
@@parsers = []
|
10
|
-
|
11
|
-
def self.handles
|
12
|
-
raise NotImplementedError,
|
13
|
-
"Model::Parser#handles must return an array of file extensions that this parser supports"
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.inherited(parser)
|
17
|
-
@@parsers << parser
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.find(file_type)
|
21
|
-
@@parsers.find do |parser|
|
22
|
-
parser.handles.include?(file_type)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.supported_formats
|
27
|
-
@@parsers.map { |parser| parser.handles }.flatten.map { |s| ".#{s}" }.join(", ")
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize(model)
|
31
|
-
@model = model
|
32
|
-
end
|
33
|
-
|
34
|
-
def parse
|
35
|
-
end
|
36
|
-
|
37
|
-
def set_object(id: nil, name: nil)
|
38
|
-
_model = nil
|
39
|
-
|
40
|
-
if id
|
41
|
-
_model = @model.objects.find { |o| o.id == id }
|
42
|
-
elsif name
|
43
|
-
_model = @model.objects.find { |o| o.name == name }
|
44
|
-
else
|
45
|
-
raise "Must provide either an id: or name:"
|
46
|
-
end
|
47
|
-
|
48
|
-
if _model
|
49
|
-
@model.current_object = _model
|
50
|
-
else
|
51
|
-
raise "Couldn't find ModelObject!"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def change_object(id, name)
|
56
|
-
@model.objects << Model::ModelObject.new(id, name)
|
57
|
-
@model.current_object = @model.objects.last
|
58
|
-
end
|
59
|
-
|
60
|
-
def set_material(name)
|
61
|
-
@model.current_material = name
|
62
|
-
@model.current_object.materials << current_material
|
63
|
-
end
|
64
|
-
|
65
|
-
def add_material(name, material)
|
66
|
-
@model.materials[name] = material
|
67
|
-
end
|
68
|
-
|
69
|
-
def current_material
|
70
|
-
@model.materials[@model.current_material]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
TextureCoordinate = Struct.new(:u, :v, :weight)
|
3
|
+
Point = Struct.new(:x, :y)
|
4
|
+
Color = Struct.new(:red, :green, :blue, :alpha)
|
5
|
+
Face = Struct.new(:vertices, :uvs, :normals, :colors, :material, :smoothing)
|
6
|
+
|
7
|
+
class Model
|
8
|
+
class Parser
|
9
|
+
@@parsers = []
|
10
|
+
|
11
|
+
def self.handles
|
12
|
+
raise NotImplementedError,
|
13
|
+
"Model::Parser#handles must return an array of file extensions that this parser supports"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.inherited(parser)
|
17
|
+
@@parsers << parser
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find(file_type)
|
21
|
+
@@parsers.find do |parser|
|
22
|
+
parser.handles.include?(file_type)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.supported_formats
|
27
|
+
@@parsers.map { |parser| parser.handles }.flatten.map { |s| ".#{s}" }.join(", ")
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(model)
|
31
|
+
@model = model
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_object(id: nil, name: nil)
|
38
|
+
_model = nil
|
39
|
+
|
40
|
+
if id
|
41
|
+
_model = @model.objects.find { |o| o.id == id }
|
42
|
+
elsif name
|
43
|
+
_model = @model.objects.find { |o| o.name == name }
|
44
|
+
else
|
45
|
+
raise "Must provide either an id: or name:"
|
46
|
+
end
|
47
|
+
|
48
|
+
if _model
|
49
|
+
@model.current_object = _model
|
50
|
+
else
|
51
|
+
raise "Couldn't find ModelObject!"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def change_object(id, name)
|
56
|
+
@model.objects << Model::ModelObject.new(id, name)
|
57
|
+
@model.current_object = @model.objects.last
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_material(name)
|
61
|
+
@model.current_material = name
|
62
|
+
@model.current_object.materials << current_material
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_material(name, material)
|
66
|
+
@model.materials[name] = material
|
67
|
+
end
|
68
|
+
|
69
|
+
def current_material
|
70
|
+
@model.materials[@model.current_material]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|