]> git.tdb.fi Git - libs/gl.git/blob - source/materials/directionallight.h
Split the Light class into subclasses by light type
[libs/gl.git] / source / materials / directionallight.h
1 #ifndef MSP_GL_DIRECTIONALLIGHT_H_
2 #define MSP_GL_DIRECTIONALLIGHT_H_
3
4 #include "light.h"
5 #include "vector.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 A light source which has uniform direction and strength everywhere.
12 */
13 class DirectionalLight: public Light
14 {
15 public:
16         class Loader: public DataFile::DerivedObjectLoader<DirectionalLight, Light::Loader>
17         {
18         private:
19                 static ActionMap shared_actions;
20
21         public:
22                 Loader(DirectionalLight &);
23
24         private:
25                 virtual void init_actions();
26
27                 void direction(float, float, float);
28         };
29
30 private:
31         Color transmittance;
32         Vector3 direction;
33
34 public:
35         DirectionalLight();
36
37 private:
38         void update_matrix();
39
40 public:
41         /** Sets the light's direction from a matrix.  The negative Z axis is used
42         as the direction.  Other axes and translation are ignored. */
43         virtual void set_matrix(const Matrix &);
44
45         void set_direction(const Vector3 &);
46
47         const Vector3 &get_direction() const { return direction; }
48
49         /** Sets a multiplier on how much light actually reaches the target.  Used
50         when modeling an atmosphere. */
51         void set_transmittance(const Color &);
52
53 protected:
54         virtual void update_shader_data(ProgramData &, const std::string &) const;
55 };
56
57 } // namespace GL
58 } // namespace Msp
59
60 #endif