Class: Raylib::ModelAnimations
- Inherits:
-
Object
- Object
- Raylib::ModelAnimations
- Defined in:
- lib/raylib_helper.rb
Overview
Manages a set of ModelAnimation (ruby raylib original)
Instance Attribute Summary collapse
-
#anim_ptrs ⇒ Object
readonly
Returns the value of attribute anim_ptrs.
-
#anims ⇒ Object
readonly
Returns the value of attribute anims.
Instance Method Summary collapse
- #anim(index) ⇒ Object
- #anims_count ⇒ Object
-
#bone_info(anim_index, bone_index) ⇒ Object
BoneInfo.
-
#bone_transform(frame_pose, bone_index) ⇒ Object
Transform.
-
#bone_transform_of_frame_pose(anim_index, frame, bone_index) ⇒ Object
Transform.
- #cleanup ⇒ Object
- #frame_count(index) ⇒ Object
-
#frame_pose(index, frame) ⇒ Object
Transform*.
-
#initialize ⇒ ModelAnimations
constructor
A new instance of ModelAnimations.
-
#setup(fileName) ⇒ Object
Self.
Constructor Details
#initialize ⇒ ModelAnimations
Returns a new instance of ModelAnimations.
363 364 365 366 367 |
# File 'lib/raylib_helper.rb', line 363 def initialize @anims = nil @anim_ptrs = nil @framePoses = nil # array of Transform** end |
Instance Attribute Details
#anim_ptrs ⇒ Object (readonly)
Returns the value of attribute anim_ptrs.
361 362 363 |
# File 'lib/raylib_helper.rb', line 361 def anim_ptrs @anim_ptrs end |
#anims ⇒ Object (readonly)
Returns the value of attribute anims.
361 362 363 |
# File 'lib/raylib_helper.rb', line 361 def anims @anims end |
Instance Method Details
#anim(index) ⇒ Object
369 |
# File 'lib/raylib_helper.rb', line 369 def anim(index) = @anims[index] |
#anims_count ⇒ Object
370 |
# File 'lib/raylib_helper.rb', line 370 def anims_count = @anims.length |
#bone_info(anim_index, bone_index) ⇒ Object
Returns BoneInfo.
374 375 376 |
# File 'lib/raylib_helper.rb', line 374 def bone_info(anim_index, bone_index) BoneInfo.new(@anims[anim_index][:bones] + bone_index * BoneInfo.size) end |
#bone_transform(frame_pose, bone_index) ⇒ Object
Returns Transform.
384 385 386 |
# File 'lib/raylib_helper.rb', line 384 def bone_transform(frame_pose, bone_index) Transform.new(frame_pose.read_pointer + bone_index * Transform.size) end |
#bone_transform_of_frame_pose(anim_index, frame, bone_index) ⇒ Object
Returns Transform.
389 390 391 |
# File 'lib/raylib_helper.rb', line 389 def bone_transform_of_frame_pose(anim_index, frame, bone_index) bone_transform(frame_pose(anim_index, frame), bone_index) end |
#cleanup ⇒ Object
403 404 405 |
# File 'lib/raylib_helper.rb', line 403 def cleanup UnloadAndFreeModelAnimations(@anims, @anim_ptrs) end |
#frame_count(index) ⇒ Object
371 |
# File 'lib/raylib_helper.rb', line 371 def frame_count(index) = @anims[index][:frameCount] |
#frame_pose(index, frame) ⇒ Object
Returns Transform*.
379 380 381 |
# File 'lib/raylib_helper.rb', line 379 def frame_pose(index, frame) @framePoses[index] + frame * FFI::NativeType::POINTER.size # Transform* end |
#setup(fileName) ⇒ Object
Returns self.
394 395 396 397 398 399 400 401 |
# File 'lib/raylib_helper.rb', line 394 def setup(fileName) @anims, @anim_ptrs = LoadAndAllocateModelAnimations(fileName) @framePoses = [] @anims.each do |anim| @framePoses << anim[:framePoses] end self end |