nuclear@0: #ifndef CAMERA_H_ nuclear@0: #define CAMERA_H_ nuclear@0: nuclear@0: #include "vmath/vmath.h" nuclear@0: nuclear@0: class Camera { nuclear@0: protected: nuclear@0: Vector3 pos; nuclear@0: float vfov; // vertical field of view in radians nuclear@0: nuclear@0: mutable Matrix4x4 cached_matrix; nuclear@0: mutable bool cached_matrix_valid; nuclear@0: nuclear@0: mutable Vector3 *rdir_cache; nuclear@0: mutable int rdir_cache_width, rdir_cache_height; nuclear@5: mutable float rdir_cache_fov; nuclear@0: nuclear@0: virtual void calc_matrix(Matrix4x4 *mat) const = 0; nuclear@0: nuclear@0: Vector2 calc_sample_pos(int x, int y, int xsz, int ysz, int sample) const; nuclear@0: nuclear@0: public: nuclear@0: Camera(); nuclear@0: Camera(const Vector3 &pos); nuclear@0: virtual ~Camera(); nuclear@0: nuclear@0: virtual void set_fov(float vfov); nuclear@0: virtual float get_fov() const; nuclear@0: nuclear@0: virtual void set_position(const Vector3 &pos); nuclear@0: virtual const Vector3 &get_position() const; nuclear@0: virtual const Matrix4x4 &get_matrix() const; nuclear@0: nuclear@0: virtual Ray get_primary_ray(int x, int y, int xsz, int ysz, int sample = 0) const; nuclear@0: }; nuclear@0: nuclear@0: class TargetCamera : public Camera { nuclear@0: protected: nuclear@0: Vector3 target; nuclear@0: nuclear@0: void calc_matrix(Matrix4x4 *mat) const; nuclear@0: nuclear@0: public: nuclear@0: TargetCamera(); nuclear@0: TargetCamera(const Vector3 &pos, const Vector3 &targ); nuclear@0: nuclear@0: virtual void set_target(const Vector3 &targ); nuclear@0: virtual const Vector3 &get_target() const; nuclear@0: }; nuclear@0: nuclear@0: class FlyCamera : public Camera { nuclear@0: protected: nuclear@0: Quaternion rot; nuclear@0: nuclear@0: void calc_matrix(Matrix4x4 *mat) const; nuclear@0: nuclear@0: public: nuclear@0: void input_move(float x, float y, float z); nuclear@0: void input_rotate(float x, float y, float z); nuclear@0: }; nuclear@0: nuclear@0: #endif // CAMERA_H_