Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Light Intensity #233

Merged
merged 6 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/ignition/rendering/Light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/ignition/rendering/base/BaseLight.hh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ namespace ignition
this->SetAttenuationQuadratic(0);
this->SetAttenuationRange(100);
this->SetCastShadows(true);
this->SetIntensity(1.0);
}

//////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions ogre/include/ignition/rendering/ogre/OgreLight.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions ogre/src/OgreLight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 6 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 12 additions & 0 deletions ogre2/src/Ogre2Light.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 4 additions & 0 deletions src/Light_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down