dungeon_crawler
diff prototype/src/light.h @ 4:158de53b4e18
tile work
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 11 Aug 2012 05:44:52 +0300 |
parents | |
children | 0588f8a1a351 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/prototype/src/light.h Sat Aug 11 05:44:52 2012 +0300 1.3 @@ -0,0 +1,53 @@ 1.4 +#ifndef LIGHT_H_ 1.5 +#define LIGHT_H_ 1.6 + 1.7 +#include "color.h" 1.8 + 1.9 +class Light { 1.10 +protected: 1.11 + float intensity; 1.12 + Color color; 1.13 + 1.14 +public: 1.15 + Light(const Color &col = 1.0); 1.16 + virtual ~Light(); 1.17 + 1.18 + virtual void set_intensity(float val); 1.19 + virtual void set_color(const Color &col); 1.20 + 1.21 + virtual void use(int id = 0) const; 1.22 +}; 1.23 + 1.24 +class PointLight : public Light { 1.25 +protected: 1.26 + Vector3 pos; 1.27 + float atten[3]; 1.28 + 1.29 +public: 1.30 + PointLight(); 1.31 + PointLight(const Vector3 &pos, const Color &col = 1.0); 1.32 + 1.33 + void set_position(const Vector3 &pos); 1.34 + void set_attenuation(float att_const, float att_lin, float att_quad); 1.35 + 1.36 + virtual void use(int id = 0) const; 1.37 +}; 1.38 + 1.39 +class DirLight : public Light { 1.40 +protected: 1.41 + Vector3 dir; 1.42 + 1.43 +public: 1.44 + DirLight(); 1.45 + DirLight(const Vector3 &dir, const Color &col = 1.0); 1.46 + 1.47 + void set_direction(const Vector3 &dir); 1.48 + 1.49 + virtual void use(int id = 0) const; 1.50 +}; 1.51 + 1.52 + 1.53 +void set_light(int id, const Light *lt); 1.54 + 1.55 + 1.56 +#endif // LIGHT_H_