#ifndef __CAMERA_H #define __CAMERA_H #include "Vector3.h" #include "AxisAlignedBox3.h" #include "Plane3.h" namespace CHCDemoEngine { class Camera { public: /** Small struct representing a frustum. */ struct Frustum { /// the 6 clip planes //float mClipPlane[6][4]; Plane3 mClipPlanes[6]; void CalcNPVertexIndices(int *indices); }; Camera(); Camera(int width, int height, float fieldOfView = 90.f); void Precompute(); void LookInBox(const AxisAlignedBox3 &box); void LookAtBox(const AxisAlignedBox3 &box); void SetPosition(const Vector3 &pos); void SetDirection(const Vector3 &dir); inline Vector3 GetPosition() const { return mPosition; } inline Vector3 GetDirection() const { return mDirection; } inline Vector3 GetUpVector() const { return mUp; } inline Vector3 GetRightVector() const { return mRight; } inline float GetFov() const { return mFovy; } inline void GetSize(int &width, int &height) const { width = mWidth; height = mHeight; } inline float GetAspect() const { return (float) mWidth / mHeight; } void SetupCameraView(); void GetProjectionMatrix(Matrix4x4 &mat); void GetModelViewMatrix(Matrix4x4 &mat); void CalcFrustum(Frustum &frustum); void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr); inline float GetNear() const { return mNear; } void SetNear(float nearDist); protected: //////////////// 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; float mNear; }; } #endif