Light.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "Light.h"
  2. #include "collision.h"
  3. #include "LightProps.h"
  4. #include "App.h"
  5. #include "MainRenderer.h"
  6. //======================================================================================================================
  7. // init [PointLight] =
  8. //======================================================================================================================
  9. void PointLight::init(const char* filename)
  10. {
  11. lightProps.loadRsrc(filename);
  12. radius = lightProps->getRadius();
  13. }
  14. //======================================================================================================================
  15. // init [SpotLight] =
  16. //======================================================================================================================
  17. void SpotLight::init(const char* filename)
  18. {
  19. lightProps.loadRsrc(filename);
  20. camera.setAll(lightProps->getFovX(), lightProps->getFovY(), 0.2, lightProps->getDistance());
  21. castsShadow = lightProps->castsShadow();
  22. if(lightProps->getTexture() == NULL)
  23. {
  24. ERROR("Light properties \"" << lightProps->getRsrcName() << "\" do not have a texture");
  25. return;
  26. }
  27. }
  28. //======================================================================================================================
  29. // deinit =
  30. //======================================================================================================================
  31. void Light::deinit()
  32. {
  33. //RsrcMngr::lightProps.unload(lightProps);
  34. }
  35. //======================================================================================================================
  36. // render =
  37. //======================================================================================================================
  38. void Light::render()
  39. {
  40. Renderer::Dbg::drawSphere(0.1, getWorldTransform(), Vec4(lightProps->getDiffuseColor(), 1.0));
  41. //Renderer::Dbg::drawSphere(0.1, Transform::getIdentity(), Vec4(lightProps->getDiffuseColor(), 1.0));
  42. }