Light.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef LIGHT_H_
  2. #define LIGHT_H_
  3. #include "Object.h"
  4. namespace gameplay
  5. {
  6. class Light : public Object
  7. {
  8. public:
  9. static const int COLOR_SIZE = 3;
  10. /**
  11. * Constructor.
  12. */
  13. Light(void);
  14. /**
  15. * Destructor.
  16. */
  17. virtual ~Light(void);
  18. virtual unsigned int getTypeId(void) const;
  19. virtual const char* getElementName(void) const;
  20. virtual void writeBinary(FILE* file);
  21. virtual void writeText(FILE* file);
  22. float getRed() const;
  23. float getGreen() const;
  24. float getBlue() const;
  25. bool isAmbient() const;
  26. /**
  27. * Sets the light type to ambient.
  28. */
  29. void setAmbientLight();
  30. void setDirectionalLight();
  31. void setPointLight();
  32. void setSpotLight();
  33. void setColor(float r, float g, float b);
  34. void setColor(float r, float g, float b, float a);
  35. void setRange(float value);
  36. void setInnerAngle(float value);
  37. void setOuterAngle(float value);
  38. enum LightType
  39. {
  40. DirectionalLight = 1,
  41. PointLight = 2,
  42. SpotLight = 3,
  43. AmbientLight = 255
  44. };
  45. private:
  46. static float computeRange(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
  47. static float computeInnerAngle(float outerAngle);
  48. unsigned char _lightType;
  49. float _color[COLOR_SIZE];
  50. float _range;
  51. float _innerAngle;
  52. float _outerAngle;
  53. };
  54. }
  55. #endif