ReflectionProbe.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  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/collision/Frustum.h>
  8. #include <anki/collision/Sphere.h>
  9. #include <anki/Gr.h>
  10. namespace anki
  11. {
  12. /// @addtogroup scene
  13. /// @{
  14. /// Probe used in realtime reflections.
  15. class ReflectionProbe : public SceneNode
  16. {
  17. friend class ReflectionProbeMoveFeedbackComponent;
  18. public:
  19. const F32 FRUSTUM_NEAR_PLANE = 0.1 / 4.0;
  20. ReflectionProbe(SceneGraph* scene)
  21. : SceneNode(scene)
  22. {
  23. }
  24. ~ReflectionProbe();
  25. ANKI_USE_RESULT Error create(const CString& name, F32 radius);
  26. U getCubemapArrayIndex() const
  27. {
  28. ANKI_ASSERT(m_cubemapArrayIdx < 0xFF);
  29. return m_cubemapArrayIdx;
  30. }
  31. void setCubemapArrayIndex(U cubemapArrayIdx)
  32. {
  33. ANKI_ASSERT(cubemapArrayIdx < 0xFF);
  34. m_cubemapArrayIdx = cubemapArrayIdx;
  35. }
  36. ANKI_USE_RESULT Error frameUpdate(
  37. F32 prevUpdateTime, F32 crntTime) override;
  38. private:
  39. class CubeSide
  40. {
  41. public:
  42. PerspectiveFrustum m_frustum;
  43. Transform m_localTrf;
  44. };
  45. Array<CubeSide, 6> m_cubeSides;
  46. Sphere m_spatialSphere;
  47. U8 m_cubemapArrayIdx = 0xFF; ///< Used by the renderer
  48. void onMoveUpdate(MoveComponent& move);
  49. };
  50. /// @}
  51. } // end namespace anki