Class: Assimp::Bone
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Assimp::Bone
- Extended by:
- StructAccessors
- Defined in:
- lib/assimp/mesh.rb
Instance Method Summary collapse
- #add_weight(vertex_id, weight) ⇒ Object
-
#initialize(ptr = nil) ⇒ Bone
constructor
A new instance of Bone.
- #push(weight) ⇒ Object
Methods included from StructAccessors
extended, has_ref?, struct_array_attr_accessor, struct_array_attr_checker, struct_array_attr_reader, struct_array_attr_writer, struct_attr_accessor, struct_attr_reader, struct_attr_writer, struct_ref_array_attr_accessor, struct_ref_array_attr_reader, struct_ref_array_attr_writer
Constructor Details
#initialize(ptr = nil) ⇒ Bone
Returns a new instance of Bone.
45 46 47 48 49 50 51 52 53 |
# File 'lib/assimp/mesh.rb', line 45 def initialize(ptr = nil) if ptr super else ptr = FFI::MemoryPointer::new(self.class.size, 1, true) super(ptr) offset_matrix.identity! end end |
Instance Method Details
#add_weight(vertex_id, weight) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/assimp/mesh.rb', line 55 def add_weight(vertex_id, weight) vw = VertexWeight::new vw.vertex_id = vertex_id vw.weight = weight push(vw) end |
#push(weight) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/assimp/mesh.rb', line 62 def push(weight) new_ptr = FFI::MemoryPointer::new(VertexWeight, num_weights + 1) ptr = self[:weights] s = VertexWeight.size new_ptr.write_array_of_uint8(ptr.read_array_of_uint8(s*num_weights)) unless ptr.null? new_ptr.put_array_of_uint8(num_weights*s, weight.pointer.read_array_of_uint8(s)) @weights = new_ptr self[:weights] = new_ptr self.num_weights += 1 self end |