forked from mirrors/0ad
* clean up CLightEnv a bit
* add CLightEnv::m_TerrainShadowTransparency * shadows will let a fraction of diffuse light through * added JS LightEnv objects, so the lighting environment can be changed from the console * new element TerrainShadowTransparency supported in the scenario .xml format, changed cantabrian_generated with an example This was SVN commit r3513.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* =========================================================================
|
||||
* File : LightEnv.cpp
|
||||
* Project : Pyrogenesis
|
||||
* Description : CLightEnv implementation
|
||||
*
|
||||
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
|
||||
* =========================================================================
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "maths/MathUtil.h"
|
||||
|
||||
#include "graphics/LightEnv.h"
|
||||
|
||||
|
||||
CLightEnv::CLightEnv()
|
||||
: m_Elevation(DEGTORAD(45)),
|
||||
m_Rotation(DEGTORAD(270)),
|
||||
m_TerrainShadowTransparency(0.0),
|
||||
m_SunColor(1,1,1),
|
||||
m_TerrainAmbientColor(0.4f,0.4f,0.4f),
|
||||
m_UnitsAmbientColor(0.4f,0.4f,0.4f)
|
||||
{
|
||||
CalculateSunDirection();
|
||||
}
|
||||
|
||||
void CLightEnv::SetElevation(float f)
|
||||
{
|
||||
m_Elevation = f;
|
||||
CalculateSunDirection();
|
||||
}
|
||||
|
||||
void CLightEnv::SetRotation(float f)
|
||||
{
|
||||
m_Rotation = f;
|
||||
CalculateSunDirection();
|
||||
}
|
||||
|
||||
void CLightEnv::SetTerrainShadowTransparency(float f)
|
||||
{
|
||||
m_TerrainShadowTransparency = f;
|
||||
}
|
||||
|
||||
void CLightEnv::CalculateSunDirection()
|
||||
{
|
||||
m_SunDir.Y=-float(sin(m_Elevation));
|
||||
float scale=1+m_SunDir.Y;
|
||||
m_SunDir.X=scale*float(sin(m_Rotation));
|
||||
m_SunDir.Z=scale*float(cos(m_Rotation));
|
||||
m_SunDir.Normalize();
|
||||
}
|
||||
Reference in New Issue
Block a user