lib/crystalcell/povray/camera.rb in crystalcell-0.0.6 vs lib/crystalcell/povray/camera.rb in crystalcell-0.1.0

- old
+ new

@@ -17,41 +17,65 @@ #} #@orthographic = true #@location = [ 3.0, 3.0, 3.0 ] #@look_at = [ 0.0, 0.0, 0.0 ] #@sky = [ 0.0, 0.0, 1.0 ] - #@right = [ -1.00, 0.0, 0.0 ] + #@right = #@up = [ 0.0, 1.0, 0.0 ] #@angle = 68 - attr_accessor :orthographic, :location, :look_at, :sky, :right, :up, :angle + attr_accessor :camera_type, :location, :right, :up, :direction, + :sky, :angle, :look_at - def initialize(orthographic:, location:, look_at:, sky:, right:, up:, angle:, - additions: []) - @orthographic = orthographic - @location = location - @look_at = look_at - @sky = sky - @right = right - @up = up - @angle = angle - @additions = additions + # camera_type: perspectice, orthographic, etc. + # Note: default values of some setting is modified from original povray + # because of left-handed coordinate system. + # This library provide only on right-handed system in crystallography. + # + # --------------------------------------------- + # setting default_orig default_this + # camera_type perspective + # location <0,0,0> + # direction <0,0,1> + # right <1.33,0,0> [-1.33, 0.0, 0.0], + # sky <0,1,0> [ 0.0, 0.0, 1.0], + # up <0,1,0> + # look_at <0,0,1> + def initialize(camera_type: nil, # perspective + location: nil, # <0,0,0> + right: [-1.33, 0.0, 0.0], + up: nil, + direction: nil, + sky: [0.0, 0.0, 1.0], + angle: nil, + #camera_modifiers: nil, + look_at: nil + ) + @camera_type = camera_type + @location = location + @right = right + @up = up + @direction = direction + @sky = sky + @angle = angle + #@camera_modifiers = camera_modifiers + @look_at = look_at end def dump(io) io.puts "camera {" - io.puts " orthographic" if @orthographic - io.printf(" location <%f, %f, %f >\n", *@location) - io.printf(" look_at <%f, %f, %f >\n", *@look_at) - io.printf(" sky <%f, %f, %f >\n", *@sky) - io.printf(" right <%f, %f, %f >\n", *@right) - io.printf(" up <%f, %f, %f >\n", *@up) - io.printf(" angle %f\n" , @angle) + io.printf(" %s\n", @camera_type) if @camera_type + io.printf(" location <%f, %f, %f >\n", *@location) if @location + io.printf(" right <%f, %f, %f >\n", *@right) if @right + io.printf(" up <%f, %f, %f >\n", *@up) if @up + io.printf(" direction <%f, %f, %f >\n", *@direction) if @direction + io.printf(" sky <%f, %f, %f >\n", *@sky) if @sky + io.printf(" angle %f\n" , @angle) if @angle + #@camera_modifiers.each do |i| + # io.puts i + #end + io.printf(" look_at <%f, %f, %f >\n", *@look_at) if @look_at io.puts "}" - @additions.each do |i| - io.puts i - end end end -