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