Class: Assimp::Node

Inherits:
FFI::Struct
  • Object
show all
Extended by:
StructAccessors
Defined in:
lib/assimp/scene.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

Constructor Details

#initialize(ptr = nil) ⇒ Node

Returns a new instance of Node.



24
25
26
27
28
29
30
31
32
# File 'lib/assimp/scene.rb', line 24

def initialize(ptr = nil)
  if ptr
    super
  else
    ptr = FFI::MemoryPointer::new(self.class.size, 1, true)
    super(ptr)
    transformation.identity!
  end
end

Instance Method Details

#ancestorsObject



40
41
42
# File 'lib/assimp/scene.rb', line 40

def ancestors
  return parent ?  [parent] + parent.ancestors : []
end

#each_node(&block) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/assimp/scene.rb', line 63

def each_node(&block)
  if block then
    block.call self
    children.each { |c|
      c.each_node(&block)
    }
    return self
  else
    to_enum(:each_node)
  end
end

#each_node_with_depth(depth = nil, &block) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/assimp/scene.rb', line 75

def each_node_with_depth(depth=nil, &block)
  depth = (depth ? depth + 1 : 0)
  if block then
    block.call self, depth
    children.each { |c|
      c.each_node_with_depth(depth, &block)
    }
  else
    to_enum(:each_node_with_depth)
  end
end

#meta_dataObject



87
88
89
90
91
# File 'lib/assimp/scene.rb', line 87

def 
  p = self[:meta_data]
  return nil if p.null?
  Metadata::new(p)
end

#parentObject



34
35
36
37
38
# File 'lib/assimp/scene.rb', line 34

def parent
  ptr = self[:parent]
  return nil if ptr.null?
  Node::new(ptr)
end

#parent=(other) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/assimp/scene.rb', line 52

def parent=(other)
  if other.kind_of? FFI::Pointer
    self[:parent] = other
  elsif other.kind_of? Node
    self[:parent] = other.pointer
  else
    raise ArgumentError::new("Argument should be a Node!")
  end
  other
end

#world_transformationObject



44
45
46
47
48
49
50
# File 'lib/assimp/scene.rb', line 44

def world_transformation
  if parent
    ancestors.reverse.collect(&:transformation).reduce(:*) * transformation
  else
    transformation
  end
end