Light.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. LIGHTING MODEL
  3. Final intensity: If = Ia + Id + Is
  4. Ambient intensity: Ia = Al * Am
  5. Ambient intensity of light: Al
  6. Ambient intensity of material: Am
  7. Defuse intensity: Id = Dl * Dm * LambertTerm
  8. Defuse intensity of light: Dl
  9. Defuse intensity of material: Dm
  10. LambertTerm: max(Normal dot Light, 0.0)
  11. Specular intensity: Is = Sm x Sl x pow(max(R dot E, 0.0), f)
  12. Specular intensity of light: Sl
  13. Specular intensity of material: Sm
  14. */
  15. #ifndef _LIGHT_H_
  16. #define _LIGHT_H_
  17. #include "Common.h"
  18. #include "Texture.h"
  19. #include "SceneNode.h"
  20. #include "Camera.h"
  21. class LightProps;
  22. /// Light scene node (Abstract)
  23. class Light: public SceneNode
  24. {
  25. public:
  26. enum Type { LT_POINT, LT_SPOT };
  27. Type type;
  28. LightProps* lightProps; ///< Later we will add a controller
  29. Light(Type type_): SceneNode(NT_LIGHT), type(type_) {}
  30. //void init(const char*);
  31. void deinit();
  32. void render();
  33. };
  34. /// PointLight scene node
  35. class PointLight: public Light
  36. {
  37. public:
  38. float radius;
  39. PointLight(): Light(LT_POINT) {}
  40. void init(const char*);
  41. };
  42. /// SpotLight scene node
  43. class SpotLight: public Light
  44. {
  45. public:
  46. Camera camera;
  47. bool castsShadow;
  48. SpotLight(): Light(LT_SPOT), castsShadow(false) { addChild(&camera); }
  49. float getDistance() const { return camera.getZFar(); }
  50. void setDistance(float d) { camera.setZFar(d); }
  51. void init(const char*);
  52. };
  53. #endif