Light.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // render =
  30. //======================================================================================================================
  31. void Light::render()
  32. {
  33. app->getMainRenderer().dbg.drawSphere(0.1, getWorldTransform(), Vec4(lightProps->getDiffuseColor(), 1.0));
  34. //Dbg::drawSphere(0.1, Transform::getIdentity(), Vec4(lightProps->getDiffuseColor(), 1.0));
  35. }