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: // 床の大きさ (x,z 軸に関して、範囲は -FLOOR_SIZE~FLOOR_SIZE)
0016: #define FLOOR_SIZE  (50.0f)
0017: 
0018: HRESULT InitRender(LPDIRECT3DDEVICE8 lpD3DDEV);                 // 初期化
0019: void Render(LPDIRECT3DDEVICE8 lpD3DDEV);                        // 描画
0020: void CleanRender(LPDIRECT3DDEVICE8 lpD3DDEV);                   // 後片付け
0021: 
0022: // ----------------------------------------------------------------------------
0023: // ビュー座標系の管理
0024: // ----------------------------------------------------------------------------
0025: class CMyView{
0026:     D3DXMATRIX              m_mView;    // ビュー行列
0027:     D3DXVECTOR4             m_eye;      // カメラの位置
0028:     D3DXVECTOR4             m_lookAt;   // カメラの注目点
0029:     D3DXVECTOR4             m_up;       // カメラの上方向
0030: 
0031:     void Calc(){
0032:         D3DXVECTOR4 eye = m_eye+m_lookAt;
0033:         D3DXMatrixLookAtLH(&m_mView,(D3DXVECTOR3*)&eye,(D3DXVECTOR3*)&m_lookAt,(D3DXVECTOR3*)&m_up);
0034:     }
0035: public:
0036:     CMyView(){Init();}
0037:     void Init(){m_eye.x    = 0.0f; m_eye.y    = 0.0f; m_eye.z    =-30.0f; m_eye.w    = 1.0f;
0038:                 m_lookAt.x = 0.0f; m_lookAt.y = 0.0f; m_lookAt.z = 0.0f; m_lookAt.w = 1.0f; 
0039:                 m_up.x     = 0.0f; m_up.y     = 1.0f; m_up.z     = 0.0f; m_up.w     = 1.0f; 
0040:                 this->Calc();}
0041:     void SetEye   (D3DXVECTOR4    eye){m_eye   =   eye;this->Calc();}
0042:     void SetLookAt(D3DXVECTOR4 lookAt){m_lookAt=lookAt;this->Calc();}
0043:     void SetUp    (D3DXVECTOR4     up){m_up    =    up;this->Calc();}
0044:     D3DXVECTOR4 GetEye()   {return m_eye;}
0045:     D3DXVECTOR4 GetLookAt(){return m_lookAt;}
0046:     D3DXVECTOR4 GetUp()    {return m_up;}
0047:     D3DXMATRIX Get(){return m_mView;}
0048: };
0049: extern CMyView  view;
0050: 
0051: 
0052: #endif /* !_DRAW_H */
0053: