dungeon_crawler

view prototype/src/light.h @ 38:862461b686f4

start work on particle systems
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 29 Aug 2012 03:22:36 +0300
parents fa8f89d06f6f
children f3030df27110
line source
1 #ifndef LIGHT_H_
2 #define LIGHT_H_
4 #include "color.h"
6 class Light {
7 protected:
8 float intensity;
9 Color color;
11 float flicker_offset;
13 // VBO for rendering the light source
14 unsigned int vbo;
15 unsigned int num_faces;
17 virtual bool create_mesh();
19 public:
20 Light(const Color &col = 1.0);
21 virtual ~Light();
23 virtual void set_intensity(float val);
24 virtual void set_color(const Color &col);
26 virtual Color get_color(bool with_intensity = true) const;
28 virtual void use(int id = 0) const;
30 virtual void draw() const;
31 };
33 class PointLight : public Light {
34 protected:
35 Vector3 pos;
36 float atten[3];
37 float radius;
39 bool create_mesh();
41 public:
42 PointLight();
43 PointLight(const Vector3 &pos, const Color &col = 1.0);
45 void set_position(const Vector3 &pos);
46 void set_attenuation(float att_const, float att_lin, float att_quad);
48 void set_radius(float rad);
49 float get_radius() const;
51 virtual void use(int id = 0) const;
53 virtual void draw() const;
54 };
56 class DirLight : public Light {
57 protected:
58 Vector3 dir;
60 bool create_mesh();
62 public:
63 DirLight();
64 DirLight(const Vector3 &dir, const Color &col = 1.0);
66 void set_direction(const Vector3 &dir);
68 virtual void use(int id = 0) const;
69 };
72 void set_light(int id, const Light *lt);
75 #endif // LIGHT_H_