summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-10-03 00:29:59 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-10-03 00:29:59 +0200
commit858b1e35aed8b3a37f138138910327f7259d1251 (patch)
treef9dee07965757f7e2778965e47764c29e298b432 /src
parent3f7f013168e62693601ab57108d329ffaa924439 (diff)
downloadcolobot-858b1e35aed8b3a37f138138910327f7259d1251.tar.gz
colobot-858b1e35aed8b3a37f138138910327f7259d1251.tar.bz2
colobot-858b1e35aed8b3a37f138138910327f7259d1251.zip
Spot light angle fix
Diffstat (limited to 'src')
-rw-r--r--src/graphics/core/light.h4
-rw-r--r--src/graphics/opengl/gldevice.cpp2
-rw-r--r--src/object/object.cpp4
-rw-r--r--src/object/task/taskbuild.cpp3
-rw-r--r--src/object/task/taskshield.cpp2
5 files changed, 7 insertions, 8 deletions
diff --git a/src/graphics/core/light.h b/src/graphics/core/light.h
index 35f37e6..28733c1 100644
--- a/src/graphics/core/light.h
+++ b/src/graphics/core/light.h
@@ -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;
}
};
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index dbf91c7..7bfd843 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -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
diff --git a/src/object/object.cpp b/src/object/object.cpp
index ec8b3c5..77a7c25 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -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;
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index 469e9cb..d82874c 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -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;
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index 682bcb1..93afd62 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -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;