light.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. {
  22. float orbX = std::sin(ang) * radius;
  23. float orbZ = std::cos(ang) * radius;
  24. position.x = orbZ;
  25. position.y = orbX;
  26. position.z = orbX;
  27. }
  28. break;
  29. case 'f':
  30. break;
  31. case 'c':
  32. {
  33. float colX = (std::sin(ang/12e3) + 1)/2.0f ;
  34. float colY = (std::cos(ang/6e3) + 1)/2.0f ;
  35. color.x = colX;
  36. color.y = 1.0f-colY;
  37. color.z = colY;
  38. }
  39. break;
  40. case 'l':
  41. {
  42. float linX = std::sin(ang) * radius ;
  43. position.x = linX;
  44. }
  45. break;
  46. default:
  47. break;
  48. }
  49. }
  50. };
  51. #endif