1
0
forked from 0ad/0ad
0ad/source/graphics/LightEnv.cpp
Ykkrosh f45c44ca09 Rotated various things (terrain texture UVs, default light and camera angles) by 45 degrees.
Map XML: Store camera position. Stopped using DTDs (because they make it
too hard to change the XML structure without breaking all the old XML
files).
Game.h: Include fewer files, to make compilation sometimes faster.
World: Changed some things to not be singletons, since they were
(ab)used as CWorld members.

This was SVN commit r3670.
2006-03-21 20:55:45 +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(315)),
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();
}