X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Fdirectionallight.h;fp=source%2Fmaterials%2Fdirectionallight.h;h=8bde91cb2c94bb53947c9a9b0523ca9810088d3c;hb=adc26a2e141a2853b6c5025130c46a46cece4b84;hp=0000000000000000000000000000000000000000;hpb=e6e6f0fe81a2f92985e65ae0de708974194d81a3;p=libs%2Fgl.git diff --git a/source/materials/directionallight.h b/source/materials/directionallight.h new file mode 100644 index 00000000..8bde91cb --- /dev/null +++ b/source/materials/directionallight.h @@ -0,0 +1,60 @@ +#ifndef MSP_GL_DIRECTIONALLIGHT_H_ +#define MSP_GL_DIRECTIONALLIGHT_H_ + +#include "light.h" +#include "vector.h" + +namespace Msp { +namespace GL { + +/** +A light source which has uniform direction and strength everywhere. +*/ +class DirectionalLight: public Light +{ +public: + class Loader: public DataFile::DerivedObjectLoader + { + private: + static ActionMap shared_actions; + + public: + Loader(DirectionalLight &); + + private: + virtual void init_actions(); + + void direction(float, float, float); + }; + +private: + Color transmittance; + Vector3 direction; + +public: + DirectionalLight(); + +private: + void update_matrix(); + +public: + /** Sets the light's direction from a matrix. The negative Z axis is used + as the direction. Other axes and translation are ignored. */ + virtual void set_matrix(const Matrix &); + + void set_direction(const Vector3 &); + + const Vector3 &get_direction() const { return direction; } + + /** Sets a multiplier on how much light actually reaches the target. Used + when modeling an atmosphere. */ + void set_transmittance(const Color &); + +protected: + virtual void update_shader_data(ProgramData &, const std::string &) const; +}; + +} // namespace GL +} // namespace Msp + +#endif