light.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef LIGHT_H
  2. #define LIGHT_H
  3. // ===============================
  4. // AUTHOR : Angel Ortiz (angelo12 AT vt DOT edu)
  5. // CREATE DATE : 2018-08-03
  6. // PURPOSE : POD struct containing the two vectors that describe a lightsource
  7. // ===============================
  8. #include "vector3D.h"
  9. struct BaseLight{
  10. Vector3f position;
  11. Vector3f color;
  12. float radius;
  13. char type;
  14. float time = 2 * M_PI ;
  15. unsigned int totalTime;
  16. void update(unsigned int deltaT){
  17. totalTime += deltaT;
  18. float ang = static_cast<float>(totalTime) * time;
  19. switch(type){
  20. case 'o':
  21. float orbX = std::sin(ang) * radius;
  22. float orbZ = std::cos(ang) * radius;
  23. position.x = orbZ;
  24. position.y = orbX;
  25. position.z = orbX;
  26. break;
  27. case 'f':
  28. break;
  29. case 'c':
  30. float colX = (std::sin(ang/12e3) + 1)/2.0f ;
  31. float colY = (std::cos(ang/6e3) + 1)/2.0f ;
  32. color.x = colX;
  33. color.y = 1.0f-colY;
  34. color.z = colY;
  35. break;
  36. case 'l':
  37. float linX = std::sin(ang) * radius ;
  38. position.x = linX;
  39. break;
  40. default:
  41. break;
  42. }
  43. }
  44. };
  45. #endif