1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
   | #include <string>
#include <vector>
 
#define _3D_ENGINE_API __declspec(dllexport)
 
using namespace std;
 
/****************************************
* Class CT4UDLL_3D_ENGINE               *
* Includes the 3D objects of the scene  *
****************************************/
class _3D_ENGINE_API CT4UDLL_3D_ENGINE					
{
private:
 
	string							sCurrentDirectory;
	LPDIRECT3DDEVICE9				m_pd3dDevice;
	LPDIRECT3DSURFACE9				m_pBackBufferSurface;
	UINT                            inScreenWidth;          // Width of the scene
	UINT                            inScreenHeight;         // Height of the scene
 
	CMainCamera*					m_pMainCamera;			// The main camera for navigating the scene
	CCamera*						m_pLightCamera;			// A virtual camera placed on lights position 
	                                                        // For rendering to cubic shadow map
	CShadowEffect*					m_pShadowEffect;		// Effect for cubic shadow mapping
	D3DXVECTOR3						m_LightPosition;
 
	vector<CMesh*>					m_p3DObject;            // 3D Objects in the scene
    CMesh*                          m_pLight;               // Light in the scene
	int                             Nb_3DObjects;           // Excluding the light
 
	//	The cubic shadow map and 6 face surfaces of it
	LPDIRECT3DCUBETEXTURE9			cubicShadowMap;
	LPDIRECT3DSURFACE9				depthCubeFacePX;
	LPDIRECT3DSURFACE9				depthCubeFacePY;
	LPDIRECT3DSURFACE9				depthCubeFacePZ;
	LPDIRECT3DSURFACE9				depthCubeFaceNX;
	LPDIRECT3DSURFACE9				depthCubeFaceNY;
	LPDIRECT3DSURFACE9              depthCubeFaceNZ;
 
	D3DXVECTOR3						m_PositiveLookX;
	D3DXVECTOR3						m_PositiveLookY;
	D3DXVECTOR3						m_PositiveLookZ;
	D3DXVECTOR3						m_NegativeLookX;
	D3DXVECTOR3						m_NegativeLookY;
	D3DXVECTOR3						m_NegativeLookZ;
 
	//helper functions for setting up the light's camera for rendering to the depth map surface
	void							CreateCamForPositiveX();
	void							CreateCamForNegativeX();
	void							CreateCamForPositiveY();
	void							CreateCamForNegativeY();
	void							CreateCamForPositiveZ();
	void							CreateCamForNegativeZ();
 
	void							OnFrameMove(DWORD inTimeDelta);
 
	//helper functions for rendering the objects to a specified depth cube face
	void							RenderDepthToCubeFace(LPDIRECT3DSURFACE9 inCubeFaceSurface);
	//helper function for filling six faces of depth cube map
	void							FillCubicShadowMap();
	//helper function for rendering the scene using cubic shadow map
	void							RenderSceneWithShadowMap();
 
public:
 
	// singleton stuff
	static CT4UDLL_3D_ENGINE&       getInstance( const string& _CurrentDirectory, const LPDIRECT3DDEVICE9 _pd3dDevice,
                                                 const LPDIRECT3DSURFACE9 _pBackBufferSurface, UINT _inScreenWidth, 
												 UINT _inScreenHeight);
 	CT4UDLL_3D_ENGINE( const string& _CurrentDirectory, const LPDIRECT3DDEVICE9 _pd3dDevice,
                       const LPDIRECT3DSURFACE9 _pBackBufferSurface, UINT _inScreenWidth, UINT _inScreenHeight);
	~CT4UDLL_3D_ENGINE(void);
 
	int                             Read_SceneObjects( const string& sSceneFileName);
	int 							Initialize( const string& sSceneFileName);
	void							Render_3DScene(DWORD inTimeDelta);
	void							CleanUp();
}; | 
Partager