Class: Vamp::Ply::PlyObject
- Inherits:
-
Object
- Object
- Vamp::Ply::PlyObject
- Defined in:
- lib/vamp/ply/ply_object.rb
Instance Attribute Summary collapse
-
#polygons ⇒ Object
readonly
Returns the value of attribute polygons.
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Instance Method Summary collapse
- #add_polygon(*vertexes) ⇒ Object
- #add_vertex(x, y, z) ⇒ Object
-
#initialize ⇒ PlyObject
constructor
A new instance of PlyObject.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ PlyObject
Returns a new instance of PlyObject.
9 10 11 12 13 |
# File 'lib/vamp/ply/ply_object.rb', line 9 def initialize @vertices = [] @polygons = [] @output = StringIO.new end |
Instance Attribute Details
#polygons ⇒ Object (readonly)
Returns the value of attribute polygons.
7 8 9 |
# File 'lib/vamp/ply/ply_object.rb', line 7 def polygons @polygons end |
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
6 7 8 |
# File 'lib/vamp/ply/ply_object.rb', line 6 def vertices @vertices end |
Instance Method Details
#add_polygon(*vertexes) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/vamp/ply/ply_object.rb', line 19 def add_polygon(*vertexes) vertexes.each do |v| fail "unknown vertex #{v}" unless vertices[v.to_i] end polygons << vertexes.map(&:to_i) end |
#add_vertex(x, y, z) ⇒ Object
15 16 17 |
# File 'lib/vamp/ply/ply_object.rb', line 15 def add_vertex(x, y, z) vertices << ([x.to_f, y.to_f, z.to_f]) end |
#to_s ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/vamp/ply/ply_object.rb', line 26 def to_s @output = StringIO.new print_header print_vertices print_polygons output.string end |