Use the PerspectiveCamera to generate primary rays.

This commit is contained in:
Eryn Wells 2014-07-16 23:32:44 -07:00
parent 899064ce42
commit 25b246d3ed
2 changed files with 10 additions and 5 deletions

View file

@ -18,6 +18,7 @@
Scene::Scene()
: width(640), height(480),
camera(new PerspectiveCamera()),
max_depth(5),
min_weight(1e-4),
ambient(new AmbientLight()),
@ -30,6 +31,11 @@ Scene::Scene()
Scene::~Scene()
{
if (camera) {
delete camera;
camera = NULL;
}
if (ambient != NULL) {
delete ambient;
}
@ -130,11 +136,7 @@ Scene::render()
Vector3 o, d;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
// Assemble a ray and trace it.
o = Vector3(x, y, -1000);
d = Vector3(0, 0, 1);
d.normalize();
primary_ray = Ray(o, d);
primary_ray = camera->compute_primary_ray(x, width, y, height);
Color c = trace_ray(primary_ray);
pixels[y * width + x] = c;
}

View file

@ -14,6 +14,7 @@
#include <list>
#include <string>
#include "basics.h"
#include "camera.h"
class AmbientLight;
@ -49,6 +50,8 @@ private:
// Pixel dimensions of the image.
int width, height;
Camera *camera;
/*
* Ray tracing parameters. max_depth indicates the maximum depth of the ray tree. min_weight indicates the minimum
* specular weight to apply before giving up.