Class: OBJ::Mesh

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Mesh

Returns a new instance of Mesh.



9
10
11
12
13
14
15
16
# File 'lib/obj/mesh.rb', line 9

def initialize(file_path)
  @vertices = []
  @normals = []
  @text_coords = []
  @faces = []

  initialize_from_file(file_path)
end

Instance Attribute Details

#facesObject

Returns the value of attribute faces.



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

def faces
  @faces
end

#normalsObject

Returns the value of attribute normals.



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

def normals
  @normals
end

#text_coordsObject

Returns the value of attribute text_coords.



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

def text_coords
  @text_coords
end

#verticesObject

Returns the value of attribute vertices.



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

def vertices
  @vertices
end

Class Method Details

.load(file_path) ⇒ Object



3
4
5
# File 'lib/obj/mesh.rb', line 3

def self.load(file_path)
  Mesh.new(file_path)
end

Instance Method Details

#normals?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/obj/mesh.rb', line 18

def normals?
  !@normals.empty?
end

#text_coords?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/obj/mesh.rb', line 22

def text_coords?
  !@text_coords.empty?
end

#to_sObject



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

def to_s
  "<#{self.class} vertices: #{@vertices.size} normals: #{@normals.size}" \
  " text_coords: #{@text_coords.size} faces: #{@faces.size}>"
end