BsCLight.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsLight.h"
  6. #include "BsComponent.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Components
  10. * @{
  11. */
  12. /**
  13. * @copydoc Light
  14. *
  15. * Wraps Light as a Component.
  16. */
  17. class BS_CORE_EXPORT CLight : public Component
  18. {
  19. public:
  20. CLight(const HSceneObject& parent, LightType type = LightType::Point, Color color = Color::White,
  21. float intensity = 100.0f, float range = 1.0f, bool castsShadows = false, Degree spotAngle = Degree(45),
  22. Degree spotFalloffAngle = Degree(40));
  23. virtual ~CLight();
  24. /** @copydoc Light::getType */
  25. LightType getType() const { return mInternal->getType(); }
  26. /** @copydoc Light::setType */
  27. void setType(LightType type) { mInternal->setType(type); }
  28. /** @copydoc Light::getCastsShadow */
  29. bool getCastsShadow() const { return mInternal->getCastsShadow(); }
  30. /** @copydoc Light::setCastsShadow */
  31. void setCastsShadow(bool castsShadow) { mInternal->setCastsShadow(castsShadow); }
  32. /** @copydoc Light::getColor */
  33. Color getColor() const { return mInternal->getColor(); }
  34. /** @copydoc Light::setColor */
  35. void setColor(const Color& color) { mInternal->setColor(color); }
  36. /** @copydoc Light::getRange */
  37. float getRange() const { return mInternal->getRange(); }
  38. /** @copydoc Light::setRange */
  39. void setRange(float range) { mInternal->setRange(range);; }
  40. /** @copydoc Light::getIntensity */
  41. float getIntensity() const { return mInternal->getIntensity(); }
  42. /** @copydoc Light::setIntensity */
  43. void setIntensity(float intensity) { mInternal->setIntensity(intensity); }
  44. /** @copydoc Light::getSpotAngle */
  45. Degree getSpotAngle() const { return mInternal->getSpotAngle(); }
  46. /** @copydoc Light::setSpotAngle */
  47. void setSpotAngle(const Degree& spotAngle) { mInternal->setSpotAngle(spotAngle); }
  48. /** @copydoc Light::getSpotFalloffAngle */
  49. Degree getSpotFalloffAngle() const { return mInternal->getSpotFalloffAngle(); }
  50. /** @copydoc Light::setSpotFalloffAngle */
  51. void setSpotFalloffAngle(const Degree& spotAngle) { mInternal->setSpotFalloffAngle(spotAngle); }
  52. /** @copydoc Light::getPhysicallyBasedAttenuation */
  53. bool getPhysicallyBasedAttenuation() const { return mInternal->getPhysicallyBasedAttenuation(); }
  54. /** @copydoc Light::setPhysicallyBasedAttenuation */
  55. void setPhysicallyBasedAttenuation(bool enabled) { mInternal->setPhysicallyBasedAttenuation(enabled); }
  56. /** @copydoc Light::getBounds */
  57. Sphere getBounds() const;
  58. /** @name Internal
  59. * @{
  60. */
  61. /** Returns the light that this component wraps. */
  62. SPtr<Light> _getLight() const { return mInternal; }
  63. /** @} */
  64. protected:
  65. mutable SPtr<Light> mInternal;
  66. // Only valid during construction
  67. LightType mType;
  68. Color mColor;
  69. float mIntensity;
  70. float mRange;
  71. bool mCastsShadows;
  72. Degree mSpotAngle;
  73. Degree mSpotFalloffAngle;
  74. /************************************************************************/
  75. /* COMPONENT OVERRIDES */
  76. /************************************************************************/
  77. protected:
  78. friend class SceneObject;
  79. /** @copydoc Component::onInitialized */
  80. void onInitialized() override;
  81. /** @copydoc Component::onDestroyed */
  82. void onDestroyed() override;
  83. /** @copydoc Component::update */
  84. void update() override { }
  85. /************************************************************************/
  86. /* RTTI */
  87. /************************************************************************/
  88. public:
  89. friend class CLightRTTI;
  90. static RTTITypeBase* getRTTIStatic();
  91. RTTITypeBase* getRTTI() const override;
  92. protected:
  93. CLight(); // Serialization only
  94. };
  95. /** @} */
  96. }