/*! -------------------------------------------------------------------- \file Camera.h \brief Class to a encapsulate a camera \author James Kuffner \date 2002-09-20 -------------------------------------------------------------------- */ #ifndef __CAMERA_H__ #define __CAMERA_H__ #include "pic.h" #include "m3d.h" //#include //! convenience definition for the Camera singleton #define theCamera Camera::getInstance() //--------------------------------------------------------------------- // CameraState // //! store a camera state using the familiar 'lookAt' parameters // //--------------------------------------------------------------------- struct CameraState { float eye[3]; //! eye position float target[3]; //! 'lookAt' target float up[3]; //! camera 'up' direction }; //--------------------------------------------------------------------- // Camera // //! Class to encapsulate a camera // //--------------------------------------------------------------------- class Camera { public: Camera(); virtual ~Camera() {} //! returns a handle to the singleton instance of Camera (use "theCamera") static Camera& getInstance() { if (!s_pCamera) s_pCamera = new Camera(); return *s_pCamera; }; //! set the camera viewing parameters void SetViewingParams(float fov, float near_clip, float far_clip); //! set the aspect ratio void SetAspectRatio(float aspect); //! function to retrieve the camera state const CameraState& GetDefaultLocation() const { return s_defaultState; } //! function to manipulate the camera state void SetLocation(const CameraState &state) { _state = state; } //! function to retrieve the camera state const CameraState& GetLocation() const { return _state; } //! load the viewing transformations on the GL matrix stacks void SetGLViewTransforms(); // static Vec3 Camera::RotateVec(float angle, Vec3 rotVec, Vec3 curVec); // static void CaptureImage(int num); //////////////////////////////////////////////////////////////// static const float DEFAULT_FOV = 60.0; static const float DEFAULT_NEAR_CLIP = 0.5; static const float DEFAULT_FAR_CLIP = 1000.0; static const float DEFAULT_ASPECT = 1.33333333; //protected: //! singleton instance static Camera *s_pCamera; private: //! default camera location static CameraState s_defaultState; //! stores camera viewing parameters float _fov; float _nearClip; float _farClip; float _aspectRatio; //! stores camera state CameraState _state; }; #endif // __CAMERA_H__