Class: Assimp::Mesh

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, material_index:, primitive:, positions:, normals:, tangents:, uv_sets:, colors:, indices:, bones:, vertex_count:, aabb:) ⇒ Mesh

Returns a new instance of Mesh.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/assimp/mesh.rb', line 10

def initialize(name:, material_index:, primitive:, positions:, normals:, tangents:, uv_sets:,
               colors:, indices:, bones:, vertex_count:, aabb:)
  @name = String(name).dup.freeze
  @material_index = Integer(material_index)
  @primitive = primitive.to_sym
  @vertex_count = Integer(vertex_count)
  @positions = packed(positions, @vertex_count * 12, :positions)
  @normals = optional_packed(normals, @vertex_count * 12, :normals)
  @tangents = optional_packed(tangents, @vertex_count * 16, :tangents)
  @uv_sets = uv_sets.map.with_index { |data, index| packed(data, @vertex_count * 8, :"uv#{index}") }.freeze
  @colors = optional_packed(colors, @vertex_count * 16, :colors)
  @indices = packed_multiple(indices, 4, :indices)
  @bones = bones.freeze
  @aabb = aabb
  freeze
end

Instance Attribute Details

#aabbObject (readonly)

Returns the value of attribute aabb.



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

def aabb
  @aabb
end

#bonesObject (readonly)

Returns the value of attribute bones.



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

def bones
  @bones
end

#colorsObject (readonly)

Returns the value of attribute colors.



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

def colors
  @colors
end

#indicesObject (readonly)

Returns the value of attribute indices.



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

def indices
  @indices
end

#material_indexObject (readonly)

Returns the value of attribute material_index.



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

def material_index
  @material_index
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#normalsObject (readonly)

Returns the value of attribute normals.



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

def normals
  @normals
end

#positionsObject (readonly)

Returns the value of attribute positions.



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

def positions
  @positions
end

#primitiveObject (readonly)

Returns the value of attribute primitive.



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

def primitive
  @primitive
end

#tangentsObject (readonly)

Returns the value of attribute tangents.



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

def tangents
  @tangents
end

#uv_setsObject (readonly)

Returns the value of attribute uv_sets.



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

def uv_sets
  @uv_sets
end

#vertex_countObject (readonly)

Returns the value of attribute vertex_count.



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

def vertex_count
  @vertex_count
end

Instance Method Details

#index_countObject



27
28
29
# File 'lib/assimp/mesh.rb', line 27

def index_count
  indices.bytesize / 4
end