]> git.tdb.fi Git - libs/gl.git/blob - source/materials/directionallight.h
Use default member initializers for simple types
[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 = { 1.0f };
32         Vector3 direction = { 0.0f, 0.0f, -1.0f };
33
34         void update_matrix();
35
36 public:
37         /** Sets the light's direction from a matrix.  The negative Z axis is used
38         as the direction.  Other axes and translation are ignored. */
39         virtual void set_matrix(const Matrix &);
40
41         void set_direction(const Vector3 &);
42
43         const Vector3 &get_direction() const { return direction; }
44
45         /** Sets a multiplier on how much light actually reaches the target.  Used
46         when modeling an atmosphere. */
47         void set_transmittance(const Color &);
48
49 protected:
50         virtual void update_shader_data(ProgramData &, const std::string &) const;
51 };
52
53 } // namespace GL
54 } // namespace Msp
55
56 #endif