1
0
forked from 0ad/0ad
0ad/source/graphics/LightEnv.cpp
prefect 36fa5ec2bf * 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.
2006-02-15 00:45:16 +00:00

54 lines
1.1 KiB
C++

/**
* =========================================================================
* 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();
}