class Vamp::Ply::PlyObject
Attributes
output[RW]
polygons[R]
vertices[R]
Public Class Methods
new()
click to toggle source
# File lib/vamp/ply/ply_object.rb, line 9 def initialize @vertices = [] @polygons = [] @output = StringIO.new end
Public Instance Methods
add_polygon(*vertexes)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# File lib/vamp/ply/ply_object.rb, line 26 def to_s @output = StringIO.new print_header print_vertices print_polygons output.string end
Private Instance Methods
print_header()
click to toggle source
# File lib/vamp/ply/ply_object.rb, line 38 def print_header output.puts("# ply file to describe a 3D model") output.puts("#") end
print_polygons()
click to toggle source
# File lib/vamp/ply/ply_object.rb, line 52 def print_polygons output.puts("# list of polygons (3, 4, .. integer values, vertex indices)") polygons.each do |p| output.puts("#{p.join(' ')}") end output.puts end
print_vertices()
click to toggle source
# File lib/vamp/ply/ply_object.rb, line 43 def print_vertices output.puts("# list of vertices (3 float values, coordinates)") output.puts("# x y z") vertices.each do |v| output.puts("#{v[0].to_f} #{v[1].to_f} #{v[2].to_f}") end output.puts end