0001: // ---------------------------------------------------------------------------- 0002: // 0003: // draw.h - Rendering 0004: // 0005: // Copyright (c) 2002 IMAGIRE Takashi (imagire@gmail.com) 0006: // All Rights Reserved. 0007: // 0008: // ---------------------------------------------------------------------------- 0009: #ifndef _DRAW_H 0010: #define _DRAW_H 0011: 0012: #include <d3d8.h> 0013: #include <d3dx8.h> 0014: 0015: HRESULT InitRender(LPDIRECT3DDEVICE8 lpD3DDEV); 0016: void Render(LPDIRECT3DDEVICE8 lpD3DDEV); 0017: void CleanRender(LPDIRECT3DDEVICE8 lpD3DDEV); 0018: 0019: // ---------------------------------------------------------------------------- 0020: // Management of the camera 0021: // ---------------------------------------------------------------------------- 0022: class CMyView{ 0023: D3DXMATRIX m_mView; // View matrix 0024: D3DXVECTOR4 m_eye; // camera position 0025: D3DXVECTOR4 m_lookAt; // camera look at 0026: D3DXVECTOR4 m_up; // up direction 0027: 0028: void Calc(){D3DXMatrixLookAtLH(&m_mView,(D3DXVECTOR3*)&m_eye,(D3DXVECTOR3*)&m_lookAt,(D3DXVECTOR3*)&m_up);} 0029: public: 0030: CMyView(){Init();} 0031: void Init(){m_eye.x = 0.0f; m_eye.y = 1.0f; m_eye.z = 2.5f; m_eye.w = 1.0f; 0032: m_lookAt.x = 0.0f; m_lookAt.y = 0.5f; m_lookAt.z = 0.0f; m_lookAt.w = 1.0f; 0033: m_up.x = 0.0f; m_up.y = 1.0f; m_up.z = 0.0f; m_up.w = 1.0f; 0034: this->Calc();} 0035: void SetEye (const D3DXVECTOR4 eye){m_eye = eye;this->Calc();} 0036: void SetLookAt(const D3DXVECTOR4 lookAt){m_lookAt=lookAt;this->Calc();} 0037: void SetUp (const D3DXVECTOR4 up){m_up = up;this->Calc();} 0038: const D3DXVECTOR4 &GetEye() const {return m_eye;} 0039: const D3DXVECTOR4 &GetLookAt() const {return m_lookAt;} 0040: const D3DXVECTOR4 &GetUp() const {return m_up;} 0041: const D3DXMATRIX &Get() const {return m_mView;} 0042: }; 0043: 0044: #endif /* !_DRAW_H */ 0045: