#ifndef __CAMERA_H #define __CAMERA_H #include "Vector3.h" #include "AxisAlignedBox3.h" namespace GtpVisibilityPreprocessor { class KdTree; class SceneGraph; class Camera { public: Vector3 mPosition; Vector3 mDirection; /** up vector takes into account the FOV at a unit distance from the origin */ Vector3 mUp; /** right vector takes into account the FOV at a unit distance from the origin */ Vector3 mRight; float mFovy; int mWidth; int mHeight; Camera() { mWidth = 1400; mHeight = 1000; mFovy = 90.0f*(float)M_PI/180.0f; } void Precompute() { mDirection.Normalize(); Vector3 side = CrossProd(Vector3(0,1,0), mDirection); mUp = Normalize(CrossProd(side, mDirection)); mRight = Normalize(CrossProd(mDirection, mUp)); float k = tan(mFovy/2); mUp *= k; mRight *= k*mWidth/mHeight; } void SetPosition(const Vector3 &pos) { mPosition = pos; Precompute(); } void SetDirection(const Vector3 &dir) { mDirection = dir; Precompute(); } void LookInBox(const AxisAlignedBox3 &box) { mDirection = Vector3(0,0,1); mPosition = box.Center(); Precompute(); } void LookAtBox(const AxisAlignedBox3 &box) { mDirection = box.Max() - box.Min(); mPosition = box.Min() - mDirection; Precompute(); } bool SnapImage(string filename, KdTree *tree, SceneGraph *sceneGraph ); void SetupRay(Ray &ray, const int x, const int y); }; }; #endif