raylib-bindings 0.5.6 → 0.5.8pre1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/raylib_helper.rb CHANGED
@@ -1,376 +1,400 @@
1
- # Yet another raylib wrapper for Ruby
2
- #
3
- # * https://github.com/vaiorabbit/raylib-bindings
4
-
5
- module Raylib
6
- #
7
- # Color helper
8
- #
9
-
10
- class Color
11
- def self.from_u8(r = 0, g = 0, b = 0, a = 255)
12
- Color.new.set(r, g, b, a)
13
- end
14
-
15
- def set(r, g, b, a)
16
- self[:r] = r
17
- self[:g] = g
18
- self[:b] = b
19
- self[:a] = a
20
- self
21
- end
22
- end
23
-
24
- LIGHTGRAY = Color.from_u8(200, 200, 200, 255)
25
- GRAY = Color.from_u8(130, 130, 130, 255)
26
- DARKGRAY = Color.from_u8(80, 80, 80, 255)
27
- YELLOW = Color.from_u8(253, 249, 0, 255)
28
- GOLD = Color.from_u8(255, 203, 0, 255)
29
- ORANGE = Color.from_u8(255, 161, 0, 255)
30
- PINK = Color.from_u8(255, 109, 194, 255)
31
- RED = Color.from_u8(230, 41, 55, 255)
32
- MAROON = Color.from_u8(190, 33, 55, 255)
33
- GREEN = Color.from_u8(0, 228, 48, 255)
34
- LIME = Color.from_u8(0, 158, 47, 255)
35
- DARKGREEN = Color.from_u8(0, 117, 44, 255)
36
- SKYBLUE = Color.from_u8(102, 191, 255, 255)
37
- BLUE = Color.from_u8(0, 121, 241, 255)
38
- DARKBLUE = Color.from_u8(0, 82, 172, 255)
39
- PURPLE = Color.from_u8(200, 122, 255, 255)
40
- VIOLET = Color.from_u8(135, 60, 190, 255)
41
- DARKPURPLE = Color.from_u8(112, 31, 126, 255)
42
- BEIGE = Color.from_u8(211, 176, 131, 255)
43
- BROWN = Color.from_u8(127, 106, 79, 255)
44
- DARKBROWN = Color.from_u8(76, 63, 47, 255)
45
-
46
- WHITE = Color.from_u8(255, 255, 255, 255)
47
- BLACK = Color.from_u8(0, 0, 0, 255)
48
- BLANK = Color.from_u8(0, 0, 0, 0)
49
- MAGENTA = Color.from_u8(255, 0, 255, 255)
50
- RAYWHITE = Color.from_u8(245, 245, 245, 255)
51
-
52
- #
53
- # Math helper
54
- #
55
-
56
- class Vector2
57
- def self.create(x = 0, y = 0)
58
- Vector2.new.set(x, y)
59
- end
60
-
61
- def self.copy_from(vec)
62
- Vector2.create(vec[:x], vec[:y])
63
- end
64
-
65
- def set(x, y)
66
- self[:x] = x
67
- self[:y] = y
68
- self
69
- end
70
- end
71
-
72
- class Vector3
73
- def self.create(x = 0, y = 0, z = 0)
74
- Vector3.new.set(x, y, z)
75
- end
76
-
77
- def self.copy_from(vec)
78
- Vector3.create(vec[:x], vec[:y], vec[:z])
79
- end
80
-
81
- def set(x, y, z)
82
- self[:x] = x
83
- self[:y] = y
84
- self[:z] = z
85
- self
86
- end
87
- end
88
-
89
- class Vector4
90
- def self.create(x = 0, y = 0, z = 0, w = 0)
91
- Vector4.new.set(x, y, z, w)
92
- end
93
-
94
- def self.copy_from(vec)
95
- Vector4.create(vec[:x], vec[:y], vec[:z], vec[:w])
96
- end
97
-
98
- def set(x, y, z, w)
99
- self[:x] = x
100
- self[:y] = y
101
- self[:z] = z
102
- self[:w] = w
103
- self
104
- end
105
- end
106
-
107
- class Quaternion
108
- def self.create(x = 0, y = 0, z = 0, w = 0)
109
- Quaternion.new.set(x, y, z, w)
110
- end
111
-
112
- def self.copy_from(quat)
113
- Quaternion.create(quat[:x], quat[:y], quat[:z], quat[:w])
114
- end
115
-
116
- def set(x, y, z, w)
117
- self[:x] = x
118
- self[:y] = y
119
- self[:z] = z
120
- self[:w] = w
121
- self
122
- end
123
- end
124
-
125
- class Rectangle
126
- def self.create(x = 0, y = 0, width = 0, height = 0)
127
- Rectangle.new.set(x, y, width, height)
128
- end
129
-
130
- def set(x, y, width, height)
131
- self[:x] = x
132
- self[:y] = y
133
- self[:width] = width
134
- self[:height] = height
135
- self
136
- end
137
- end
138
-
139
- class BoundingBox
140
- def self.create(*args)
141
- case args.size
142
- when 2
143
- instance = BoundingBox.new
144
- instance[:min] = args[0] # min
145
- instance[:max] = args[1] # max
146
- instance
147
- when 6
148
- instance = BoundingBox.new
149
- instance[:min] = Vector3.create(args[0], args[1], args[2]) # min_x, min_y, min_z
150
- instance[:max] = Vector3.create(args[3], args[4], args[5]) # max_x, max_y, max_z
151
- instance
152
- else
153
- raise ArgumentError.new 'BoundingBox.create : Number of arguments must be 2 or 6'
154
- end
155
- end
156
-
157
- def with_min(x, y, z)
158
- self[:min].set(x, y, z)
159
- self
160
- end
161
-
162
- def with_max(x, y, z)
163
- self[:max].set(x, y, z)
164
- self
165
- end
166
- end
167
-
168
- def Vector3ToFloat(vec)
169
- Vector3ToFloatV(vec)[:v].to_a
170
- end
171
-
172
- def MatrixToFloat(mat)
173
- MatrixToFloatV(mat)[:v].to_a
174
- end
175
-
176
- #
177
- # Camera helper
178
- #
179
-
180
- class Camera3D
181
- def with_position(x, y, z)
182
- self[:position].set(x, y, z)
183
- self
184
- end
185
-
186
- def with_target(x, y, z)
187
- self[:target].set(x, y, z)
188
- self
189
- end
190
-
191
- def with_up(x, y, z)
192
- self[:up].set(x, y, z)
193
- self
194
- end
195
-
196
- def with_fovy(fovy)
197
- self[:fovy] = fovy
198
- self
199
- end
200
-
201
- def with_projection(projection)
202
- self[:projection] = projection
203
- self
204
- end
205
- end
206
-
207
- class Camera2D
208
- def with_offset(x, y)
209
- self[:offset].set(x, y)
210
- self
211
- end
212
-
213
- def with_target(x, y)
214
- self[:target].set(x, y)
215
- self
216
- end
217
-
218
- def with_rotation(rotation)
219
- self[:rotation] = rotation
220
- self
221
- end
222
-
223
- def with_zoom(zoom)
224
- self[:zoom] = zoom
225
- self
226
- end
227
- end
228
-
229
- #
230
- # Transform helper
231
- #
232
-
233
- class Transform
234
- def t = self[:translation]
235
- def r = self[:rotation]
236
- def s = self[:scale]
237
- end
238
-
239
- #
240
- # Model helper
241
- #
242
-
243
- # DrawModelEx : Draw a model with extended parameters
244
- # @param model [Model]
245
- # @param position [Vector3]
246
- # @param rotationAxis [Vector3]
247
- # @param rotationAngle [float]
248
- # @param scale [Vector3]
249
- # @param tint [Color]
250
- # @return [void]
251
- def DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint)
252
- # [NOTE] Fixing unintended matrix modification
253
- # - In C, DrawModelEx uses the whole copy of `model` on stack, which will never affect the content of original `model`.
254
- # But Ruby FFI seems to pass the reference of `model` to DrawModelEx, which results in transform accumulation (e.g.:`model` get rotated by `rotationAngle` around `rotationAxis` every frame).
255
- # So here I copy the transform into `mtx_clone` and copy back this to the original after finished calling DrawModelEx.
256
- # - Other DrawXXX members (DrawModel, DrawModelWires, DrawModelWiresEx) are free from this problem.
257
- # - They call DrawModelEx in C layer, which will use the copy of `model` on stack.
258
- mtx_clone = model[:transform].clone
259
- internalDrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint)
260
- model[:transform] = mtx_clone
261
- end
262
-
263
- class Model
264
- # GetModelMaterial (ruby raylib original)
265
- # @param index [int] 0 ~ materialCount
266
- # @return [Material]
267
- def material(index = 0)
268
- Material.new(self[:materials] + index * Material.size)
269
- end
270
-
271
- # GetModelMaterialCount (ruby raylib original)
272
- # @return [int]
273
- def material_count
274
- self[:materialCount]
275
- end
276
-
277
- # GetModelBoneCount (ruby raylib original)
278
- # @return [int]
279
- def bone_count
280
- self[:boneCount]
281
- end
282
-
283
- # @return BoneInfo
284
- def bone_info(index)
285
- BoneInfo.new(self[:bones] + index * BoneInfo.size)
286
- end
287
-
288
- # @return Transform
289
- def bind_pose_transform(index)
290
- Transform.new(self[:bindPose] + index * Transform.size)
291
- end
292
- end
293
-
294
- class BoneInfo
295
- def parent_bone_index
296
- self[:parent]
297
- end
298
- end
299
-
300
- #
301
- # ModelAnimation helper
302
- #
303
-
304
- # Manages a set of ModelAnimation (ruby raylib original)
305
- class ModelAnimations
306
- attr_reader :anims, :anim_ptrs
307
-
308
- def initialize
309
- @anims = nil
310
- @anim_ptrs = nil
311
- @framePoses = nil # array of Transform**
312
- end
313
-
314
- def anim(index) = @anims[index]
315
- def anims_count = @anims.length
316
- def frame_count(index) = @anims[index][:frameCount]
317
-
318
- # @return BoneInfo
319
- def bone_info(anim_index, bone_index)
320
- BoneInfo.new(@anims[anim_index][:bones] + bone_index * BoneInfo.size)
321
- end
322
-
323
- # @return Transform*
324
- def frame_pose(index, frame)
325
- @framePoses[index] + frame * FFI::NativeType::POINTER.size # Transform*
326
- end
327
-
328
- # @return Transform
329
- def bone_transform(frame_pose, bone_index)
330
- Transform.new(frame_pose.read_pointer + bone_index * Transform.size)
331
- end
332
-
333
- # @return Transform
334
- def bone_transform_of_frame_pose(anim_index, frame, bone_index)
335
- bone_transform(frame_pose(anim_index, frame), bone_index)
336
- end
337
-
338
- # @return self
339
- def setup(fileName)
340
- @anims, @anim_ptrs = LoadAndAllocateModelAnimations(fileName)
341
- @framePoses = []
342
- @anims.each do |anim|
343
- @framePoses << anim[:framePoses]
344
- end
345
- self
346
- end
347
-
348
- def cleanup
349
- UnloadAndFreeModelAnimations(@anims, @anim_ptrs)
350
- end
351
- end
352
-
353
- # LoadAndAllocateModelAnimations : (ruby raylib original)
354
- # @param fileName [const char *]
355
- # @return array of ModelAnimation and pointer to loaded memory
356
- def LoadAndAllocateModelAnimations(fileName)
357
- animsCount_buf = FFI::MemoryPointer.new(:uint, 1)
358
- anim_ptrs = LoadModelAnimations(fileName, animsCount_buf)
359
- animsCount = animsCount_buf.read_uint
360
- anims = animsCount.times.map do |i|
361
- ModelAnimation.new(anim_ptrs + i * ModelAnimation.size)
362
- end
363
- return anims, anim_ptrs
364
- end
365
-
366
- # UnloadAndFreeModelAnimations : (ruby raylib original)
367
- # @param anims [array of ModelAnimation]
368
- # @param anim_ptrs [pointer to loaded memory]
369
- def UnloadAndFreeModelAnimations(anims, anim_ptrs)
370
- anims.each do |anim|
371
- UnloadModelAnimation(anim)
372
- end
373
- MemFree(anim_ptrs)
374
- end
375
-
376
- end
1
+ # Yet another raylib wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/raylib-bindings
4
+
5
+ module Raylib
6
+ #
7
+ # Color helper
8
+ #
9
+
10
+ class Color
11
+ def self.from_u8(r = 0, g = 0, b = 0, a = 255)
12
+ Color.new.set(r, g, b, a)
13
+ end
14
+
15
+ def set(r, g, b, a)
16
+ self[:r] = r
17
+ self[:g] = g
18
+ self[:b] = b
19
+ self[:a] = a
20
+ self
21
+ end
22
+
23
+ def copy(other)
24
+ self[:r] = other.r
25
+ self[:g] = other.g
26
+ self[:b] = other.b
27
+ self[:a] = other.a
28
+ self
29
+ end
30
+ end
31
+
32
+ LIGHTGRAY = Color.from_u8(200, 200, 200, 255)
33
+ GRAY = Color.from_u8(130, 130, 130, 255)
34
+ DARKGRAY = Color.from_u8(80, 80, 80, 255)
35
+ YELLOW = Color.from_u8(253, 249, 0, 255)
36
+ GOLD = Color.from_u8(255, 203, 0, 255)
37
+ ORANGE = Color.from_u8(255, 161, 0, 255)
38
+ PINK = Color.from_u8(255, 109, 194, 255)
39
+ RED = Color.from_u8(230, 41, 55, 255)
40
+ MAROON = Color.from_u8(190, 33, 55, 255)
41
+ GREEN = Color.from_u8(0, 228, 48, 255)
42
+ LIME = Color.from_u8(0, 158, 47, 255)
43
+ DARKGREEN = Color.from_u8(0, 117, 44, 255)
44
+ SKYBLUE = Color.from_u8(102, 191, 255, 255)
45
+ BLUE = Color.from_u8(0, 121, 241, 255)
46
+ DARKBLUE = Color.from_u8(0, 82, 172, 255)
47
+ PURPLE = Color.from_u8(200, 122, 255, 255)
48
+ VIOLET = Color.from_u8(135, 60, 190, 255)
49
+ DARKPURPLE = Color.from_u8(112, 31, 126, 255)
50
+ BEIGE = Color.from_u8(211, 176, 131, 255)
51
+ BROWN = Color.from_u8(127, 106, 79, 255)
52
+ DARKBROWN = Color.from_u8(76, 63, 47, 255)
53
+
54
+ WHITE = Color.from_u8(255, 255, 255, 255)
55
+ BLACK = Color.from_u8(0, 0, 0, 255)
56
+ BLANK = Color.from_u8(0, 0, 0, 0)
57
+ MAGENTA = Color.from_u8(255, 0, 255, 255)
58
+ RAYWHITE = Color.from_u8(245, 245, 245, 255)
59
+
60
+ #
61
+ # Math helper
62
+ #
63
+
64
+ class Vector2
65
+ def self.create(x = 0, y = 0)
66
+ Vector2.new.set(x, y)
67
+ end
68
+
69
+ def self.copy_from(vec)
70
+ Vector2.create(vec[:x], vec[:y])
71
+ end
72
+
73
+ def set(x, y)
74
+ self[:x] = x
75
+ self[:y] = y
76
+ self
77
+ end
78
+
79
+ def to_a
80
+ [x, y]
81
+ end
82
+ end
83
+
84
+ class Vector3
85
+ def self.create(x = 0, y = 0, z = 0)
86
+ Vector3.new.set(x, y, z)
87
+ end
88
+
89
+ def self.copy_from(vec)
90
+ Vector3.create(vec[:x], vec[:y], vec[:z])
91
+ end
92
+
93
+ def set(x, y, z)
94
+ self[:x] = x
95
+ self[:y] = y
96
+ self[:z] = z
97
+ self
98
+ end
99
+
100
+ def to_a
101
+ [x, y, z]
102
+ end
103
+ end
104
+
105
+ class Vector4
106
+ def self.create(x = 0, y = 0, z = 0, w = 0)
107
+ Vector4.new.set(x, y, z, w)
108
+ end
109
+
110
+ def self.copy_from(vec)
111
+ Vector4.create(vec[:x], vec[:y], vec[:z], vec[:w])
112
+ end
113
+
114
+ def set(x, y, z, w)
115
+ self[:x] = x
116
+ self[:y] = y
117
+ self[:z] = z
118
+ self[:w] = w
119
+ self
120
+ end
121
+
122
+ def to_a
123
+ [x, y, z, w]
124
+ end
125
+ end
126
+
127
+ class Quaternion
128
+ def self.create(x = 0, y = 0, z = 0, w = 0)
129
+ Quaternion.new.set(x, y, z, w)
130
+ end
131
+
132
+ def self.copy_from(quat)
133
+ Quaternion.create(quat[:x], quat[:y], quat[:z], quat[:w])
134
+ end
135
+
136
+ def set(x, y, z, w)
137
+ self[:x] = x
138
+ self[:y] = y
139
+ self[:z] = z
140
+ self[:w] = w
141
+ self
142
+ end
143
+
144
+ def to_a
145
+ [x, y, z, w]
146
+ end
147
+ end
148
+
149
+ class Rectangle
150
+ def self.create(x = 0, y = 0, width = 0, height = 0)
151
+ Rectangle.new.set(x, y, width, height)
152
+ end
153
+
154
+ def set(x, y, width, height)
155
+ self[:x] = x
156
+ self[:y] = y
157
+ self[:width] = width
158
+ self[:height] = height
159
+ self
160
+ end
161
+ end
162
+
163
+ class BoundingBox
164
+ def self.create(*args)
165
+ case args.size
166
+ when 2
167
+ instance = BoundingBox.new
168
+ instance[:min] = args[0] # min
169
+ instance[:max] = args[1] # max
170
+ instance
171
+ when 6
172
+ instance = BoundingBox.new
173
+ instance[:min] = Vector3.create(args[0], args[1], args[2]) # min_x, min_y, min_z
174
+ instance[:max] = Vector3.create(args[3], args[4], args[5]) # max_x, max_y, max_z
175
+ instance
176
+ else
177
+ raise ArgumentError.new 'BoundingBox.create : Number of arguments must be 2 or 6'
178
+ end
179
+ end
180
+
181
+ def with_min(x, y, z)
182
+ self[:min].set(x, y, z)
183
+ self
184
+ end
185
+
186
+ def with_max(x, y, z)
187
+ self[:max].set(x, y, z)
188
+ self
189
+ end
190
+ end
191
+
192
+ def Vector3ToFloat(vec)
193
+ Vector3ToFloatV(vec)[:v].to_a
194
+ end
195
+
196
+ def MatrixToFloat(mat)
197
+ MatrixToFloatV(mat)[:v].to_a
198
+ end
199
+
200
+ #
201
+ # Camera helper
202
+ #
203
+
204
+ class Camera3D
205
+ def with_position(x, y, z)
206
+ self[:position].set(x, y, z)
207
+ self
208
+ end
209
+
210
+ def with_target(x, y, z)
211
+ self[:target].set(x, y, z)
212
+ self
213
+ end
214
+
215
+ def with_up(x, y, z)
216
+ self[:up].set(x, y, z)
217
+ self
218
+ end
219
+
220
+ def with_fovy(fovy)
221
+ self[:fovy] = fovy
222
+ self
223
+ end
224
+
225
+ def with_projection(projection)
226
+ self[:projection] = projection
227
+ self
228
+ end
229
+ end
230
+
231
+ class Camera2D
232
+ def with_offset(x, y)
233
+ self[:offset].set(x, y)
234
+ self
235
+ end
236
+
237
+ def with_target(x, y)
238
+ self[:target].set(x, y)
239
+ self
240
+ end
241
+
242
+ def with_rotation(rotation)
243
+ self[:rotation] = rotation
244
+ self
245
+ end
246
+
247
+ def with_zoom(zoom)
248
+ self[:zoom] = zoom
249
+ self
250
+ end
251
+ end
252
+
253
+ #
254
+ # Transform helper
255
+ #
256
+
257
+ class Transform
258
+ def t = self[:translation]
259
+ def r = self[:rotation]
260
+ def s = self[:scale]
261
+ end
262
+
263
+ #
264
+ # Model helper
265
+ #
266
+
267
+ # DrawModelEx : Draw a model with extended parameters
268
+ # @param model [Model]
269
+ # @param position [Vector3]
270
+ # @param rotationAxis [Vector3]
271
+ # @param rotationAngle [float]
272
+ # @param scale [Vector3]
273
+ # @param tint [Color]
274
+ # @return [void]
275
+ def DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint)
276
+ # [NOTE] Fixing unintended matrix modification
277
+ # - In C, DrawModelEx uses the whole copy of `model` on stack, which will never affect the content of original `model`.
278
+ # But Ruby FFI seems to pass the reference of `model` to DrawModelEx, which results in transform accumulation (e.g.:`model` get rotated by `rotationAngle` around `rotationAxis` every frame).
279
+ # So here I copy the transform into `mtx_clone` and copy back this to the original after finished calling DrawModelEx.
280
+ # - Other DrawXXX members (DrawModel, DrawModelWires, DrawModelWiresEx) are free from this problem.
281
+ # - They call DrawModelEx in C layer, which will use the copy of `model` on stack.
282
+ mtx_clone = model[:transform].clone
283
+ internalDrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint)
284
+ model[:transform] = mtx_clone
285
+ end
286
+
287
+ class Model
288
+ # GetModelMaterial (ruby raylib original)
289
+ # @param index [int] 0 ~ materialCount
290
+ # @return [Material]
291
+ def material(index = 0)
292
+ Material.new(self[:materials] + index * Material.size)
293
+ end
294
+
295
+ # GetModelMaterialCount (ruby raylib original)
296
+ # @return [int]
297
+ def material_count
298
+ self[:materialCount]
299
+ end
300
+
301
+ # GetModelBoneCount (ruby raylib original)
302
+ # @return [int]
303
+ def bone_count
304
+ self[:boneCount]
305
+ end
306
+
307
+ # @return BoneInfo
308
+ def bone_info(index)
309
+ BoneInfo.new(self[:bones] + index * BoneInfo.size)
310
+ end
311
+
312
+ # @return Transform
313
+ def bind_pose_transform(index)
314
+ Transform.new(self[:bindPose] + index * Transform.size)
315
+ end
316
+ end
317
+
318
+ class BoneInfo
319
+ def parent_bone_index
320
+ self[:parent]
321
+ end
322
+ end
323
+
324
+ #
325
+ # ModelAnimation helper
326
+ #
327
+
328
+ # Manages a set of ModelAnimation (ruby raylib original)
329
+ class ModelAnimations
330
+ attr_reader :anims, :anim_ptrs
331
+
332
+ def initialize
333
+ @anims = nil
334
+ @anim_ptrs = nil
335
+ @framePoses = nil # array of Transform**
336
+ end
337
+
338
+ def anim(index) = @anims[index]
339
+ def anims_count = @anims.length
340
+ def frame_count(index) = @anims[index][:frameCount]
341
+
342
+ # @return BoneInfo
343
+ def bone_info(anim_index, bone_index)
344
+ BoneInfo.new(@anims[anim_index][:bones] + bone_index * BoneInfo.size)
345
+ end
346
+
347
+ # @return Transform*
348
+ def frame_pose(index, frame)
349
+ @framePoses[index] + frame * FFI::NativeType::POINTER.size # Transform*
350
+ end
351
+
352
+ # @return Transform
353
+ def bone_transform(frame_pose, bone_index)
354
+ Transform.new(frame_pose.read_pointer + bone_index * Transform.size)
355
+ end
356
+
357
+ # @return Transform
358
+ def bone_transform_of_frame_pose(anim_index, frame, bone_index)
359
+ bone_transform(frame_pose(anim_index, frame), bone_index)
360
+ end
361
+
362
+ # @return self
363
+ def setup(fileName)
364
+ @anims, @anim_ptrs = LoadAndAllocateModelAnimations(fileName)
365
+ @framePoses = []
366
+ @anims.each do |anim|
367
+ @framePoses << anim[:framePoses]
368
+ end
369
+ self
370
+ end
371
+
372
+ def cleanup
373
+ UnloadAndFreeModelAnimations(@anims, @anim_ptrs)
374
+ end
375
+ end
376
+
377
+ # LoadAndAllocateModelAnimations : (ruby raylib original)
378
+ # @param fileName [const char *]
379
+ # @return array of ModelAnimation and pointer to loaded memory
380
+ def LoadAndAllocateModelAnimations(fileName)
381
+ animsCount_buf = FFI::MemoryPointer.new(:uint, 1)
382
+ anim_ptrs = LoadModelAnimations(fileName, animsCount_buf)
383
+ animsCount = animsCount_buf.read_uint
384
+ anims = animsCount.times.map do |i|
385
+ ModelAnimation.new(anim_ptrs + i * ModelAnimation.size)
386
+ end
387
+ return anims, anim_ptrs
388
+ end
389
+
390
+ # UnloadAndFreeModelAnimations : (ruby raylib original)
391
+ # @param anims [array of ModelAnimation]
392
+ # @param anim_ptrs [pointer to loaded memory]
393
+ def UnloadAndFreeModelAnimations(anims, anim_ptrs)
394
+ anims.each do |anim|
395
+ UnloadModelAnimation(anim)
396
+ end
397
+ MemFree(anim_ptrs)
398
+ end
399
+
400
+ end