mittsu 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build-workflow.yml +3 -38
  3. data/Gemfile +0 -4
  4. data/README.md +16 -130
  5. data/bin/console +0 -4
  6. data/lib/mittsu/cameras/cube_camera.rb +1 -1
  7. data/lib/mittsu/core/uniform.rb +23 -0
  8. data/lib/mittsu/core.rb +1 -0
  9. data/lib/mittsu/loaders/stl_loader.rb +186 -0
  10. data/lib/mittsu/loaders.rb +1 -0
  11. data/lib/mittsu/textures/render_target.rb +93 -0
  12. data/lib/mittsu/textures/render_target_cube.rb +8 -0
  13. data/lib/mittsu/textures/texture.rb +1 -1
  14. data/lib/mittsu/textures.rb +2 -0
  15. data/lib/mittsu/version.rb +1 -1
  16. data/lib/mittsu.rb +0 -1
  17. data/mittsu.gemspec +8 -12
  18. metadata +28 -199
  19. data/install-glfw.ps1 +0 -13
  20. data/lib/mittsu/renderers/generic_lib.rb +0 -125
  21. data/lib/mittsu/renderers/glfw_lib.rb +0 -64
  22. data/lib/mittsu/renderers/glfw_window.rb +0 -233
  23. data/lib/mittsu/renderers/opengl/core/buffer_geometry.rb +0 -11
  24. data/lib/mittsu/renderers/opengl/core/geometry.rb +0 -346
  25. data/lib/mittsu/renderers/opengl/core/object_3d.rb +0 -134
  26. data/lib/mittsu/renderers/opengl/lights/ambient_light.rb +0 -26
  27. data/lib/mittsu/renderers/opengl/lights/directional_light.rb +0 -35
  28. data/lib/mittsu/renderers/opengl/lights/hemisphere_light.rb +0 -39
  29. data/lib/mittsu/renderers/opengl/lights/light.rb +0 -55
  30. data/lib/mittsu/renderers/opengl/lights/point_light.rb +0 -36
  31. data/lib/mittsu/renderers/opengl/lights/spot_light.rb +0 -47
  32. data/lib/mittsu/renderers/opengl/materials/line_basic_material.rb +0 -16
  33. data/lib/mittsu/renderers/opengl/materials/material.rb +0 -274
  34. data/lib/mittsu/renderers/opengl/materials/mesh_basic_material.rb +0 -21
  35. data/lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb +0 -33
  36. data/lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb +0 -44
  37. data/lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb +0 -57
  38. data/lib/mittsu/renderers/opengl/materials/point_cloud_material.rb +0 -27
  39. data/lib/mittsu/renderers/opengl/materials/shader_material.rb +0 -11
  40. data/lib/mittsu/renderers/opengl/objects/group.rb +0 -9
  41. data/lib/mittsu/renderers/opengl/objects/line.rb +0 -45
  42. data/lib/mittsu/renderers/opengl/objects/mesh.rb +0 -70
  43. data/lib/mittsu/renderers/opengl/objects/point_cloud.rb +0 -39
  44. data/lib/mittsu/renderers/opengl/objects/sprite.rb +0 -12
  45. data/lib/mittsu/renderers/opengl/opengl_buffer.rb +0 -13
  46. data/lib/mittsu/renderers/opengl/opengl_debug.rb +0 -81
  47. data/lib/mittsu/renderers/opengl/opengl_default_target.rb +0 -50
  48. data/lib/mittsu/renderers/opengl/opengl_geometry_group.rb +0 -758
  49. data/lib/mittsu/renderers/opengl/opengl_geometry_like.rb +0 -132
  50. data/lib/mittsu/renderers/opengl/opengl_helper.rb +0 -161
  51. data/lib/mittsu/renderers/opengl/opengl_implementations.rb +0 -37
  52. data/lib/mittsu/renderers/opengl/opengl_lib.rb +0 -19
  53. data/lib/mittsu/renderers/opengl/opengl_light_renderer.rb +0 -43
  54. data/lib/mittsu/renderers/opengl/opengl_mittsu_params.rb +0 -53
  55. data/lib/mittsu/renderers/opengl/opengl_program.rb +0 -250
  56. data/lib/mittsu/renderers/opengl/opengl_shader.rb +0 -58
  57. data/lib/mittsu/renderers/opengl/opengl_state.rb +0 -205
  58. data/lib/mittsu/renderers/opengl/plugins/shadow_map_plugin.rb +0 -417
  59. data/lib/mittsu/renderers/opengl/plugins/sprite_fragment.glsl +0 -38
  60. data/lib/mittsu/renderers/opengl/plugins/sprite_plugin.rb +0 -250
  61. data/lib/mittsu/renderers/opengl/plugins/sprite_vertex.glsl +0 -31
  62. data/lib/mittsu/renderers/opengl/scenes/scene.rb +0 -9
  63. data/lib/mittsu/renderers/opengl/textures/compressed_texture.rb +0 -20
  64. data/lib/mittsu/renderers/opengl/textures/cube_texture.rb +0 -77
  65. data/lib/mittsu/renderers/opengl/textures/data_texture.rb +0 -21
  66. data/lib/mittsu/renderers/opengl/textures/texture.rb +0 -107
  67. data/lib/mittsu/renderers/opengl_render_target.rb +0 -201
  68. data/lib/mittsu/renderers/opengl_renderer.rb +0 -1028
  69. data/lib/mittsu/renderers/shaders/rbsl_loader.rb +0 -166
  70. data/lib/mittsu/renderers/shaders/shader_chunk/alphamap_fragment.glsl +0 -5
  71. data/lib/mittsu/renderers/shaders/shader_chunk/alphamap_pars_fragment.glsl +0 -5
  72. data/lib/mittsu/renderers/shaders/shader_chunk/alphatest_fragment.glsl +0 -5
  73. data/lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl +0 -40
  74. data/lib/mittsu/renderers/shaders/shader_chunk/color_fragment.glsl +0 -5
  75. data/lib/mittsu/renderers/shaders/shader_chunk/color_pars_fragment.glsl +0 -5
  76. data/lib/mittsu/renderers/shaders/shader_chunk/color_pars_vertex.glsl +0 -5
  77. data/lib/mittsu/renderers/shaders/shader_chunk/color_vertex.glsl +0 -5
  78. data/lib/mittsu/renderers/shaders/shader_chunk/common.glsl +0 -60
  79. data/lib/mittsu/renderers/shaders/shader_chunk/default_vertex.glsl +0 -15
  80. data/lib/mittsu/renderers/shaders/shader_chunk/defaultnormal_vertex.glsl +0 -21
  81. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_fragment.glsl +0 -62
  82. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_pars_fragment.glsl +0 -21
  83. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_pars_vertex.glsl +0 -7
  84. data/lib/mittsu/renderers/shaders/shader_chunk/envmap_vertex.glsl +0 -17
  85. data/lib/mittsu/renderers/shaders/shader_chunk/fog_fragment.glsl +0 -26
  86. data/lib/mittsu/renderers/shaders/shader_chunk/fog_pars_fragment.glsl +0 -15
  87. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_fragment.glsl +0 -5
  88. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_pars_fragment.glsl +0 -6
  89. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_pars_vertex.glsl +0 -5
  90. data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_vertex.glsl +0 -5
  91. data/lib/mittsu/renderers/shaders/shader_chunk/lights_lambert_pars_vertex.glsl +0 -43
  92. data/lib/mittsu/renderers/shaders/shader_chunk/lights_lambert_vertex.glsl +0 -196
  93. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_fragment.glsl +0 -243
  94. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_pars_fragment.glsl +0 -58
  95. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_pars_vertex.glsl +0 -5
  96. data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_vertex.glsl +0 -5
  97. data/lib/mittsu/renderers/shaders/shader_chunk/linear_to_gamma_fragment.glsl +0 -2
  98. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_fragment.glsl +0 -5
  99. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_pars_fragment.glsl +0 -12
  100. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_pars_vertex.glsl +0 -11
  101. data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_vertex.glsl +0 -15
  102. data/lib/mittsu/renderers/shaders/shader_chunk/map_fragment.glsl +0 -9
  103. data/lib/mittsu/renderers/shaders/shader_chunk/map_pars_fragment.glsl +0 -11
  104. data/lib/mittsu/renderers/shaders/shader_chunk/map_pars_vertex.glsl +0 -6
  105. data/lib/mittsu/renderers/shaders/shader_chunk/map_particle_fragment.glsl +0 -5
  106. data/lib/mittsu/renderers/shaders/shader_chunk/map_particle_pars_fragment.glsl +0 -6
  107. data/lib/mittsu/renderers/shaders/shader_chunk/map_vertex.glsl +0 -5
  108. data/lib/mittsu/renderers/shaders/shader_chunk/morphnormal_vertex.glsl +0 -12
  109. data/lib/mittsu/renderers/shaders/shader_chunk/morphtarget_pars_vertex.glsl +0 -13
  110. data/lib/mittsu/renderers/shaders/shader_chunk/morphtarget_vertex.glsl +0 -20
  111. data/lib/mittsu/renderers/shaders/shader_chunk/normalmap_pars_fragment.glsl +0 -27
  112. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_fragment.glsl +0 -216
  113. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_pars_fragment.glsl +0 -19
  114. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_pars_vertex.glsl +0 -6
  115. data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_vertex.glsl +0 -9
  116. data/lib/mittsu/renderers/shaders/shader_chunk/skinbase_vertex.glsl +0 -8
  117. data/lib/mittsu/renderers/shaders/shader_chunk/skinning_pars_vertex.glsl +0 -47
  118. data/lib/mittsu/renderers/shaders/shader_chunk/skinning_vertex.glsl +0 -20
  119. data/lib/mittsu/renderers/shaders/shader_chunk/skinnormal_vertex.glsl +0 -20
  120. data/lib/mittsu/renderers/shaders/shader_chunk/specularmap_fragment.glsl +0 -12
  121. data/lib/mittsu/renderers/shaders/shader_chunk/specularmap_pars_fragment.glsl +0 -5
  122. data/lib/mittsu/renderers/shaders/shader_chunk/worldpos_vertex.glsl +0 -17
  123. data/lib/mittsu/renderers/shaders/shader_chunk.rb +0 -9
  124. data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_fragment.rbsl +0 -37
  125. data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_uniforms.rbslu +0 -3
  126. data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_vertex.rbsl +0 -33
  127. data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_fragment.rbsl +0 -12
  128. data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_uniforms.rbslu +0 -2
  129. data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_vertex.rbsl +0 -12
  130. data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_fragment.rbsl +0 -26
  131. data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_uniforms.rbslu +0 -0
  132. data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_vertex.rbsl +0 -12
  133. data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_fragment.rbsl +0 -56
  134. data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_uniforms.rbslu +0 -7
  135. data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_vertex.rbsl +0 -37
  136. data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_fragment.rbsl +0 -27
  137. data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_uniforms.rbslu +0 -2
  138. data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_vertex.rbsl +0 -25
  139. data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_fragment.rbsl +0 -45
  140. data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_uniforms.rbslu +0 -11
  141. data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_vertex.rbsl +0 -43
  142. data/lib/mittsu/renderers/shaders/shader_lib.rb +0 -43
  143. data/lib/mittsu/renderers/shaders/shader_templates/fragment.glsl.erb +0 -105
  144. data/lib/mittsu/renderers/shaders/shader_templates/vertex.glsl.erb +0 -143
  145. data/lib/mittsu/renderers/shaders/uniforms_lib.rb +0 -106
  146. data/lib/mittsu/renderers/shaders/uniforms_utils.rb +0 -31
  147. data/lib/mittsu/renderers.rb +0 -1
@@ -1,758 +0,0 @@
1
- require 'mittsu/renderers/opengl/opengl_geometry_like'
2
-
3
- module Mittsu
4
- class OpenGLGeometryGroup
5
- include OpenGLGeometryLike
6
-
7
- attr_reader :id, :material_index
8
-
9
- alias :initted_arrays? :initted_arrays
10
-
11
- def initialize material_index, num_morph_targets, num_morph_normals, renderer
12
- @id = (@@id ||= 1).tap { @@id += 1 }
13
-
14
- @faces3 = []
15
- @num_vertices = 0
16
-
17
- @material_index = material_index
18
-
19
- @num_morph_targets = num_morph_targets
20
- @num_morph_normals = num_morph_normals
21
-
22
- @renderer = renderer
23
- @custom_attributes_list = []
24
- end
25
-
26
- def create_mesh_buffers
27
- @vertex_array_object = glCreateVertexArray
28
-
29
- @vertex_buffer = glCreateBuffer
30
- @normal_buffer = glCreateBuffer
31
- @tangent_buffer = glCreateBuffer
32
- @color_buffer = glCreateBuffer
33
- @uv_buffer = glCreateBuffer
34
- @uv2_buffer = glCreateBuffer
35
-
36
- @skin_indices_buffer = glCreateBuffer
37
- @skin_weights_buffer = glCreateBuffer
38
-
39
- @face_buffer = glCreateBuffer
40
- @line_buffer = glCreateBuffer
41
-
42
- if !@num_morph_targets.nil?
43
- @morph_targets_buffers = []
44
-
45
- @num_morph_targets.times do |m|
46
- @morph_targets_buffers << glCreateBuffer
47
- end
48
- end
49
-
50
- if !@num_morph_normals.nil?
51
- @morph_normals_buffers = []
52
-
53
- @num_morph_normals.times do |m|
54
- @morph_normals_buffers << glCreateBuffer
55
- end
56
- end
57
- end
58
-
59
- def init_mesh_buffers(object)
60
- geometry = object.geometry
61
-
62
- nvertices = @faces3.length * 3
63
- nvertices2 = nvertices * 2
64
- nvertices3 = nvertices * 3
65
- nvertices4 = nvertices * 4
66
- ntris = @faces3.length * 1
67
- nlines = @faces3.length * 3
68
-
69
- material = object.buffer_material(self)
70
-
71
- @vertex_array = Array.new(nvertices3) # Float32Array
72
- @normal_array = Array.new(nvertices3) # Float32Array
73
- @color_array = Array.new(nvertices3) # Float32Array
74
- @uv_array = Array.new(nvertices2) # Float32Array
75
-
76
- if geometry.face_vertex_uvs.length > 1
77
- @uv2_array = Array.new(nvertices2) # Float32Array
78
- end
79
-
80
- if geometry.has_tangents
81
- @tangent_array = Array.new(nvertices4) # Float32Array
82
- end
83
-
84
- if !object.geometry.skin_weights.empty? && !object.geometry.skin_indices.empty?
85
- @skin_indices_array = Array.new(nvertices4) # Float32Array
86
- @skin_weight_array = Array.new(nvertices4)
87
- end
88
-
89
- # UintArray from OES_element_index_uint ???
90
-
91
- @type_array = Array # UintArray ???
92
- @face_array = Array.new(ntris * 3)
93
- @line_array = Array.new(nlines * 2)
94
-
95
- num_morph_targets = @num_morph_targets
96
-
97
- if !num_morph_targets.zero?
98
- @morph_targets_arrays = []
99
-
100
- num_morph_targets.times do |m|
101
- @morph_targets_arrays << Array.new(nvertices3) # Float32Array ???
102
- end
103
- end
104
-
105
- num_morph_normals = @num_morph_normals
106
-
107
- if !num_morph_targets.zero?
108
- @morph_normals_arrays = []
109
-
110
- num_morph_normals.times do |m|
111
- @morph_normals_arrays << Array.new(nvertices3) # Float32Array ???
112
- end
113
- end
114
-
115
- @face_count = ntris * 3
116
- @line_count = nlines * 2
117
-
118
- # custom attributes
119
-
120
- if material.attributes
121
- if @custom_attributes_list.nil?
122
- @custom_attributes_list = []
123
- end
124
-
125
- material.attributes.each do |(name, original_attribute)|
126
- attribute = {}
127
- original_attribute.each do |(key, value)|
128
- attribute[key] = value
129
- end
130
-
131
- if !attribute[:_opengl_initialized] || attribute[:create_unique_buffers]
132
- attribute[:_opengl_initialized] = true
133
-
134
- size = case attribute[:type]
135
- when :v2 then 2
136
- when :v3, :c then 3
137
- when :v4 then 4
138
- else 1 # :f and :i
139
- end
140
-
141
- attribute[:size] = size
142
- attribute[:array] = Array.new(nvertices * size) # Float32Array
143
-
144
- attribute[:buffer] = glCreateBuffer
145
- attribute[:buffer_belongs_to_attribute] = name
146
-
147
- original_attribute[:needs_update] = true
148
- attribute[:_original] = original_attribute
149
- end
150
-
151
- @custom_attributes_list << attribute
152
- end
153
- end
154
-
155
- @initted_arrays = true
156
- end
157
-
158
- def set_mesh_buffers(object, hint, should_dispose, material)
159
- return unless @initted_arrays
160
-
161
- geometry = object.geometry
162
-
163
- needs_face_normals = material.needs_face_normals?
164
-
165
- vertex_index = 0
166
-
167
- offset = 0
168
- offset_uv = 0
169
- offset_uv2 = 0
170
- offset_face = 0
171
- offset_normal = 0
172
- offset_tangent = 0
173
- offset_line = 0
174
- offset_color = 0
175
- offset_skin = 0
176
- offset_morph_target = 0
177
- offset_custom = 0
178
-
179
- vertices = geometry.vertices
180
- obj_faces = geometry.faces
181
-
182
- obj_uvs = geometry.face_vertex_uvs[0]
183
- obj_uvs2 = geometry.face_vertex_uvs[1]
184
-
185
- obj_skin_indices = geometry.skin_indices
186
- obj_skin_weights = geometry.skin_weights
187
-
188
- morph_targets = geometry.morph_targets
189
- morph_normals = geometry.morph_normals
190
-
191
- if geometry.vertices_need_update
192
- @faces3.each do |chf|
193
- face = obj_faces[chf]
194
-
195
- v1 = vertices[face.a]
196
- v2 = vertices[face.b]
197
- v3 = vertices[face.c]
198
-
199
- @vertex_array[offset] = v1.x
200
- @vertex_array[offset + 1] = v1.y
201
- @vertex_array[offset + 2] = v1.z
202
-
203
- @vertex_array[offset + 3] = v2.x
204
- @vertex_array[offset + 4] = v2.y
205
- @vertex_array[offset + 5] = v2.z
206
-
207
- @vertex_array[offset + 6] = v3.x
208
- @vertex_array[offset + 7] = v3.y
209
- @vertex_array[offset + 8] = v3.z
210
-
211
- offset += 9
212
- end
213
-
214
- glBindBuffer(GL_ARRAY_BUFFER, @vertex_buffer)
215
- glBufferData_easy(GL_ARRAY_BUFFER, @vertex_array, hint)
216
- end
217
-
218
- if geometry.morph_targets_need_update
219
- morph_targets.each_index do |vk|
220
- @faces3.each do |chf|
221
- face = obj_faces[chf]
222
-
223
- # morph positions
224
-
225
- v1 = morph_targets[vk].vertices[face.a]
226
- v2 = morph_targets[vk].vertices[face.b]
227
- v3 = morph_targets[vk].vertices[face.c]
228
-
229
- vka = @morph_targets_arrays[vk]
230
-
231
- vka[offset_morph_target] = v1.x
232
- vka[offset_morph_target + 1] = v1.y
233
- vka[offset_morph_target + 2] = v1.z
234
-
235
- vka[offset_morph_target + 3] = v2.x
236
- vka[offset_morph_target + 4] = v2.y
237
- vka[offset_morph_target + 5] = v2.z
238
-
239
- vka[offset_morph_target + 6] = v3.x
240
- vka[offset_morph_target + 7] = v3.y
241
- vka[offset_morph_target + 8] = v3.z
242
-
243
- # morph normals
244
-
245
- if material.morph_normals
246
- if needs_face_normals
247
- n1 = morph_normals[vk].face_normals[chf]
248
- n2 = n1
249
- n3 = n1
250
- else
251
- face_vertex_normals = morph_normals[vk].vertex_normals[chf]
252
-
253
- n1 = face_vertex_normals.a
254
- n2 = face_vertex_normals.b
255
- n3 = face_vertex_normals.c
256
- end
257
-
258
- nka = @morph_normals_arrays[vk]
259
-
260
- nka[offset_morph_target] = n1.x
261
- nka[offset_morph_target + 1] = n1.y
262
- nka[offset_morph_target + 2] = n1.z
263
-
264
- nka[offset_morph_target + 3] = n2.x
265
- nka[offset_morph_target + 4] = n2.y
266
- nka[offset_morph_target + 5] = n2.z
267
-
268
- nka[offset_morph_target + 6] = n3.x
269
- nka[offset_morph_target + 7] = n3.y
270
- nka[offset_morph_target + 8] = n3.z
271
- end
272
-
273
- #
274
-
275
- offset_morph_target += 9
276
- end
277
-
278
- glBindBuffer(GL_ARRAY_BUFFER, @morph_targets_buffers[vk])
279
- glBufferData_easy(GL_ARRAY_BUFFER, @morph_targets_arrays[vk], hint)
280
-
281
- if material.morph_normals
282
- glBindBuffer(GL_ARRAY_BUFFER, @morph_normals_buffers[vk])
283
- glBufferData_easy(GL_ARRAY_BUFFER, @morph_normals_arrays[vk], hint)
284
- end
285
- end
286
- end
287
-
288
- if !obj_skin_weights.empty?
289
- @faces3.each do |chf|
290
- face = obj_faces[chf]
291
-
292
- # weights
293
-
294
- sw1 = obj_skin_weights[face.a]
295
- sw2 = obj_skin_weights[face.b]
296
- sw3 = obj_skin_weights[face.c]
297
-
298
- @skin_weight_array[offset_skin] = sw1.x
299
- @skin_weight_array[offset_skin + 1] = sw1.y
300
- @skin_weight_array[offset_skin + 2] = sw1.z
301
- @skin_weight_array[offset_skin + 3] = sw1.w
302
-
303
- @skin_weight_array[offset_skin + 4] = sw2.x
304
- @skin_weight_array[offset_skin + 5] = sw2.y
305
- @skin_weight_array[offset_skin + 6] = sw2.z
306
- @skin_weight_array[offset_skin + 7] = sw2.w
307
-
308
- @skin_weight_array[offset_skin + 8] = sw3.x
309
- @skin_weight_array[offset_skin + 9] = sw3.y
310
- @skin_weight_array[offset_skin + 10] = sw3.z
311
- @skin_weight_array[offset_skin + 11] = sw3.w
312
-
313
- # indices
314
-
315
- si1 = obj_skin_indices[face.a]
316
- si2 = obj_skin_indices[face.b]
317
- si3 = obj_skin_indices[face.c]
318
-
319
- @skin_indices_array[offset_skin] = si1.x
320
- @skin_indices_array[offset_skin + 1] = si1.y
321
- @skin_indices_array[offset_skin + 2] = si1.z
322
- @skin_indices_array[offset_skin + 3] = si1.w
323
-
324
- @skin_indices_array[offset_skin + 4] = si2.x
325
- @skin_indices_array[offset_skin + 5] = si2.y
326
- @skin_indices_array[offset_skin + 6] = si2.z
327
- @skin_indices_array[offset_skin + 7] = si2.w
328
-
329
- @skin_indices_array[offset_skin + 8] = si3.x
330
- @skin_indices_array[offset_skin + 9] = si3.y
331
- @skin_indices_array[offset_skin + 10] = si3.z
332
- @skin_indices_array[offset_skin + 11] = si3.w
333
-
334
- offset_skin += 12
335
- end
336
-
337
- if offset_skin > 0
338
- glBindBuffer(GL_ARRAY_BUFFER, @skin_indices_buffer)
339
- glBufferData_easy(GL_ARRAY_BUFFER, @skin_indices_array, hint)
340
-
341
- glBindBuffer(GL_ARRAY_BUFFER, @skin_weights_buffer)
342
- glBufferData_easy(GL_ARRAY_BUFFER, @skin_weight_array, hint)
343
- end
344
- end
345
-
346
- if geometry.colors_need_update
347
- @faces3.each do |chf|
348
- face = obj_faces[chf]
349
-
350
- face_vertex_colors = face.vertex_colors
351
- face_color = face.color
352
-
353
- if face_vertex_colors.length == 3 && material.vertex_colors == VertexColors
354
- c1 = face_vertex_colors[0]
355
- c2 = face_vertex_colors[1]
356
- c3 = face_vertex_colors[2]
357
- else
358
- c1 = face_color
359
- c2 = face_color
360
- c3 = face_color
361
- end
362
-
363
- @color_array[offset_color] = c1.r
364
- @color_array[offset_color + 1] = c1.g
365
- @color_array[offset_color + 2] = c1.b
366
-
367
- @color_array[offset_color + 3] = c2.r
368
- @color_array[offset_color + 4] = c2.g
369
- @color_array[offset_color + 5] = c2.b
370
-
371
- @color_array[offset_color + 6] = c3.r
372
- @color_array[offset_color + 7] = c3.g
373
- @color_array[offset_color + 8] = c3.b
374
-
375
- offset_color += 9
376
- end
377
-
378
- if offset_color > 0
379
- glBindBuffer(GL_ARRAY_BUFFER, @color_buffer)
380
- glBufferData_easy(GL_ARRAY_BUFFER, @color_array, hint)
381
- end
382
- end
383
-
384
- if geometry.tangents_need_update && geometry.has_tangents
385
- @faces3.each do |chf|
386
- face = obj_faces[chf]
387
-
388
- face_vertex_tangents = face.vertex_tangents
389
-
390
- t1 = face_vertex_tangents[0]
391
- t2 = face_vertex_tangents[1]
392
- t3 = face_vertex_tangents[2]
393
-
394
- @tangent_array[offset_tangent] = t1.x
395
- @tangent_array[offset_tangent + 1] = t1.y
396
- @tangent_array[offset_tangent + 2] = t1.z
397
- @tangent_array[offset_tangent + 3] = t1.w
398
-
399
- @tangent_array[offset_tangent + 4] = t2.x
400
- @tangent_array[offset_tangent + 5] = t2.y
401
- @tangent_array[offset_tangent + 6] = t2.z
402
- @tangent_array[offset_tangent + 7] = t2.w
403
-
404
- @tangent_array[offset_tangent + 8] = t3.x
405
- @tangent_array[offset_tangent + 9] = t3.y
406
- @tangent_array[offset_tangent + 10] = t3.z
407
- @tangent_array[offset_tangent + 11] = t3.w
408
-
409
- offset_tangent += 12
410
- end
411
-
412
- glBindBuffer(GL_ARRAY_BUFFER, @angent_buffer)
413
- glBufferData_easy(GL_ARRAY_BUFFER, @tangent_array, hint)
414
- end
415
-
416
- if geometry.normals_need_update
417
- @faces3.each do |chf|
418
- face = obj_faces[chf]
419
-
420
- face_vertex_normals = face.vertex_normals
421
- face_normal = face.normal
422
-
423
- if face_vertex_normals.length == 3 && !needs_face_normals
424
- 3.times do |i|
425
- vn = face_vertex_normals[i]
426
-
427
- @normal_array[offset_normal] = vn.x
428
- @normal_array[offset_normal + 1] = vn.y
429
- @normal_array[offset_normal + 2] = vn.z
430
-
431
- offset_normal += 3
432
- end
433
- else
434
- 3.times do |i|
435
- @normal_array[offset_normal] = face_normal.x
436
- @normal_array[offset_normal + 1] = face_normal.y
437
- @normal_array[offset_normal + 2] = face_normal.z
438
-
439
- offset_normal += 3
440
- end
441
- end
442
- end
443
-
444
- glBindBuffer(GL_ARRAY_BUFFER, @normal_buffer)
445
- glBufferData_easy(GL_ARRAY_BUFFER, @normal_array, hint)
446
- end
447
-
448
- if geometry.uvs_need_update && obj_uvs
449
- @faces3.each do |fi|
450
- uv = obj_uvs[fi]
451
-
452
- next if uv.nil?
453
-
454
- 3.times do |i|
455
- uvi = uv[i]
456
-
457
- @uv_array[offset_uv] = uvi.x
458
- @uv_array[offset_uv + 1] = uvi.y
459
-
460
- offset_uv += 2
461
- end
462
- end
463
-
464
- if offset_uv > 0
465
- glBindBuffer(GL_ARRAY_BUFFER, @uv_buffer)
466
- glBufferData_easy(GL_ARRAY_BUFFER, @uv_array, hint)
467
- end
468
- end
469
-
470
- if geometry.uvs_need_update && obj_uvs2
471
- @faces3.each do |fi|
472
- uv2 = obj_uvs2[fi]
473
-
474
- next if uv2.nil?
475
-
476
- 3.times do |i|
477
- uv2i = uv2[i]
478
-
479
- @uv2_array[offset_uv2] = uv2i.x
480
- @uv2_array[offset_uv2 + 1] = uv2i.y
481
-
482
- offset_uv2 += 2
483
- end
484
- end
485
-
486
- if offset_uv2 > 0
487
- glBindBuffer(GL_ARRAY_BUFFER, @uv2_buffer)
488
- glBufferData_easy(GL_ARRAY_BUFFER, @uv2_array, hint)
489
- end
490
- end
491
-
492
- if geometry.elements_need_update
493
- @faces3.each do |chf|
494
- @face_array[offset_face] = vertex_index
495
- @face_array[offset_face + 1] = vertex_index + 1
496
- @face_array[offset_face + 2] = vertex_index + 2
497
-
498
- offset_face += 3
499
-
500
- @line_array[offset_line] = vertex_index
501
- @line_array[offset_line + 1] = vertex_index + 1
502
-
503
- @line_array[offset_line + 2] = vertex_index
504
- @line_array[offset_line + 3] = vertex_index + 2
505
-
506
- @line_array[offset_line + 4] = vertex_index + 1
507
- @line_array[offset_line + 5] = vertex_index + 2
508
-
509
- offset_line += 6
510
-
511
- vertex_index += 3
512
- end
513
-
514
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, @face_buffer)
515
- glBufferData_easy(GL_ELEMENT_ARRAY_BUFFER, @face_array, hint)
516
-
517
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, @line_buffer)
518
- glBufferData_easy(GL_ELEMENT_ARRAY_BUFFER, @line_array, hint)
519
- end
520
-
521
- if @custom_attributes_list
522
- @custom_attributes_list.each do |custom_attribute|
523
- next if !custom_attribute[:_original][:needs_update]
524
-
525
- offset_custom = 0
526
-
527
- if custom_attribute[:size] == 1
528
- if custom_attribute[:bound_to].nil? || custom_attribute[:bound_to] == :vertices
529
- @faces3.each do |chf|
530
- face = obj_faces[chf]
531
-
532
- custom_attribute[:array][offset_custom] = custom_attribute[:value][face.a]
533
- custom_attribute[:array][offset_custom + 1] = custom_attribute[:value][face.b]
534
- custom_attribute[:array][offset_custom + 2] = custom_attribute[:value][face.c]
535
-
536
- offset_custom += 3
537
- end
538
- elsif custom_attribute[:bound_to] == :faces
539
- value = custom_attribute[:value][chf]
540
-
541
- custom_attribute[:array][offset_custom] = value
542
- custom_attribute[:array][offset_custom + 1] = value
543
- custom_attribute[:array][offset_custom + 2] = value
544
-
545
- offset_custom += 3
546
- end
547
- elsif custom_attribute[:size] == 2
548
- if custom_attribute[:bound_to].nil? || custom_attribute[:bound_to] == :vertices
549
- @faces3.each do |chf|
550
- face = obj_faces[chf]
551
-
552
- v1 = custom_attribute[:value][face.a]
553
- v2 = custom_attribute[:value][face.b]
554
- v3 = custom_attribute[:value][face.c]
555
-
556
- custom_attribute[:array][offset_custom] = v1.x
557
- custom_attribute[:array][offset_custom + 1] = v1.y
558
-
559
- custom_attribute[:array][offset_custom + 2] = v2.x
560
- custom_attribute[:array][offset_custom + 3] = v2.y
561
-
562
- custom_attribute[:array][offset_custom + 4] = v3.x
563
- custom_attribute[:array][offset_custom + 5] = v3.y
564
-
565
- offset_custom += 6
566
- end
567
- elsif custom_attribute[:bound_to] == :faces
568
- @faces3.each do |chf|
569
- value = custom_attribute[:value][chf]
570
-
571
- v1 = value
572
- v2 = value
573
- v3 = value
574
-
575
- custom_attribute[:array][offset_custom] = v1.x
576
- custom_attribute[:array][offset_custom + 1] = v1.y
577
-
578
- custom_attribute[:array][offset_custom + 2] = v2.x
579
- custom_attribute[:array][offset_custom + 3] = v2.y
580
-
581
- custom_attribute[:array][offset_custom + 4] = v3.x
582
- custom_attribute[:array][offset_custom + 5] = v3.y
583
-
584
- offset_custom += 6
585
- end
586
- end
587
- elsif custom_attribute[:size] == 3
588
- if custom_attribute[:bound_to].nil? || custom_attribute[:bound_to] == :vertices
589
- @faces3.each do |chf|
590
- face = obj_faces[chf];
591
-
592
- v1 = custom_attribute[:value][face.a]
593
- v2 = custom_attribute[:value][face.b]
594
- v3 = custom_attribute[:value][face.c]
595
-
596
- custom_attribute[:array][offset_custom] = v1[0]
597
- custom_attribute[:array][offset_custom + 1] = v1[1]
598
- custom_attribute[:array][offset_custom + 2] = v1[2]
599
-
600
- custom_attribute[:array][offset_custom + 3] = v2[0]
601
- custom_attribute[:array][offset_custom + 4] = v2[1]
602
- custom_attribute[:array][offset_custom + 5] = v2[2]
603
-
604
- custom_attribute[:array][offset_custom + 6] = v3[0]
605
- custom_attribute[:array][offset_custom + 7] = v3[1]
606
- custom_attribute[:array][offset_custom + 8] = v3[2]
607
-
608
- offset_custom += 9
609
- end
610
- elsif custom_attribute[:bound_to] == :faces
611
- @faces3.each do |chf|
612
- value = custom_attribute[:value][chf]
613
-
614
- v1 = value
615
- v2 = value
616
- v3 = value
617
-
618
- custom_attribute[:array][offset_custom] = v1[0]
619
- custom_attribute[:array][offset_custom + 1] = v1[1]
620
- custom_attribute[:array][offset_custom + 2] = v1[2]
621
-
622
- custom_attribute[:array][offset_custom + 3] = v2[0]
623
- custom_attribute[:array][offset_custom + 4] = v2[1]
624
- custom_attribute[:array][offset_custom + 5] = v2[2]
625
-
626
- custom_attribute[:array][offset_custom + 6] = v3[0]
627
- custom_attribute[:array][offset_custom + 7] = v3[1]
628
- custom_attribute[:array][offset_custom + 8] = v3[2]
629
-
630
- offset_custom += 9
631
- end
632
- elsif custom_attribute[:bound_to] == :face_vertices
633
- @faces3.each do |chf|
634
- value = custom_attribute[:value][chf]
635
-
636
- v1 = value[0]
637
- v2 = value[1]
638
- v3 = value[2]
639
-
640
- custom_attribute[:array][offset_custom] = v1[0]
641
- custom_attribute[:array][offset_custom + 1] = v1[1]
642
- custom_attribute[:array][offset_custom + 2] = v1[2]
643
-
644
- custom_attribute[:array][offset_custom + 3] = v2[0]
645
- custom_attribute[:array][offset_custom + 4] = v2[1]
646
- custom_attribute[:array][offset_custom + 5] = v2[2]
647
-
648
- custom_attribute[:array][offset_custom + 6] = v3[0]
649
- custom_attribute[:array][offset_custom + 7] = v3[1]
650
- custom_attribute[:array][offset_custom + 8] = v3[2]
651
-
652
- offset_custom += 9
653
- end
654
- end
655
- elsif custom_attribute[:size] == 4
656
- if custom_attribute[:bound_to].nil? || custom_attribute[:bound_to] == :vertices
657
- @faces3.each do |chf|
658
- face = obj_faces[chf]
659
-
660
- v1 = custom_attribute[:value][face.a]
661
- v2 = custom_attribute[:value][face.b]
662
- v3 = custom_attribute[:value][face.c]
663
-
664
- custom_attribute[:array][offset_custom] = v1.x
665
- custom_attribute[:array][offset_custom + 1 ] = v1.y
666
- custom_attribute[:array][offset_custom + 2 ] = v1.z
667
- custom_attribute[:array][offset_custom + 3 ] = v1.w
668
-
669
- custom_attribute[:array][offset_custom + 4 ] = v2.x
670
- custom_attribute[:array][offset_custom + 5 ] = v2.y
671
- custom_attribute[:array][offset_custom + 6 ] = v2.z
672
- custom_attribute[:array][offset_custom + 7 ] = v2.w
673
-
674
- custom_attribute[:array][offset_custom + 8 ] = v3.x
675
- custom_attribute[:array][offset_custom + 9 ] = v3.y
676
- custom_attribute[:array][offset_custom + 10] = v3.z
677
- custom_attribute[:array][offset_custom + 11] = v3.w
678
-
679
- offset_custom += 12
680
- end
681
- elsif custom_attribute[:bound_to] == :faces
682
- @faces3.each do |chf|
683
- value = custom_attribute[:value][chf]
684
-
685
- v1 = value
686
- v2 = value
687
- v3 = value
688
-
689
- custom_attribute[:array][offset_custom] = v1.x
690
- custom_attribute[:array][offset_custom + 1 ] = v1.y
691
- custom_attribute[:array][offset_custom + 2 ] = v1.z
692
- custom_attribute[:array][offset_custom + 3 ] = v1.w
693
-
694
- custom_attribute[:array][offset_custom + 4 ] = v2.x
695
- custom_attribute[:array][offset_custom + 5 ] = v2.y
696
- custom_attribute[:array][offset_custom + 6 ] = v2.z
697
- custom_attribute[:array][offset_custom + 7 ] = v2.w
698
-
699
- custom_attribute[:array][offset_custom + 8 ] = v3.x
700
- custom_attribute[:array][offset_custom + 9 ] = v3.y
701
- custom_attribute[:array][offset_custom + 10] = v3.z
702
- custom_attribute[:array][offset_custom + 11] = v3.w
703
-
704
- offset_custom += 12
705
- end
706
- elsif custom_attribute[:bound_to] == :face_vertices
707
- @faces3.each do |chf|
708
- value = custom_attribute[:value][chf]
709
-
710
- v1 = value[0]
711
- v2 = value[1]
712
- v3 = value[2]
713
-
714
- custom_attribute[:array][offset_custom] = v1.x
715
- custom_attribute[:array][offset_custom + 1 ] = v1.y
716
- custom_attribute[:array][offset_custom + 2 ] = v1.z
717
- custom_attribute[:array][offset_custom + 3 ] = v1.w
718
-
719
- custom_attribute[:array][offset_custom + 4 ] = v2.x
720
- custom_attribute[:array][offset_custom + 5 ] = v2.y
721
- custom_attribute[:array][offset_custom + 6 ] = v2.z
722
- custom_attribute[:array][offset_custom + 7 ] = v2.w
723
-
724
- custom_attribute[:array][offset_custom + 8 ] = v3.x
725
- custom_attribute[:array][offset_custom + 9 ] = v3.y
726
- custom_attribute[:array][offset_custom + 10] = v3.z
727
- custom_attribute[:array][offset_custom + 11] = v3.w
728
-
729
- offset_custom += 12
730
- end
731
- end
732
- end
733
-
734
- glBindBuffer(GL_ARRAY_BUFFER, custom_attribute[:buffer])
735
- glBufferData_easy(GL_ARRAY_BUFFER, custom_attribute[:array], hint)
736
- end
737
- end
738
-
739
- if should_dispose
740
- self.dispose
741
- end
742
- end
743
-
744
- def dispose
745
- @initted_arrays = nil
746
- @color_array = nil
747
- @normal_array = nil
748
- @tangent_array = nil
749
- @uv_array = nil
750
- @uv2_array = nil
751
- @face_array = nil
752
- @vertex_array = nil
753
- @line_array = nil
754
- @skin_index_array = nil
755
- @skin_weight_array = nil
756
- end
757
- end
758
- end