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.
347 348 349 350 351 |
# File 'lib/raylib_helper.rb', line 347 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.
345 346 347 |
# File 'lib/raylib_helper.rb', line 345 def anim_ptrs @anim_ptrs end |
#anims ⇒ Object (readonly)
Returns the value of attribute anims.
345 346 347 |
# File 'lib/raylib_helper.rb', line 345 def anims @anims end |
Instance Method Details
#anim(index) ⇒ Object
353 |
# File 'lib/raylib_helper.rb', line 353 def anim(index) = @anims[index] |
#anims_count ⇒ Object
354 |
# File 'lib/raylib_helper.rb', line 354 def anims_count = @anims.length |
#bone_info(anim_index, bone_index) ⇒ Object
Returns BoneInfo.
358 359 360 |
# File 'lib/raylib_helper.rb', line 358 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.
368 369 370 |
# File 'lib/raylib_helper.rb', line 368 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.
373 374 375 |
# File 'lib/raylib_helper.rb', line 373 def bone_transform_of_frame_pose(anim_index, frame, bone_index) bone_transform(frame_pose(anim_index, frame), bone_index) end |
#cleanup ⇒ Object
387 388 389 |
# File 'lib/raylib_helper.rb', line 387 def cleanup UnloadAndFreeModelAnimations(@anims, @anim_ptrs) end |
#frame_count(index) ⇒ Object
355 |
# File 'lib/raylib_helper.rb', line 355 def frame_count(index) = @anims[index][:frameCount] |
#frame_pose(index, frame) ⇒ Object
Returns Transform*.
363 364 365 |
# File 'lib/raylib_helper.rb', line 363 def frame_pose(index, frame) @framePoses[index] + frame * FFI::NativeType::POINTER.size # Transform* end |
#setup(fileName) ⇒ Object
Returns self.
378 379 380 381 382 383 384 385 |
# File 'lib/raylib_helper.rb', line 378 def setup(fileName) @anims, @anim_ptrs = LoadAndAllocateModelAnimations(fileName) @framePoses = [] @anims.each do |anim| @framePoses << anim[:framePoses] end self end |