2013-09-06 19:00:28 -07:00
|
|
|
/* camera.h
|
|
|
|
*
|
2013-09-16 16:34:48 -07:00
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
|
2013-09-16 16:34:48 -07:00
|
|
|
#ifndef __CAMERA_H__
|
|
|
|
#define __CAMERA_H__
|
2013-09-06 19:00:28 -07:00
|
|
|
|
|
|
|
#include "basics.h"
|
2013-09-16 16:34:48 -07:00
|
|
|
#include "object.h"
|
2013-09-06 19:00:28 -07:00
|
|
|
|
|
|
|
|
2013-09-16 16:34:48 -07:00
|
|
|
class Camera
|
|
|
|
: public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Camera();
|
2014-07-16 23:24:31 -07:00
|
|
|
virtual ~Camera();
|
2013-09-06 19:00:28 -07:00
|
|
|
|
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;
|
|
|
|
|
2014-07-16 23:28:40 -07:00
|
|
|
const Vector3& GetRight() const;
|
|
|
|
void SetRight(const Vector3& right);
|
|
|
|
const Vector3& GetUp() const;
|
|
|
|
void SetUp(const Vector3& up);
|
2013-09-06 19:00:28 -07:00
|
|
|
|
2014-07-16 23:29:54 -07:00
|
|
|
virtual Ray compute_primary_ray(const int x, const int width,
|
|
|
|
const int y, const int height) const = 0;
|
2013-09-17 10:15:35 -07:00
|
|
|
|
2014-07-16 23:28:40 -07:00
|
|
|
private:
|
2013-09-16 16:34:48 -07:00
|
|
|
// 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.
|
2013-09-16 16:34:48 -07:00
|
|
|
Vector3 direction;
|
2014-07-16 23:28:40 -07:00
|
|
|
Vector3 mRight;
|
|
|
|
Vector3 mUp;
|
2013-09-06 19:00:28 -07:00
|
|
|
|
2013-09-16 16:34:48 -07:00
|
|
|
};
|
2013-09-06 19:00:28 -07:00
|
|
|
|
2013-09-16 16:34:48 -07:00
|
|
|
|
|
|
|
class OrthographicCamera
|
2013-09-20 09:21:25 -07:00
|
|
|
: public Camera
|
2013-09-16 16:34:48 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-07-16 23:29:54 -07:00
|
|
|
Ray compute_primary_ray(const int x, const int width,
|
|
|
|
const int y, const int height) const;
|
2013-09-16 16:34:48 -07:00
|
|
|
};
|
2013-09-06 19:00:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|