Light.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "anki/scene/Light.h"
  2. #include "anki/resource/LightRsrc.h"
  3. namespace anki {
  4. //==============================================================================
  5. // Light =
  6. //==============================================================================
  7. //==============================================================================
  8. Light::Light(LightType t, const char* fmtl, // Light
  9. const char* name, Scene* scene, // Scene
  10. uint movableFlags, Movable* movParent, // Movable
  11. CollisionShape* cs) // Spatial
  12. : SceneNode(name, scene),
  13. Movable(movableFlags, movParent, *this),
  14. Spatial(cs), type(t)
  15. {
  16. mtl.load(fmtl);
  17. Renderable::init(*this);
  18. }
  19. //==============================================================================
  20. Light::~Light()
  21. {}
  22. //==============================================================================
  23. // PointLight =
  24. //==============================================================================
  25. //==============================================================================
  26. PointLight::PointLight(const char* fmtl,
  27. const char* name, Scene* scene,
  28. uint movableFlags, Movable* movParent)
  29. : Light(LT_POINT, fmtl, name, scene, movableFlags, movParent, &sphereW)
  30. {
  31. PropertyBase& pbase = findPropertyBaseByName("radius");
  32. Property<float>& prop = pbase.upCast<Property<float> >();
  33. ANKI_CONNECT(&prop, valueChanged, this, updateRadius);
  34. sphereL.setCenter(Vec3(0.0));
  35. sphereL.setRadius(prop.getValue());
  36. }
  37. //==============================================================================
  38. // SpotLight =
  39. //==============================================================================
  40. //==============================================================================
  41. SpotLight::SpotLight(const char* fmtl,
  42. const char* name, Scene* scene,
  43. uint movableFlags, Movable* movParent)
  44. : Light(LT_SPOT, fmtl, name, scene, movableFlags, movParent, &frustum),
  45. Frustumable(&frustum)
  46. {}
  47. } // end namespace