Class: Rubytracer::Camera
- Inherits:
-
Object
- Object
- Rubytracer::Camera
- Defined in:
- lib/rubytracer/camera.rb
Instance Method Summary collapse
- #colour_of_pixel(row, col) ⇒ Object
-
#initialize(view, scene) ⇒ Camera
constructor
A new instance of Camera.
Constructor Details
#initialize(view, scene) ⇒ Camera
Returns a new instance of Camera.
3 4 5 6 |
# File 'lib/rubytracer/camera.rb', line 3 def initialize(view, scene) @view = view @scene = scene end |
Instance Method Details
#colour_of_pixel(row, col) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubytracer/camera.rb', line 8 def colour_of_pixel(row, col) ray = @view.eye_ray(row, col) obj, t = @scene.intersect(ray) if t == Float::INFINITY Colour.new(0.6,0.6,0.6) else pos = ray.pos(t) normal = obj.normal(pos) obj.material.lit_colour(@scene, normal, -ray.dir, pos) end end |