0001: // ----------------------------------------------------------------------------
0002: //
0003: // draw.h - 全体的な定義
0004: //
0005: // Copyright (c) 2001 if (if@edokko.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: // 頂点の定義
0021: typedef struct {
0022: float x,y,z;
0023: float nx,ny,nz;
0024: float tu0,tv0;
0025: }D3DVERTEX;
0026: #define D3DFVF_VERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1)
0027:
0028:
0029: // ----------------------------------------------------------------------------
0030: // カメラ管理
0031: // ----------------------------------------------------------------------------
0032: class CMyView{
0033: D3DXMATRIX m_mView; // ビュー行列
0034: D3DXVECTOR4 m_eye; // カメラ位置
0035: D3DXVECTOR4 m_lookAt; // 注目店
0036: D3DXVECTOR4 m_up; // 上方向
0037:
0038: void Calc(){D3DXMatrixLookAtLH(&m_mView,(D3DXVECTOR3*)&m_eye,(D3DXVECTOR3*)&m_lookAt,(D3DXVECTOR3*)&m_up);}
0039: public:
0040: CMyView(){Init();}
0041: void Init(){m_eye.x = 0.0f; m_eye.y = 1.0f; m_eye.z = 2.5f; m_eye.w = 1.0f;
0042: m_lookAt.x = 0.0f; m_lookAt.y = 0.5f; m_lookAt.z = 0.0f; m_lookAt.w = 1.0f;
0043: m_up.x = 0.0f; m_up.y = 1.0f; m_up.z = 0.0f; m_up.w = 1.0f;
0044: this->Calc();}
0045: void SetEye (const D3DXVECTOR4 eye){m_eye = eye;this->Calc();}
0046: void SetLookAt(const D3DXVECTOR4 lookAt){m_lookAt=lookAt;this->Calc();}
0047: void SetUp (const D3DXVECTOR4 up){m_up = up;this->Calc();}
0048: const D3DXVECTOR4 &GetEye() const {return m_eye;}
0049: const D3DXVECTOR4 &GetLookAt() const {return m_lookAt;}
0050: const D3DXVECTOR4 &GetUp() const {return m_up;}
0051: const D3DXMATRIX &Get() const {return m_mView;}
0052: };
0053:
0054:
0055: #endif /* !_DRAW_H */
0056: