From 272885cb7b08c67b84a9ffbb70cb577905f8b215 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Thu, 4 Feb 2021 18:58:31 +0100 Subject: [PATCH 1/4] Added Light Intensity Signed-off-by: ahcorde --- include/ignition/rendering/Light.hh | 8 ++++++++ ogre/include/ignition/rendering/ogre/OgreLight.hh | 6 ++++++ ogre/src/OgreLight.cc | 12 ++++++++++++ ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh | 6 ++++++ ogre2/src/Ogre2Light.cc | 12 ++++++++++++ src/Light_TEST.cc | 4 ++++ 6 files changed, 48 insertions(+) diff --git a/include/ignition/rendering/Light.hh b/include/ignition/rendering/Light.hh index bb6d3f5a6..5d62c4790 100644 --- a/include/ignition/rendering/Light.hh +++ b/include/ignition/rendering/Light.hh @@ -106,6 +106,14 @@ namespace ignition /// \brief Specify if this light should cast shadows /// \param[in] _castShadows True if this light cast shadows public: virtual void SetCastShadows(bool _castShadows) = 0; + + /// \brief Get the light intensity + /// \return The light intensity + public: virtual double Intensity() const = 0; + + /// \brief Set the light intensity + /// \param[in] _intensity New light intensity + public: virtual void SetIntensity(double _intensity) = 0; }; /// \class DirectionalLight Light.hh ignition/rendering/Light.hh diff --git a/ogre/include/ignition/rendering/ogre/OgreLight.hh b/ogre/include/ignition/rendering/ogre/OgreLight.hh index d8db210b1..84703c8c2 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLight.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLight.hh @@ -67,6 +67,12 @@ namespace ignition public: virtual void SetCastShadows(bool _castShadows); + // Documentation Inherited + public: virtual double Intensity() const override; + + // Documentation Inherited + public: virtual void SetIntensity(double _intensity) override; + public: virtual Ogre::Light *Light() const; public: virtual void Destroy(); diff --git a/ogre/src/OgreLight.cc b/ogre/src/OgreLight.cc index 6022de883..8c899e04a 100644 --- a/ogre/src/OgreLight.cc +++ b/ogre/src/OgreLight.cc @@ -118,6 +118,18 @@ void OgreLight::SetAttenuationRange(double _range) this->UpdateAttenuation(); } +////////////////////////////////////////////////// +double OgreLight::Intensity() const +{ + return this->ogreLight->getPowerScale(); +} + +////////////////////////////////////////////////// +void OgreLight::SetIntensity(double _intensity) +{ + this->ogreLight->setPowerScale(_intensity); +} + ////////////////////////////////////////////////// bool OgreLight::CastShadows() const { diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh index 685fc4b1e..b10f22cb1 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh @@ -89,6 +89,12 @@ namespace ignition // Documentation Inherited public: virtual void SetCastShadows(bool _castShadows) override; + // Documentation Inherited + public: virtual double Intensity() const override; + + // Documentation Inherited + public: virtual void SetIntensity(double _intensity) override; + /// \brief Get a pointer to ogre light public: virtual Ogre::Light *Light() const; diff --git a/ogre2/src/Ogre2Light.cc b/ogre2/src/Ogre2Light.cc index af1dac8f0..dc768e6da 100644 --- a/ogre2/src/Ogre2Light.cc +++ b/ogre2/src/Ogre2Light.cc @@ -123,6 +123,18 @@ void Ogre2Light::SetAttenuationRange(double _range) this->UpdateAttenuation(); } +////////////////////////////////////////////////// +double Ogre2Light::Intensity() const +{ + return this->ogreLight->getPowerScale(); +} + +////////////////////////////////////////////////// +void Ogre2Light::SetIntensity(double _intensity) +{ + this->ogreLight->setPowerScale(_intensity * Ogre::Math::PI); +} + ////////////////////////////////////////////////// bool Ogre2Light::CastShadows() const { diff --git a/src/Light_TEST.cc b/src/Light_TEST.cc index ea8c289ee..b19d8992e 100644 --- a/src/Light_TEST.cc +++ b/src/Light_TEST.cc @@ -74,6 +74,10 @@ void LightTest::Light(const std::string &_renderEngine) light->SetCastShadows(false); EXPECT_FALSE(light->CastShadows()); + // intensity + light->SetIntensity(1.25); + EXPECT_DOUBLE_EQ(1.25, light->Intensity()); + // attenuation // Checking near because Ogre stores it as float light->SetAttenuationConstant(0.6); From aaa79f9c838aef47f9d8906a32c3cfe2e748fed7 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Fri, 5 Feb 2021 08:56:22 +0100 Subject: [PATCH 2/4] set intensity to the default value in the reset method Signed-off-by: ahcorde --- include/ignition/rendering/base/BaseLight.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/include/ignition/rendering/base/BaseLight.hh b/include/ignition/rendering/base/BaseLight.hh index 05dee7f53..516b46c26 100644 --- a/include/ignition/rendering/base/BaseLight.hh +++ b/include/ignition/rendering/base/BaseLight.hh @@ -148,6 +148,7 @@ namespace ignition this->SetAttenuationQuadratic(0); this->SetAttenuationRange(100); this->SetCastShadows(true); + this->SetIntensity(1.0); } ////////////////////////////////////////////////// From e0fec35d24b8e49cc9e9b604fc1740ee50cbe281 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Mon, 8 Feb 2021 08:08:39 +0100 Subject: [PATCH 3/4] Fixed Light_TEST Signed-off-by: ahcorde --- ogre2/src/Ogre2Light.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogre2/src/Ogre2Light.cc b/ogre2/src/Ogre2Light.cc index dc768e6da..886dae5c3 100644 --- a/ogre2/src/Ogre2Light.cc +++ b/ogre2/src/Ogre2Light.cc @@ -132,7 +132,7 @@ double Ogre2Light::Intensity() const ////////////////////////////////////////////////// void Ogre2Light::SetIntensity(double _intensity) { - this->ogreLight->setPowerScale(_intensity * Ogre::Math::PI); + this->ogreLight->setPowerScale(_intensity); } ////////////////////////////////////////////////// From d0553faf5874e7b72c0aa108778e3099c55dd64b Mon Sep 17 00:00:00 2001 From: ahcorde Date: Mon, 8 Feb 2021 09:02:59 +0100 Subject: [PATCH 4/4] Fixed MACOS warnings Signed-off-by: ahcorde --- .../ignition/rendering/ogre/OgreLight.hh | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ogre/include/ignition/rendering/ogre/OgreLight.hh b/ogre/include/ignition/rendering/ogre/OgreLight.hh index 84703c8c2..98c8cc3e1 100644 --- a/ogre/include/ignition/rendering/ogre/OgreLight.hh +++ b/ogre/include/ignition/rendering/ogre/OgreLight.hh @@ -39,33 +39,34 @@ namespace ignition public: virtual ~OgreLight(); - public: virtual math::Color DiffuseColor() const; + public: virtual math::Color DiffuseColor() const override; - public: virtual void SetDiffuseColor(const math::Color &_color); + public: virtual void SetDiffuseColor(const math::Color &_color) override; - public: virtual math::Color SpecularColor() const; + public: virtual math::Color SpecularColor() const override; - public: virtual void SetSpecularColor(const math::Color &_color); + public: virtual void SetSpecularColor( + const math::Color &_color) override; - public: virtual double AttenuationConstant() const; + public: virtual double AttenuationConstant() const override; - public: virtual void SetAttenuationConstant(double _value); + public: virtual void SetAttenuationConstant(double _value) override; - public: virtual double AttenuationLinear() const; + public: virtual double AttenuationLinear() const override; - public: virtual void SetAttenuationLinear(double _value); + public: virtual void SetAttenuationLinear(double _value) override; - public: virtual double AttenuationQuadratic() const; + public: virtual double AttenuationQuadratic() const override; - public: virtual void SetAttenuationQuadratic(double _value); + public: virtual void SetAttenuationQuadratic(double _value) override; - public: virtual double AttenuationRange() const; + public: virtual double AttenuationRange() const override; - public: virtual void SetAttenuationRange(double _range); + public: virtual void SetAttenuationRange(double _range) override; - public: virtual bool CastShadows() const; + public: virtual bool CastShadows() const override; - public: virtual void SetCastShadows(bool _castShadows); + public: virtual void SetCastShadows(bool _castShadows) override; // Documentation Inherited public: virtual double Intensity() const override; @@ -75,9 +76,9 @@ namespace ignition public: virtual Ogre::Light *Light() const; - public: virtual void Destroy(); + public: virtual void Destroy() override; - protected: virtual void Init(); + protected: virtual void Init() override; private: void CreateLight();