0001: //-------------------------------------------------------------
0002: // File: main.h
0003: //
0004: // Desc: Real-Time Global Illumination
0005: // Copyright (c) 2004 IMAGIRE Takashi. All rights reserved.
0006: //-------------------------------------------------------------
0007: #pragma once
0008: 
0009: //-------------------------------------------------------------
0010: // Defines, and constants(定義や定数)
0011: //-------------------------------------------------------------
0012: 
0013: // Struct to store the current input state(現在の入力データを保存する構造体)
0014: struct UserInput
0015: {
0016:     BOOL bRotateUp;
0017:     BOOL bRotateDown;
0018:     BOOL bRotateLeft;
0019:     BOOL bRotateRight;
0020:     BOOL bZoomIn;
0021:     BOOL bZoomOut;
0022:     BOOL bChangeShader;
0023:     BOOL bPause;
0024: };
0025: 
0026: 
0027: 
0028: 
0029: //-------------------------------------------------------------
0030: // Name: class CMyD3DApplication
0031: // Desc: Main class to run this application. Most functionality is inherited
0032: //       from the CD3DApplication base class.
0033: //       (アプリケーションのクラス)
0034: //-------------------------------------------------------------
0035: class CMyD3DApplication : public CD3DApplication
0036: {
0037:     // Scene management(シーン管理)
0038:     bool                    m_bPause;               // Pause
0039: 
0040:     // Model
0041:     CD3DMesh                *m_pMesh;
0042:     CD3DMesh                *m_pMeshBg;
0043:     CD3DMesh                *m_pMeshEnv;
0044:     
0045:     // Dynamics for a ball
0046:     D3DXVECTOR3             m_pos;                  // Position(位置)
0047:     D3DXVECTOR3             m_vel;                  // Velocity(速度)
0048:     D3DXVECTOR3             m_rot;                  // Rotation(位置)
0049:     D3DXVECTOR3             m_omega;                // Angler velocity(位置)
0050: 
0051:     // Shader
0052:     LPD3DXEFFECT            m_pEffect;              // Effect for the sample(エフェクト)
0053:     D3DXHANDLE              m_hTechnique;           // Technique handle for RenderScene(テクニック)
0054:     D3DXHANDLE              m_hmWV;                 // Handle for world+view matrix in effect(変換行列)
0055:     D3DXHANDLE              m_hmWVP;                // Handle for world+view+projection matrix in effect(変換行列)
0056:     D3DXHANDLE              m_htSrcTex;             // Handle for the scene texture in effect(テクスチャ)
0057:     D3DXHANDLE              m_fWidth;               // Handle for the texture width in effect(テクスチャ幅)
0058:     D3DXHANDLE              m_fHeight;              // Handle for the texture height in effect(テクスチャ高さ)
0059: 
0060:     // Rendering targets (レンダリングターゲット)
0061:     LPDIRECT3DSURFACE9      m_pMapZ;                // Depth buffer
0062:     LPDIRECT3DTEXTURE9      m_pParaboloidTex[2];    // Environment map
0063:     LPDIRECT3DSURFACE9      m_pParaboloidSurf[2];
0064:     LPDIRECT3DTEXTURE9      m_pTetrahedronTex[4];   // Environment map
0065:     LPDIRECT3DSURFACE9      m_pTetrahedronSurf[4];
0066: 
0067:     // Geometry (通常の座標変換行列)
0068:     D3DXMATRIX              m_mWorld;               // World matrix
0069:     D3DXMATRIX              m_mView;                // View matrix
0070:     D3DXMATRIX              m_mProj;                // Projection matrix
0071: 
0072:     D3DXMATRIX              m_mViewTetrahedron[4];  // View matrix
0073:     D3DXMATRIX              m_mProjTetrahedron;     // Projection matrix
0074:     
0075:     LPDIRECT3DVERTEXBUFFER9 m_pVB;
0076:     LPDIRECT3DINDEXBUFFER9  m_pIB;
0077: 
0078:     FLOAT                   m_fWorldRotX;   // World rotation state X-axis(X軸回転)
0079:     FLOAT                   m_fWorldRotY;   // World rotation state Y-axis(Y軸回転)
0080:     FLOAT                   m_fViewZoom;    // Distance to lookat (視点の距離)
0081: 
0082:     BOOL                    m_bLoadingApp;  // TRUE, if the app is loading(ロード中?)
0083:     CD3DFont*               m_pFont;        // Font for drawing text(フォント)
0084:     UserInput               m_UserInput;    // Struct for storing user input (入力データ)
0085: 
0086: protected:
0087:     virtual HRESULT OneTimeSceneInit();
0088:     virtual HRESULT InitDeviceObjects();
0089:     virtual HRESULT RestoreDeviceObjects();
0090:     virtual HRESULT InvalidateDeviceObjects();
0091:     virtual HRESULT DeleteDeviceObjects();
0092:     virtual HRESULT Render();
0093:     virtual HRESULT FrameMove();
0094:     virtual HRESULT FinalCleanup();
0095:     virtual HRESULT ConfirmDevice( D3DCAPS9*, DWORD, D3DFORMAT );
0096: 
0097:     void RenderParaboloidMap();
0098:     void DeleteQuad( );
0099:     void RenderQuad();
0100:     void InitQuad( );
0101: 
0102:     HRESULT RenderText();
0103: 
0104:     void    UpdateInput( UserInput* pUserInput );
0105: public:
0106:     LRESULT MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
0107:     CMyD3DApplication();
0108:     virtual ~CMyD3DApplication();
0109: };
0110: 
0111: