www.pudn.com > GameEngine.rar > GameEngine_light.cpp, change:2005-10-01,size:2346b


#include "..\GameEngine_Common.h" 
#include "GameEngine_Light.h" 
 
CGameEngine_Light::CGameEngine_Light(){ 
	//初始化为点光源 
	ZeroMemory(&m_Light, sizeof(D3DLIGHT9)); 
	SetLightType(D3DLIGHT_POINT); 
	SetLightPos(0.0f,0.0f,0.0f); 
	SetDiffuseColor(255,255,255,255); 
	SetAmbientColor(255,255,255,255); 
	SetRange(10000.0f); 
} 
 
CGameEngine_Light::~CGameEngine_Light(){} 
 
 
 
void CGameEngine_Light::SetLightType(D3DLIGHTTYPE type){ 
	ZeroMemory(&m_Light,sizeof(D3DLIGHT9)); 
	m_Light.Type=type; 
} 
 
void CGameEngine_Light::SetDiffuseColor(unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha){ 
	m_Light.Diffuse.r=1.0f/255.0f * (float)red; 
	m_Light.Diffuse.g=1.0f/255.0f * (float)green; 
	m_Light.Diffuse.b=1.0f/255.0f * (float)blue; 
	m_Light.Diffuse.a=1.0f/255.0f * (float)alpha; 
} 
 
void CGameEngine_Light::SetAmbientColor(unsigned char red, unsigned char green, unsigned char blue,unsigned char alpha) 
{ 
	m_Light.Ambient.r=1.0f/255.0f * (float)red; 
	m_Light.Ambient.g=1.0f/255.0f * (float)green; 
	m_Light.Ambient.b=1.0f/255.0f * (float)blue; 
	m_Light.Ambient.a=1.0f/255.0f * (float)alpha; 
} 
 
void CGameEngine_Light::SetSpecularColor(unsigned char red, unsigned char green, unsigned char blue,unsigned char alpha) 
{ 
	m_Light.Specular.r=1.0f/255.0f * (float)red; 
	m_Light.Specular.g=1.0f/255.0f * (float)green; 
	m_Light.Specular.b=1.0f/255.0f * (float)blue; 
	m_Light.Specular.a=1.0f/255.0f * (float)alpha; 
} 
 
void CGameEngine_Light::SetRange(float fRange) 
{ 
  m_Light.Range=fRange; 
} 
 
void CGameEngine_Light::SetFalloff(float fFalloff) 
{ 
  m_Light.Falloff=fFalloff; 
} 
 
void CGameEngine_Light::SetTheta(float fTheta) 
{ 
  m_Light.Theta=fTheta; 
} 
 
void CGameEngine_Light::SetPhi(float fPhi) 
{ 
  m_Light.Phi=fPhi; 
} 
 
void CGameEngine_Light::SetAttenuation0(float fAttenuation) 
{ 
  m_Light.Attenuation0=fAttenuation; 
} 
 
void CGameEngine_Light::SetAttenuation1(float fAttenuation) 
{ 
  m_Light.Attenuation1=fAttenuation; 
} 
 
void CGameEngine_Light::SetAttenuation2(float fAttenuation) 
{ 
  m_Light.Attenuation2=fAttenuation; 
} 
 
void CGameEngine_Light::SetLightPos(float fPosX, float fPosY, float fPosZ) 
{ 
  m_Light.Position.x=fPosX; 
  m_Light.Position.y=fPosY; 
  m_Light.Position.z=fPosZ; 
} 
 
D3DLIGHT9* CGameEngine_Light::GetLight(){ 
	return &m_Light; 
}