Class: Assimp::Material

Inherits:
FFI::Struct
  • Object
show all
Extended by:
StructAccessors
Defined in:
lib/assimp/material.rb

Instance Method Summary collapse

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

Instance Method Details

#add_property(key, val, semantic: 0, index: 0, type: nil) ⇒ Object



385
386
387
# File 'lib/assimp/material.rb', line 385

def add_property(key, val, semantic: 0, index: 0, type: nil)
  push(MaterialProperty::property(key, val, semantic: semantic, index: index, type: type))
end

#property(key, type, index) ⇒ Object



376
377
378
379
380
381
382
383
# File 'lib/assimp/material.rb', line 376

def property(key, type, index)
  ptr = FFI::MemoryPointer::new(:pointer)
  res = Assimp::aiGetMaterialProperty(self, key, type, index, ptr)
  raise "get_material_property error!" unless res == :SUCCESS
  new_ptr = ptr.read_pointer
  return nil if new_ptr.null?
  MaterialProperty::new(new_ptr)
end

#push(property) ⇒ Object



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/assimp/material.rb', line 389

def push(property)
  @properties = [nil, []] unless @properties
  @properties[1].push(property)
  if num_allocated > num_properties
    self[:properties].put_pointer(FFI::Pointer.size*num_properties, property.pointer)
  else
    self.num_allocated = [32, num_allocated*2].max
    new_ptr = FFI::MemoryPointer::new(:pointer, num_allocated)
    new_ptr.write_array_of_pointer(self[:properties].read_array_of_pointer(num_properties)) unless self[:properties].null?
    new_ptr[num_properties].write_pointer(property.pointer)
    @properties[0] = new_ptr
    self[:properties] = new_ptr
  end
  self.num_properties += 1
  self
end