light.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 = orbX;
  24. position.y = orbX;
  25. position.z = orbZ;
  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. printf("%f\n",ang);
  36. color.print();
  37. break;
  38. case 'l':
  39. float linX = std::sin(ang) * radius ;
  40. position.x = linX;
  41. break;
  42. default:
  43. break;
  44. }
  45. }
  46. };
  47. #endif