Class: Stagecraft::Skin
- Inherits:
-
Object
- Object
- Stagecraft::Skin
- Defined in:
- lib/stagecraft/core/skin.rb
Instance Attribute Summary collapse
-
#inverse_bind_matrices ⇒ Object
readonly
Returns the value of attribute inverse_bind_matrices.
-
#joints ⇒ Object
readonly
Returns the value of attribute joints.
-
#skeleton ⇒ Object
readonly
Returns the value of attribute skeleton.
Instance Method Summary collapse
-
#initialize(joints:, inverse_bind_matrices: nil, skeleton: nil) ⇒ Skin
constructor
A new instance of Skin.
- #joint_matrices(mesh) ⇒ Object
Constructor Details
#initialize(joints:, inverse_bind_matrices: nil, skeleton: nil) ⇒ Skin
Returns a new instance of Skin.
7 8 9 10 11 12 13 14 |
# File 'lib/stagecraft/core/skin.rb', line 7 def initialize(joints:, inverse_bind_matrices: nil, skeleton: nil) @joints = joints.freeze @inverse_bind_matrices = inverse_bind_matrices || Array.new(joints.length) { Larb::Mat4.identity } @skeleton = skeleton unless @inverse_bind_matrices.length == joints.length raise ArgumentError, "inverse bind matrix count must match joint count" end end |
Instance Attribute Details
#inverse_bind_matrices ⇒ Object (readonly)
Returns the value of attribute inverse_bind_matrices.
5 6 7 |
# File 'lib/stagecraft/core/skin.rb', line 5 def inverse_bind_matrices @inverse_bind_matrices end |
#joints ⇒ Object (readonly)
Returns the value of attribute joints.
5 6 7 |
# File 'lib/stagecraft/core/skin.rb', line 5 def joints @joints end |
#skeleton ⇒ Object (readonly)
Returns the value of attribute skeleton.
5 6 7 |
# File 'lib/stagecraft/core/skin.rb', line 5 def skeleton @skeleton end |
Instance Method Details
#joint_matrices(mesh) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/stagecraft/core/skin.rb', line 16 def joint_matrices(mesh) mesh_inverse = mesh.world_matrix.inverse joints.each_with_index.map do |joint, index| inverse_bind_matrices[index] * joint.world_matrix * mesh_inverse end end |