LightNode.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /// @addtogroup scene
  10. /// @{
  11. /// Light scene node. It can be spot or point.
  12. class LightNode : public SceneNode
  13. {
  14. public:
  15. LightNode(SceneGraph* scene, CString name);
  16. ~LightNode();
  17. protected:
  18. class OnMovedFeedbackComponent;
  19. class OnLightShapeUpdatedFeedbackComponent;
  20. /// Called when moved
  21. void onMoveUpdateCommon(const MoveComponent& move);
  22. void frameUpdateCommon();
  23. virtual void onMoved(const MoveComponent& move) = 0;
  24. virtual void onLightShapeUpdated(LightComponent& light) = 0;
  25. };
  26. /// Point light
  27. class PointLightNode : public LightNode
  28. {
  29. public:
  30. PointLightNode(SceneGraph* scene, CString name);
  31. ~PointLightNode();
  32. ANKI_USE_RESULT Error frameUpdate(Second prevUpdateTime, Second crntTime) override;
  33. private:
  34. class ShadowCombo
  35. {
  36. public:
  37. Transform m_localTrf = Transform::getIdentity();
  38. };
  39. DynamicArray<ShadowCombo> m_shadowData;
  40. void onMoved(const MoveComponent& move) override;
  41. void onLightShapeUpdated(LightComponent& light) override;
  42. };
  43. /// Spot light
  44. class SpotLightNode : public LightNode
  45. {
  46. public:
  47. SpotLightNode(SceneGraph* scene, CString name);
  48. ANKI_USE_RESULT Error frameUpdate(Second prevUpdateTime, Second crntTime) override;
  49. private:
  50. class OnFrustumUpdatedFeedbackComponent;
  51. void onMoved(const MoveComponent& move) override;
  52. void onLightShapeUpdated(LightComponent& light) override;
  53. void onFrustumUpdated(FrustumComponent& frc);
  54. };
  55. /// Directional light (the sun).
  56. class DirectionalLightNode : public SceneNode
  57. {
  58. public:
  59. DirectionalLightNode(SceneGraph* scene, CString name);
  60. private:
  61. class FeedbackComponent;
  62. static void drawCallback(RenderQueueDrawContext& ctx, ConstWeakArray<void*> userData)
  63. {
  64. // TODO
  65. }
  66. };
  67. /// @}
  68. } // end namespace anki