Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LightEnv.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2012 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * CLightEnv implementation
20  */
21 
22 #include "precompiled.h"
23 
24 #include "maths/MathUtil.h"
25 
26 #include "graphics/LightEnv.h"
27 
28 
30  : m_Elevation(DEGTORAD(45)),
31  m_Rotation(DEGTORAD(315)),
32  m_LightingModel("standard"),
33  m_SunColor(1.5, 1.5, 1.5),
34  m_TerrainAmbientColor(0x50/255.f, 0x60/255.f, 0x85/255.f),
35  m_UnitsAmbientColor(0x80/255.f, 0x80/255.f, 0x80/255.f),
36  m_FogColor(0xCC/255.f, 0xCC/255.f, 0xE5/255.f),
37  m_FogFactor(0.000f),
38  m_FogMax(0.5f),
39  m_Brightness(0.0f), m_Contrast(1.0f), m_Saturation(0.99f), m_Bloom(0.1999f)
40 {
42 }
43 
45 {
46  m_Elevation = f;
48 }
49 
51 {
52  m_Rotation = f;
54 }
55 
57 {
58  m_SunDir.Y = -sinf(m_Elevation);
59  float scale = 1 + m_SunDir.Y;
60  m_SunDir.X = scale * sinf(m_Rotation);
61  m_SunDir.Z = scale * cosf(m_Rotation);
63 }
void CalculateSunDirection()
Definition: LightEnv.cpp:56
void Normalize()
Definition: Vector3D.cpp:77
void SetElevation(float f)
Definition: LightEnv.cpp:44
float m_Elevation
Height of sun above the horizon, in radians.
Definition: LightEnv.h:46
float X
Definition: Vector3D.h:31
float m_Rotation
Direction of sun on the compass, in radians.
Definition: LightEnv.h:54
float Y
Definition: Vector3D.h:31
void SetRotation(float f)
Definition: LightEnv.cpp:50
float Z
Definition: Vector3D.h:31
#define DEGTORAD(a)
Definition: MathUtil.h:21
CVector3D m_SunDir
Vector corresponding to m_Elevation and m_Rotation.
Definition: LightEnv.h:60