00001 /****************************************************************************\ 00002 * * 00003 * 28.03.2006 * 00004 * CCamera - Header File * 00005 * * 00006 * (c) Robert Hausmair * 00007 * * 00008 \****************************************************************************/ 00009 00010 #ifndef __CCAMERA_H__ 00011 #define __CCAMERA_H__ 00012 00013 /****************************************************************************\ 00014 * REQUIRED HEADERS * 00015 \****************************************************************************/ 00016 00017 //need to include this in every class, that includes "gl/gl.h" 00018 #include <QGLWidget> 00019 00020 #include <Definitions.h> 00021 #include <Memory/mmgr.h> 00022 #include <Memory/IManagedObject.h> 00023 #include <Memory/TSmartPointer.h> 00024 #include "CFrustum.h" 00025 00026 /****************************************************************************\ 00027 * DEFINITIONS * 00028 \****************************************************************************/ 00029 #define RT 0 00030 #define TR 1 00031 00032 /****************************************************************************\ 00033 * CLASS * 00034 \****************************************************************************/ 00035 class CCamera : public IManagedObject 00036 { 00037 /**************************************************************************\ 00038 * PUBLIC CLASS FUNCTIONS * 00039 \**************************************************************************/ 00040 public: 00041 CCamera() {Clear();} 00042 ~CCamera(){} 00043 00044 //State settings set by ICamCtrl 00045 void SetPerspective(const float &fFov, const float &fAspectRatio, const float &fNearZ, const float &fFarZ); 00046 void SetTransformOrder(byte order); 00047 void SetFOV(float fov); 00048 void SetAspect(const float &fAspectRatio); 00049 void SetPos(const CVector3f &vPos); 00050 void SetRot(const CVector3f &vRot); 00051 00052 inline float GetFOV(){return m_fov;} 00053 const CMatrix44 &GetTransformation(); 00054 inline CVector3f GetViewVector(){} 00055 00056 //Get current frustum. Only valid until next movement/state function is called 00057 const CFrustum &GetFrustum(); 00058 00059 inline bool CameraChanged() const {return !m_bTransformValid;} 00060 00061 //Call to Update if View or Transform changed 00062 void UpdateView(); 00063 void UpdateTransForm(); 00064 00065 //Call to Force Update of View or Transform 00066 void ForceUpdateView(){m_bPerspectiveValid = false;UpdateView();} 00067 void ForceUpdateTransform(){m_bTransformValid = false;UpdateTransForm();} 00068 00069 //Call to Force Update and View together 00070 void Refresh(); 00071 00072 //Debugging: 00073 void Log(word wTargetLog); 00074 00075 /**************************************************************************\ 00076 * PROTECTED CLASS FUNCTIONS * 00077 \**************************************************************************/ 00078 protected: 00079 00080 /**************************************************************************\ 00081 * PRIVATE CLASS FUNCTIONS * 00082 \**************************************************************************/ 00083 private: 00084 void Clear(); 00085 void Update(); 00086 00087 //Private copy constructor and assignment operator to prevent mistakes: 00088 CCamera(const CCamera &); 00089 CCamera &operator =(const CCamera &); 00090 00091 /**************************************************************************\ 00092 * PRIVATE CLASS MEMBERS * 00093 \**************************************************************************/ 00094 private: 00095 CMatrix44 m_Projection; 00096 CMatrix44 m_View; 00097 CMatrix44 m_Pos; 00098 CMatrix44 m_Rot; 00099 CVector3f m_vPos,m_vRot; 00100 float m_fov,m_nearPlane,m_farPlane,m_aspect; 00101 CFrustum m_Frustum; 00102 byte m_TransformOrder; 00103 00104 //States 00105 bool m_bTransformValid; 00106 bool m_bPerspectiveValid; 00107 }; 00108 00109 #endif