Spot light angle fix

dev-ui
Piotr Dziwinski 2012-10-03 00:29:59 +02:00
parent 3f7f013168
commit 858b1e35ae
5 changed files with 7 additions and 8 deletions

View File

@ -68,7 +68,7 @@ struct Light
float attenuation1;
//! Quadratic attenuation factor
float attenuation2;
//! Angle of spotlight cone (0-90 degrees)
//! Angle of spotlight cone (0-PI/2 radians)
float spotAngle;
//! Intensity of spotlight (0 = uniform; 128 = most intense)
@ -91,7 +91,7 @@ struct Light
direction = Math::Vector(0.0f, 0.0f, 1.0f);
attenuation0 = 1.0f;
attenuation1 = attenuation2 = 0.0f;
spotAngle = 90.0f;
spotAngle = Math::PI/2.0f;
spotIntensity = 0.0f;
}
};

View File

@ -305,7 +305,7 @@ void CGLDevice::SetLight(int index, const Light &light)
if (light.type == LIGHT_SPOT)
{
glLightf(GL_LIGHT0 + index, GL_SPOT_CUTOFF, light.spotAngle);
glLightf(GL_LIGHT0 + index, GL_SPOT_CUTOFF, light.spotAngle * Math::RAD_TO_DEG);
glLightf(GL_LIGHT0 + index, GL_SPOT_EXPONENT, light.spotIntensity);
}
else

View File

@ -2264,7 +2264,7 @@ bool CObject::CreateShadowLight(float height, Gfx::Color color)
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
light.spotAngle = 90;
light.spotAngle = 90.0f*Math::PI/180.0f;
m_shadowLight = m_lightMan->CreateLight();
if ( m_shadowLight == -1 ) return false;
@ -2307,7 +2307,7 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color)
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
light.spotAngle = 90;
light.spotAngle = 90.0f*Math::PI/180.0f;
m_effectLight = m_lightMan->CreateLight();
if ( m_effectLight == -1 ) return false;

View File

@ -153,8 +153,7 @@ void CTaskBuild::CreateLight()
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
//TODO Is this value correct
light.spotAngle = 90;
light.spotAngle = 90.0f*Math::PI/180.0f;
m_lightMan->SetLight(m_lightRank[i], light);
color.r = -1.0f;

View File

@ -499,7 +499,7 @@ bool CTaskShield::CreateLight(Math::Vector pos)
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
light.spotAngle = 90;
light.spotAngle = 90.0f*Math::PI/180.0f;
m_effectLight = m_lightMan->CreateLight();
if ( m_effectLight == -1 ) return false;