Class: Assimp::Scene

Inherits:
Object
  • Object
show all
Defined in:
lib/assimp/scene.rb

Constant Summary collapse

INCOMPLETE_FLAG =
0x1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, meshes:, materials:, root:, animations:, textures:, flags:) ⇒ Scene

Returns a new instance of Scene.



9
10
11
12
13
14
15
16
17
18
# File 'lib/assimp/scene.rb', line 9

def initialize(name:, meshes:, materials:, root:, animations:, textures:, flags:)
  @name = String(name).dup.freeze
  @meshes = meshes.freeze
  @materials = materials.freeze
  @root = root
  @animations = animations.freeze
  @textures = textures.freeze
  @flags = Integer(flags)
  freeze
end

Instance Attribute Details

#animationsObject (readonly)

Returns the value of attribute animations.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def animations
  @animations
end

#flagsObject (readonly)

Returns the value of attribute flags.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def flags
  @flags
end

#materialsObject (readonly)

Returns the value of attribute materials.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def materials
  @materials
end

#meshesObject (readonly)

Returns the value of attribute meshes.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def meshes
  @meshes
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def name
  @name
end

#rootObject (readonly)

Returns the value of attribute root.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def root
  @root
end

#texturesObject (readonly)

Returns the value of attribute textures.



7
8
9
# File 'lib/assimp/scene.rb', line 7

def textures
  @textures
end

Instance Method Details

#each_mesh_instanceObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/assimp/scene.rb', line 28

def each_mesh_instance
  return enum_for(__method__) unless block_given?
  return self unless root

  stack = [[root, Matrix::IDENTITY]]
  until stack.empty?
    node, parent_matrix = stack.pop
    world_matrix = Matrix.multiply(parent_matrix, node.matrix)
    node.mesh_indices.each { |index| yield meshes.fetch(index), world_matrix }
    node.children.reverse_each { |child| stack << [child, world_matrix] }
  end
  self
end

#find_node(name) ⇒ Object



24
25
26
# File 'lib/assimp/scene.rb', line 24

def find_node(name)
  root&.find(name)
end

#incomplete?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/assimp/scene.rb', line 20

def incomplete?
  (flags & INCOMPLETE_FLAG) != 0
end