Class: Raylib::ModelAnimations

Inherits:
Object
  • Object
show all
Defined in:
lib/raylib_helper.rb

Overview

Manages a set of ModelAnimation (ruby raylib original)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModelAnimations

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_ptrsObject (readonly)

Returns the value of attribute anim_ptrs.



361
362
363
# File 'lib/raylib_helper.rb', line 361

def anim_ptrs
  @anim_ptrs
end

#animsObject (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_countObject



370
# File 'lib/raylib_helper.rb', line 370

def anims_count = @anims.length

#bone_info(anim_index, bone_index) ⇒ Object

Returns BoneInfo.

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.

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.

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

#cleanupObject



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*.

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.

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