www.pudn.com > notWow.rar > Effect.h


#pragma once  
#include "Enums.h" 
#include  
#include  
 
class Effect 
{ 
	LPD3DXEFFECT            m_pEffect; 
	LPDIRECT3DDEVICE9		m_pd3dDevice; 
 
	D3DXHANDLE				m_hViewProj;			 
	D3DXHANDLE				m_hMatrixPalette;			 
	D3DXHANDLE				m_hAmbient; 
	D3DXHANDLE				m_hDiffuse; 
	D3DXHANDLE				m_hEmissive; 
	D3DXHANDLE				m_hSpecular; 
	D3DXHANDLE				m_hPosition; 
	D3DXHANDLE				m_hDirection; 
	D3DXHANDLE				m_hLightDir; 
	D3DXHANDLE				m_hLightColor; 
	D3DXHANDLE				m_hAlpha; 
	D3DXHANDLE				m_hTexture; 
public: 
	Effect() : m_pEffect(NULL),m_pd3dDevice(NULL) {} 
 
	bool Init(LPDIRECT3DDEVICE9	pd3dDevice); 
	void Free(); 
	bool Reset(); 
	void Lost(); 
 
	void SetTechnique(EFFECTTYPE Type); 
	void SetTechnique(MODELTYPE	 Type); 
 
	inline LPD3DXEFFECT GetD3DEffect()			{ return m_pEffect;					} 
 
	inline void CommitChanges()					{ m_pEffect->CommitChanges();		} 
	inline void Begin(UINT* pPasses,DWORD Flags){ m_pEffect->Begin(pPasses,Flags);	} 
	void End()									{ m_pEffect->End();					} 
	void BeginPass(int Pass)					{ m_pEffect->BeginPass(Pass);		} 
	void EndPass()								{ m_pEffect->EndPass();				} 
 
	inline void SetViewProjMatrix(D3DXMATRIX *pmatViewProj) 
	{ 
		m_pEffect->SetMatrix(m_hViewProj,pmatViewProj); 
	} 
	inline void SetMatrixPalette(D3DXMATRIX *pPalette,int count) 
	{ 
		m_pEffect->SetMatrixArray(m_hMatrixPalette,pPalette,count); 
	} 
	inline void SetAmbient(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hAmbient,pVec); 
	} 
	inline void SetDiffuse(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hDiffuse,pVec); 
	} 
	inline void SetEmissive(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hEmissive,pVec); 
	} 
	inline void SetSpecular(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hSpecular,pVec); 
	} 
	inline void SetPosition(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hPosition,pVec); 
	} 
	inline void SetAlpha(float fVal) 
	{ 
		m_pEffect->SetFloat(m_hAlpha,fVal); 
	} 
	inline void SetLightDir(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hLightDir,pVec); 
	} 
	inline void SetLightColor(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hLightColor,pVec); 
	} 
	//------------------------------------- 
	// the Direction.x is sin(DirAngle) 
	// the Direction.y is cos(DirAngle) 
	//-------------------------------------- 
	inline void SetDirection(D3DXVECTOR4 *pVec) 
	{ 
		m_pEffect->SetVector(m_hDirection,pVec); 
	} 
	void SetTexture(LPDIRECT3DTEXTURE9 pTex); 
 
};