LightNode.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Scene/SceneNode.h>
  7. #include <AnKi/Scene/Components/LightComponent.h>
  8. namespace anki
  9. {
  10. /// @addtogroup scene
  11. /// @{
  12. /// Light scene node. It can be spot or point.
  13. class LightNode : public SceneNode
  14. {
  15. public:
  16. LightNode(SceneGraph* scene, CString name);
  17. ~LightNode();
  18. protected:
  19. class OnMovedFeedbackComponent;
  20. class OnLightShapeUpdatedFeedbackComponent;
  21. /// Called when moved
  22. void onMoveUpdateCommon(const MoveComponent& move);
  23. void frameUpdateCommon();
  24. virtual void onMoved(const MoveComponent& move) = 0;
  25. virtual void onLightShapeUpdated(LightComponent& light) = 0;
  26. };
  27. /// Point light
  28. class PointLightNode : public LightNode
  29. {
  30. public:
  31. PointLightNode(SceneGraph* scene, CString name);
  32. ~PointLightNode();
  33. ANKI_USE_RESULT Error frameUpdate(Second prevUpdateTime, Second crntTime) override;
  34. private:
  35. class ShadowCombo
  36. {
  37. public:
  38. Transform m_localTrf = Transform::getIdentity();
  39. };
  40. DynamicArray<ShadowCombo> m_shadowData;
  41. void onMoved(const MoveComponent& move) override;
  42. void onLightShapeUpdated(LightComponent& light) override;
  43. };
  44. /// Spot light
  45. class SpotLightNode : public LightNode
  46. {
  47. public:
  48. SpotLightNode(SceneGraph* scene, CString name);
  49. ANKI_USE_RESULT Error frameUpdate(Second prevUpdateTime, Second crntTime) override;
  50. private:
  51. class OnFrustumUpdatedFeedbackComponent;
  52. void onMoved(const MoveComponent& move) override;
  53. void onLightShapeUpdated(LightComponent& light) override;
  54. void onFrustumUpdated(FrustumComponent& frc);
  55. };
  56. /// Directional light (the sun).
  57. class DirectionalLightNode : public SceneNode
  58. {
  59. public:
  60. DirectionalLightNode(SceneGraph* scene, CString name);
  61. private:
  62. class FeedbackComponent;
  63. static void drawCallback(RenderQueueDrawContext& ctx, ConstWeakArray<void*> userData)
  64. {
  65. // TODO
  66. }
  67. };
  68. /// @}
  69. } // end namespace anki