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);
50 mutable unsigned generation;
52 AttachedLight(const Light *l): light(l), generation(0) { }
57 Vector3 zenith_direction;
58 Geometry::Angle<float> horizon_angle;
61 std::vector<AttachedLight> lights;
62 mutable ProgramData shdata;
67 /** Sets the ambient lighting color. Affects all surfaces in the scene. */
68 void set_ambient(const Color &);
70 const Color &get_ambient() const { return ambient; }
72 /** Sets the color of the sky at zenith. Has no effect without shaders. */
73 DEPRECATED void set_sky_color(const Color &);
75 /** Sets the direction of the zenith. Defaults to positive Z axis. Has no
76 effect without shaders. */
77 DEPRECATED void set_zenith_direction(const Vector3 &);
79 /** Sets the angle where skylight cuts off, counted from the true horizon.
80 Has no effect without shaders. */
81 DEPRECATED void set_horizon_angle(const Geometry::Angle<float> &);
83 /** Sets the fog color, which is blended into distant surfaces. */
84 void set_fog_color(const Color &);
86 /** Sets the density of the fog. Zero means no fog. */
87 void set_fog_density(float);
89 /** Sets the density of the fog so that the blending factor at the given
91 void set_fog_half_distance(float);
93 /** Attaches a light source. If the light was already attached, does
95 void attach(const Light &);
97 /** Detaches a light source. If the light was not attached, does nothing. */
98 void detach(const Light &);
100 DEPRECATED void attach(unsigned, const Light &l) { attach(l); }
101 DEPRECATED void detach(unsigned);
103 /** Returns an attached light. If no light is attached at that index, null
105 DEPRECATED const Light *get_attached_light(unsigned) const;
107 /** Updates a ProgramData object with the uniforms for the Lighting,
108 including all attached light sources. A view matrix must be passed in. */
109 DEPRECATED void update_shader_data(ProgramData &, const Matrix &) const;
111 const ProgramData &get_shader_data() const;
113 void set_debug_name(const std::string &);