Fix compiler errors in camera module

This commit is contained in:
Eryn Wells 2013-09-20 09:21:25 -07:00
parent 746731398a
commit f6e92f2571
2 changed files with 30 additions and 11 deletions

View file

@ -38,9 +38,9 @@ Camera::get_pixel_width()
} }
void void
Camera::set_pixel_width(const int &pw) Camera::set_pixel_width(const int &w)
{ {
pwidth = pw; pwidth = w;
} }
int int
@ -51,9 +51,9 @@ Camera::get_pixel_height()
} }
void void
Camera::set_pixel_height(const int &ph) Camera::set_pixel_height(const int &h)
{ {
pheight = ph; pheight = h;
} }
@ -86,7 +86,7 @@ Camera::get_height()
} }
void void
Camera::get_height(const Vector3 &h) Camera::set_height(const Vector3 &h)
{ {
height = h; height = h;
} }
@ -111,6 +111,19 @@ Camera::set_direction(const Vector3 &d)
direction = d; direction = d;
} }
/*
* Camera::get_angle --
*
* Get the angle of view.
*/
float
Camera::get_angle()
const
{
return angle;
}
#pragma mark - Orthographic Camera #pragma mark - Orthographic Camera
/* /*
@ -126,12 +139,12 @@ OrthographicCamera::compute_primary_ray(const int &x,
const const
{ {
// Calculate the point on the image plane that the given (x,y) coordinate pair corresponds to. // Calculate the point on the image plane that the given (x,y) coordinate pair corresponds to.
float dir_x = (x / pwidth) + 0.5; float dir_x = (x / get_pixel_width()) + 0.5;
float dir_y = (y / pheight) + 0.5; float dir_y = (y / get_pixel_height()) + 0.5;
Vector3 ray_origin = (dir_x * width) + (dir_y * height) + direction; Vector3 ray_origin = (dir_x * get_width()) + (dir_y * get_height()) + get_direction();
// Calculate the direction of the ray, given the camera's origin and normalize that vector. // Calculate the direction of the ray, given the camera's origin and normalize that vector.
Vector3 ray_direction = (image_point - get_origin()).normalize(); Vector3 ray_direction = (ray_origin - get_origin()).normalize();
return Ray(get_origin(), ray_direction); return Ray(get_origin(), ray_direction);
} }

View file

@ -20,11 +20,16 @@ public:
Camera(); Camera();
~Camera(); ~Camera();
int get_pixel_height() const;
int get_pixel_width() const; int get_pixel_width() const;
const Vector3 &get_height() const; void set_pixel_width(const int &w);
int get_pixel_height() const;
void set_pixel_height(const int &h);
const Vector3 &get_width() const; const Vector3 &get_width() const;
void set_width(const Vector3 &w);
const Vector3 &get_height() const;
void set_height(const Vector3 &h);
const Vector3 &get_direction() const; const Vector3 &get_direction() const;
void set_direction(const Vector3 &d);
float get_angle() const; float get_angle() const;
virtual Ray compute_primary_ray(const int &x, const int &y) const = 0; virtual Ray compute_primary_ray(const int &x, const int &y) const = 0;
@ -45,6 +50,7 @@ private:
class OrthographicCamera class OrthographicCamera
: public Camera
{ {
public: public:
Ray compute_primary_ray(const int &x, const int &y) const; Ray compute_primary_ray(const int &x, const int &y) const;