Class: Assimp::Node
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Assimp::Node
show all
- Extended by:
- StructAccessors
- Defined in:
- lib/assimp/scene.rb
Instance Method Summary
collapse
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
#ancestors ⇒ Object
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
|
87
88
89
90
91
|
# File 'lib/assimp/scene.rb', line 87
def meta_data
p = self[:meta_data]
return nil if p.null?
Metadata::new(p)
end
|
#parent ⇒ Object
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
|
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
|