nuclear@4: #ifndef LIGHT_H_ nuclear@4: #define LIGHT_H_ nuclear@4: nuclear@4: #include "color.h" nuclear@4: nuclear@4: class Light { nuclear@4: protected: nuclear@4: float intensity; nuclear@4: Color color; nuclear@4: nuclear@23: // VBO for rendering the light source nuclear@23: unsigned int vbo; nuclear@23: unsigned int num_faces; nuclear@23: nuclear@23: virtual bool create_mesh(); nuclear@23: nuclear@4: public: nuclear@4: Light(const Color &col = 1.0); nuclear@4: virtual ~Light(); nuclear@4: nuclear@4: virtual void set_intensity(float val); nuclear@4: virtual void set_color(const Color &col); nuclear@4: nuclear@21: virtual Color get_color(bool with_intensity = true) const; nuclear@21: nuclear@4: virtual void use(int id = 0) const; nuclear@23: nuclear@23: virtual void draw() const; nuclear@4: }; nuclear@4: nuclear@4: class PointLight : public Light { nuclear@4: protected: nuclear@4: Vector3 pos; nuclear@4: float atten[3]; nuclear@21: float radius; nuclear@4: nuclear@23: bool create_mesh(); nuclear@23: nuclear@4: public: nuclear@4: PointLight(); nuclear@4: PointLight(const Vector3 &pos, const Color &col = 1.0); nuclear@4: nuclear@4: void set_position(const Vector3 &pos); nuclear@4: void set_attenuation(float att_const, float att_lin, float att_quad); nuclear@4: nuclear@21: void set_radius(float rad); nuclear@21: float get_radius() const; nuclear@21: nuclear@4: virtual void use(int id = 0) const; nuclear@23: nuclear@23: virtual void draw() const; nuclear@4: }; nuclear@4: nuclear@4: class DirLight : public Light { nuclear@4: protected: nuclear@4: Vector3 dir; nuclear@4: nuclear@23: bool create_mesh(); nuclear@23: nuclear@4: public: nuclear@4: DirLight(); nuclear@4: DirLight(const Vector3 &dir, const Color &col = 1.0); nuclear@4: nuclear@4: void set_direction(const Vector3 &dir); nuclear@4: nuclear@4: virtual void use(int id = 0) const; nuclear@4: }; nuclear@4: nuclear@4: nuclear@4: void set_light(int id, const Light *lt); nuclear@4: nuclear@4: nuclear@4: #endif // LIGHT_H_