1 #ifndef MSP_GL_LIGHTING_H_
2 #define MSP_GL_LIGHTING_H_
5 #include <msp/geometry/angle.h>
8 #include "programdata.h"
16 Encapsulates global lighting parameters and any number of individual light
22 class Loader: public DataFile::CollectionObjectLoader<Lighting>
25 static ActionMap shared_actions;
29 Loader(Lighting &, Collection &);
32 virtual void init_actions();
34 void ambient(float, float, float);
35 void fog_color(float, float, float);
36 void fog_density(float);
37 void fog_half_distance(float);
38 void horizon_angle(float);
39 void light(const std::string &);
41 void light_inline_index(unsigned);
42 void sky_color(float, float, float);
43 void zenith_direction(float, float, float);
49 Vector3 zenith_direction;
50 Geometry::Angle<float> horizon_angle;
53 std::vector<const Light *> lights;
54 std::vector<Light *> owned_data;
60 /** Sets the ambient lighting color. Affects all surfaces in the scene. */
61 void set_ambient(const Color &);
63 const Color &get_ambient() const { return ambient; }
65 /** Sets the color of the sky at zenith. Has no effect without shaders. */
66 void set_sky_color(const Color &);
68 /** Sets the direction of the zenith. Defaults to positive Z axis. Has no
69 effect without shaders. */
70 void set_zenith_direction(const Vector3 &);
72 /** Sets the angle where skylight cuts off, counted from the true horizon.
73 Has no effect without shaders. */
74 void set_horizon_angle(const Geometry::Angle<float> &);
76 /** Sets the fog color, which is blended into distant surfaces. */
77 void set_fog_color(const Color &);
79 /** Sets the density of the fog. Zero means no fog. */
80 void set_fog_density(float);
82 /** Sets the density of the fog so that the blending factor at the given
84 void set_fog_half_distance(float);
86 /** Attaches a light source. If the light was already attached, does
88 void attach(const Light &);
90 /** Detaches a light source. If the light was not attached, does nothing. */
91 void detach(const Light &);
93 DEPRECATED void attach(unsigned, const Light &l) { attach(l); }
94 DEPRECATED void detach(unsigned);
96 /** Returns an attached light. If no light is attached at that index, null
98 DEPRECATED const Light *get_attached_light(unsigned) const;
100 const std::vector<const Light *> &get_attached_lights() const { return lights; }
102 /** Updates a ProgramData object with the uniforms for the Lighting,
103 including all attached light sources. A view matrix must be passed in. */
104 void update_shader_data(ProgramData &, const Matrix &) const;