You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 line
1.1 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstring>
  14. #include <cstdlib>
  15. #include "core.h"
  16. namespace lol
  17. {
  18. Light::Light()
  19. : m_color(1.f),
  20. m_directional(true)
  21. {
  22. m_gamegroup = GAMEGROUP_BEFORE;
  23. m_drawgroup = DRAWGROUP_CAMERA;
  24. SetPosition(vec4(0.f));
  25. }
  26. Light::~Light()
  27. {
  28. }
  29. void Light::SetPosition(vec4 const &pos)
  30. {
  31. m_directional = (pos.w > 0.f);
  32. m_position = pos.xyz;
  33. }
  34. vec4 Light::GetPosition()
  35. {
  36. return vec4(m_position, m_directional ? 1.f : 0.f);
  37. }
  38. void Light::SetColor(vec4 const &color)
  39. {
  40. m_color = color;
  41. }
  42. vec4 Light::GetColor()
  43. {
  44. return m_color;
  45. }
  46. void Light::TickGame(float seconds)
  47. {
  48. WorldEntity::TickGame(seconds);
  49. }
  50. void Light::TickDraw(float seconds)
  51. {
  52. WorldEntity::TickDraw(seconds);
  53. Scene::GetDefault()->AddLight(this);
  54. }
  55. } /* namespace lol */