X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Fpointlight.h;fp=source%2Fmaterials%2Fpointlight.h;h=074c8c37b61d208cdd76cf9a97a59bfa8b47c9b7;hp=0000000000000000000000000000000000000000;hb=adc26a2e141a2853b6c5025130c46a46cece4b84;hpb=e6e6f0fe81a2f92985e65ae0de708974194d81a3 diff --git a/source/materials/pointlight.h b/source/materials/pointlight.h new file mode 100644 index 00000000..074c8c37 --- /dev/null +++ b/source/materials/pointlight.h @@ -0,0 +1,60 @@ +#ifndef MSP_GL_POINTLIGHT_H_ +#define MSP_GL_POINTLIGHT_H_ + +#include "light.h" +#include "vector.h" + +namespace Msp { +namespace GL { + +/** +A positional, omnidirectional light source. The light's strength can be +attenuated based on distance. +*/ +class PointLight: public Light +{ +public: + class Loader: public DataFile::DerivedObjectLoader + { + private: + static ActionMap shared_actions; + + public: + Loader(PointLight &); + + private: + virtual void init_actions(); + + void attenuation(float, float, float); + void position(float, float, float); + }; + +private: + Vector3 position; + float attenuation[3]; + +public: + PointLight(); + +private: + void update_matrix(); + +public: + /** Sets the light's position from a matrix. Only the translation part is + used. */ + virtual void set_matrix(const Matrix &); + + void set_position(const Vector3 &); + const Vector3 &get_position(); + + void set_attenuation(float, float, float); + const float *get_attenuation() const { return attenuation; } + +protected: + virtual void update_shader_data(ProgramData &, const std::string &) const; +}; + +} // namespace GL +} // namespace Msp + +#endif