Class: Assimp::SceneCopier

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

Instance Method Summary collapse

Constructor Details

#initialize(native: Native) ⇒ SceneCopier

Returns a new instance of SceneCopier.



5
6
7
8
9
10
11
# File 'lib/assimp/scene_copier.rb', line 5

def initialize(native: Native)
  @native = native
  @minor_version = native.version[1]
  @mesh_copier = MeshCopier.new(native:)
  @animation_copier = AnimationCopier.new(native:)
  @texture_copier = TextureCopier.new
end

Instance Method Details

#copy(pointer) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/assimp/scene_copier.rb', line 13

def copy(pointer)
  source = Native::Scene.new(pointer)
  textures = map_pointers(source[:textures], source[:num_textures], @texture_copier)
  material_copier = MaterialCopier.new(native: @native, embedded_textures: textures)
  Scene.new(
    name: @minor_version.zero? ? "" : source[:name].to_s,
    meshes: map_pointers(source[:meshes], source[:num_meshes], @mesh_copier),
    materials: map_pointers(source[:materials], source[:num_materials], material_copier),
    root: copy_node(source[:root_node]),
    animations: map_pointers(source[:animations], source[:num_animations], @animation_copier),
    textures:,
    flags: source[:flags]
  )
end