0001:
0002:
0003:
0004:
0005:
0006:
0007: #pragma once
0008:
0009: #define DX9C
0010:
0011: #ifdef DX9C
0012: #define BEGIN_PASS(n) m_pEffect->BeginPass(n)
0013: #define END_PASS() m_pEffect->EndPass()
0014: #else// DX9C
0015: #define BEGIN_PASS(n) m_pEffect->Pass(n)
0016: #define END_PASS()
0017: #endif
0018:
0019:
0020:
0021:
0022:
0023:
0024: struct UserInput
0025: {
0026: BOOL bRotateUp;
0027: BOOL bRotateDown;
0028: BOOL bRotateLeft;
0029: BOOL bRotateRight;
0030: BOOL bZoomIn;
0031: BOOL bZoomOut;
0032: BOOL bChangeShader;
0033: BOOL bDiffuseUp;
0034: BOOL bDiffuseDown;
0035: BOOL bSpecularUp;
0036: BOOL bSpecularDown;
0037: BOOL bTranslucentUp;
0038: BOOL bTranslucentDown;
0039: BOOL bPause;
0040: };
0041:
0042:
0043:
0044:
0045:
0046:
0047:
0048:
0049:
0050:
0051: class CMyD3DApplication : public CD3DApplication
0052: {
0053: enum{
0054: L_MAX = 1,
0055: TEX_MAX = ((L_MAX+1)*(L_MAX+1)+3)/4,
0056:
0057: REDUCTION_MAPS = 3,
0058: };
0059:
0060: float m_fDiffuse;
0061: float m_fSpecular;
0062: float m_fTranslucent;
0063:
0064:
0065: int m_iState;
0066: int m_iChangeState;
0067: int m_iCount;
0068: bool m_bPause;
0069:
0070:
0071: CD3DMesh *m_pMesh;
0072: CD3DMesh *m_pMeshBg;
0073: CD3DMesh *m_pMeshEnv;
0074:
0075:
0076: D3DXVECTOR3 m_pos;
0077: D3DXVECTOR3 m_vel;
0078: D3DXVECTOR3 m_rot;
0079: D3DXVECTOR3 m_omega;
0080:
0081: D3DXVECTOR3 m_EnvRot[4];
0082: FLOAT m_EnvRate;
0083: D3DXMATRIX m_mEnv;
0084:
0085:
0086: int m_Shader;
0087: LPD3DXEFFECT m_pEffect;
0088: D3DXHANDLE m_hTechnique;
0089: D3DXHANDLE m_hmWV;
0090: D3DXHANDLE m_hmWVP;
0091: D3DXHANDLE m_htSrcTex;
0092: D3DXHANDLE m_fWidth;
0093: D3DXHANDLE m_fHeight;
0094:
0095:
0096: LPDIRECT3DSURFACE9 m_pMapZ;
0097: LPDIRECT3DTEXTURE9 m_pPosTex;
0098: LPDIRECT3DSURFACE9 m_pPosSurf;
0099: LPDIRECT3DTEXTURE9 m_pPosLockTex;
0100: LPDIRECT3DSURFACE9 m_pPosLockSurf;
0101: LPDIRECT3DTEXTURE9 m_pNormalTex;
0102: LPDIRECT3DSURFACE9 m_pNormalSurf;
0103: LPDIRECT3DTEXTURE9 m_pNormalLockTex;
0104: LPDIRECT3DSURFACE9 m_pNormalLockSurf;
0105:
0106: LPDIRECT3DTEXTURE9 m_pParaboloidTex[2];
0107: LPDIRECT3DSURFACE9 m_pParaboloidSurf[2];
0108: LPDIRECT3DTEXTURE9 m_pJacobianTex[TEX_MAX][2];
0109:
0110: LPDIRECT3DTEXTURE9 m_pReductionTex [REDUCTION_MAPS];
0111: LPDIRECT3DSURFACE9 m_pReductionSurf[REDUCTION_MAPS];
0112:
0113: LPDIRECT3DTEXTURE9 m_p64Tex ;
0114: LPDIRECT3DSURFACE9 m_p64Surf;
0115: LPDIRECT3DSURFACE9 m_p64Z;
0116: LPDIRECT3DTEXTURE9 m_p64Tex2;
0117: LPDIRECT3DSURFACE9 m_p64Surf2;
0118: LPDIRECT3DTEXTURE9 m_p8Tex ;
0119: LPDIRECT3DSURFACE9 m_p8Surf;
0120:
0121: LPDIRECT3DTEXTURE9 m_pFinalTex[TEX_MAX];
0122: LPDIRECT3DSURFACE9 m_pFinalSurf[TEX_MAX];
0123: LPDIRECT3DTEXTURE9 m_pFinalSSTex[TEX_MAX];
0124: LPDIRECT3DSURFACE9 m_pFinalSSSurf[TEX_MAX];
0125: LPDIRECT3DTEXTURE9 m_pMaskTex;
0126:
0127:
0128: D3DXMATRIX m_mWorld;
0129: D3DXMATRIX m_mView;
0130: D3DXMATRIX m_mProj;
0131:
0132: FLOAT m_fWorldRotX;
0133: FLOAT m_fWorldRotY;
0134: FLOAT m_fViewZoom;
0135:
0136: BOOL m_bLoadingApp;
0137: CD3DFont* m_pFont;
0138: UserInput m_UserInput;
0139:
0140: protected:
0141: virtual HRESULT OneTimeSceneInit();
0142: virtual HRESULT InitDeviceObjects();
0143: virtual HRESULT RestoreDeviceObjects();
0144: virtual HRESULT InvalidateDeviceObjects();
0145: virtual HRESULT DeleteDeviceObjects();
0146: virtual HRESULT Render();
0147: virtual HRESULT FrameMove();
0148: virtual HRESULT FinalCleanup();
0149: virtual HRESULT ConfirmDevice( D3DCAPS9*, DWORD, D3DFORMAT );
0150:
0151: int FrameMoveCreateMap();
0152: void RenderCreateMap();
0153: int FrameMovePRT();
0154: void RenderPRT();
0155: int FrameMoveSSPRT();
0156: void RenderSSPRT();
0157: void RenderParaboloidMap();
0158:
0159: HRESULT RenderText();
0160:
0161: void UpdateInput( UserInput* pUserInput );
0162: public:
0163: LRESULT MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
0164: CMyD3DApplication();
0165: virtual ~CMyD3DApplication();
0166: };
0167:
0168: