charles/src/camera.h

73 lines
1.6 KiB
C
Raw Normal View History

2013-09-06 19:00:28 -07:00
/* camera.h
*
2014-07-19 16:30:26 -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>
*/
#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
2014-07-19 17:24:52 -07:00
struct Camera
: public Object
{
public:
Camera();
2014-07-19 17:24:52 -07:00
Camera(const Camera& other);
virtual ~Camera();
2013-09-06 19:00:28 -07:00
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;
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
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
private:
2014-07-19 16:30:26 -07:00
/** A normalized vector defining where the camera is pointed. */
2014-07-19 17:24:52 -07:00
Vector3 mDirection;
2014-07-19 16:30:26 -07:00
/**
* A vector defining the width of the camera's image plane. The ratio of
* this and mUp determine the aspect ratio of the image.
*/
Vector3 mRight;
2014-07-19 16:30:26 -07:00
/**
* A vector defining the height of the camera's image plane. The ratio of
* this and mUp determine the aspect ratio of the image.
*/
Vector3 mUp;
};
2013-09-06 19:00:28 -07:00
class PerspectiveCamera
: public Camera
{
Ray compute_primary_ray(const int x, const int width,
const int y, const int height) const;
};
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 width,
const int y, const int height) const;
};
2013-09-06 19:00:28 -07:00
#endif