]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/pointlight.h
Split the Light class into subclasses by light type
[libs/gl.git] / source / materials / pointlight.h
diff --git a/source/materials/pointlight.h b/source/materials/pointlight.h
new file mode 100644 (file)
index 0000000..074c8c3
--- /dev/null
@@ -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<PointLight, Light::Loader>
+       {
+       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