charles/src/camera.h

61 lines
1.3 KiB
C
Raw Normal View History

2013-09-06 19:00:28 -07:00
/* camera.h
*
* The Camera is the eye into the scene. It defines several parameters and a single compute_primary_ray method
* that generates rays with which the ray tracer draws the scene.
2013-09-06 19:00:28 -07:00
*
* Eryn Wells <eryn@erynwells.me>
*/
#ifndef __CAMERA_H__
#define __CAMERA_H__
2013-09-06 19:00:28 -07:00
#include "basics.h"
#include "object.h"
2013-09-06 19:00:28 -07:00
class Camera
: public Object
{
public:
Camera();
~Camera();
2013-09-06 19:00:28 -07:00
2013-09-17 10:15:35 -07:00
int get_pixel_width() const;
2013-09-20 09:21:25 -07:00
void set_pixel_width(const int &w);
int get_pixel_height() const;
void set_pixel_height(const int &h);
2013-09-17 10:15:35 -07:00
const Vector3 &get_width() const;
2013-09-20 09:21:25 -07:00
void set_width(const Vector3 &w);
const Vector3 &get_height() const;
void set_height(const Vector3 &h);
2013-09-17 10:15:35 -07:00
const Vector3 &get_direction() const;
2013-09-20 09:21:25 -07:00
void set_direction(const Vector3 &d);
2013-09-17 10:15:35 -07:00
float get_angle() const;
virtual Ray compute_primary_ray(const int &x, const int &y) const = 0;
2013-09-06 19:00:28 -07:00
private:
2013-09-17 10:15:35 -07:00
// Pixel dimensions of the image plane.
int pwidth, pheight;
// Size of the image plane.
Vector3 height, width;
2013-09-17 10:15:35 -07:00
// Direction. A normalized vector defining where the camera is pointed.
Vector3 direction;
2013-09-06 19:00:28 -07:00
// Horizontal viewing angle.
float angle;
};
2013-09-06 19:00:28 -07:00
class OrthographicCamera
2013-09-20 09:21:25 -07:00
: public Camera
{
public:
Ray compute_primary_ray(const int &x, const int &y) const;
};
2013-09-06 19:00:28 -07:00
#endif