Original Post
Hi,
I saw the article about Lense-Flares here and now I want to render Lense-Flares in my game. Fortunately I can't see them: Can somebody help me?
Here the code:
// Weltmatrix zurücksetzen
tbDirect3D::GetDevice()->SetTransform(D3DTS_WORLD, (D3DMATRIX*)(&tbMatrixIdentity()));
// Sonne und LenseFlares rendern
D3DLIGHT9 PointLight;
ZeroMemory(&PointLight, sizeof(D3DLIGHT9));
PointLight.Type = D3DLIGHT_POINT; // Punktlicht
PointLight.Diffuse = tbColor(1.0f, 1.0f, 0.75f); // Gelbe Streufarbe
PointLight.Ambient = tbColor(1.0f, 1.0f, 0.75f); // Gelbe Hintergrundfarbe
PointLight.Position = tbVector3(0,0,0); // Die Position der Sonne
PointLight.Range = m_fLast/2; // Reichweite
PointLight.Attenuation0 = 0.75f; // Lichtabschwächung
PointLight.Attenuation1 = 0.0f; // ...
PointLight.Attenuation2 = 0.0f; // ...
tbDirect3D::SetRS(D3DRS_AMBIENT, (DWORD)tbColor(1.0f, 1.0f, 1.0f));
tbVector2 vTranslation, vDirection, vNorm;
float fLenght;
float fTrans[]={1.0f,2.0f,3.0f,8.0f,-2.0f,-4.0f,-5.5f};
float fScale[]={1.0f,0.5f,0.25f,1.0f,5.0f,0.25f,0.25f};
int iSprite[]={0,1,0,3,2,0,3};
D3DXVECTOR3 vLightPos=PointLight.Position;
// ----------------------------------------
D3DXVec3Project(&vLightPos,
&vLightPos,
&m_vp,
(const D3DXMATRIX*)&m_mProjection,
(const D3DXMATRIX*)&m_mCamera,
(const D3DXMATRIX*)&tbMatrixIdentity());
vDirection=tbVector2(m_vScreenCenter.x-vLightPos.x,m_vScreenCenter.y-vLightPos.y);
fLenght=tbVector2Length(vDirection);
vNorm=tbVector2Normalize(vDirection);
for(int i=0; i<7;i++)
{
fLenght/=fTrans[i];
vNorm.x*=fLenght;
vNorm.y*=fLenght;
m_pSpriteEngine->AddSprite(iSprite[i], tbVector3(vNorm.x+m_vScreenCenter.x, vNorm.y+m_vScreenCenter.y, m_vCameraPos.z+0.5f), tbColor(1.0f), tbVector2(fScale[i]));
}
// Licht einsetzen und aktivieren
tbDirect3D::GetDevice()->SetLight(0, &PointLight);
tbDirect3D::GetDevice()->LightEnable(0, TRUE);
Thanks,
Chrissi
[edited by - chrissi on January 4, 2004 12:27:32 PM]