#ifndef CAMERA_H #define CAMERA_H namespace fw { class Camera : public SceneNode { public: Camera(const std::string& sName); virtual ~Camera(); virtual D3DXMATRIX* GetViewMatrix(); virtual D3DXMATRIX* GetProjectionMatrix(); void LookAt(const D3DXVECTOR3& lookAt); D3DXVECTOR3 GetLookAt(); virtual void SetTarget(const D3DXVECTOR3& target); D3DXVECTOR3 GetTarget(); void SetTarget(float x, float y, float z); std::string& GetName(); virtual void Update(float fTimeSinceLastFrame); void SetUpVector(const D3DXVECTOR3& up); D3DXVECTOR3 GetUpVector(); float GetNearValue(); float GetFarValue(); virtual void RebuildProj(); void SetIgnoreUpdate(bool bIgnore); bool GetIgnoreUpdate(); template<typename D3DVersion> AbstractShaderSceneNode* LoadCameraMesh() { if (MESH_CACHES_MANAGER(D3DVersion)->MeshBufferExists("CameraMesh")) { const MeshBuffers<D3DVersion::BufferType>* pMesh = MESH_CACHES_MANAGER(D3DVersion)->GetMeshBuffers("CameraMesh"); D3DMeshSceneNode<D3DVersion>* pCameraMeshSceneNode = new D3DMeshSceneNode<D3DVersion>("CameraMesh"); pCameraMeshSceneNode->SetMeshBuffers(pMesh); SAFE_DELETE(m_pCameraSceneNode); m_pCameraSceneNode = pCameraMeshSceneNode; } else { D3DMeshSceneNode<D3DVersion>* pCameraMeshSceneNode = OBJ_LOADER_MANAGER->LoadMesh<D3DVersion>("camera.obj"); const MeshBuffers<D3DVersion::BufferType>* pMesh(pCameraMeshSceneNode); SAFE_DELETE(m_pCameraSceneNode); m_pCameraSceneNode = pCameraMeshSceneNode; MESH_CACHES_MANAGER(D3DVersion)->AddMeshBuffer("CameraMesh", pMesh); } return m_pCameraSceneNode; } virtual void OnTransformationChange() override; protected: virtual void BuildView(); protected: D3DXVECTOR3 m_lookAt; D3DXVECTOR3 m_right; D3DXVECTOR3 m_up; D3DXMATRIX m_view; private: void UpdateLens(float fFov, float fAspect, float fNearZ, float fFarZ); private: D3DXMATRIX m_proj; std::string m_sName; float m_fNear; float m_fFar; bool m_bIgnoreUpdate; AbstractShaderSceneNode* m_pCameraSceneNode; }; } #endif