class Assimp::Material

Public Instance Methods

add_property(key, val, semantic: 0, index: 0, type: nil) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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