diff --git a/examples/example/misc/sunLightExample.js b/examples/example/misc/sunLightExample.js index e4826dcfeb..45cf353620 100644 --- a/examples/example/misc/sunLightExample.js +++ b/examples/example/misc/sunLightExample.js @@ -73,33 +73,33 @@ function runStageTime() { } Script.setInterval(runStageTime, tickTackPeriod); -panel.newCheckbox("Enable Earth Sun Model", - function(value) { Scene.setStageEarthSunModelEnable((value != 0)); }, - function() { return Scene.isStageEarthSunModelEnabled(); }, +panel.newCheckbox("Enable Sun Model", + function(value) { Scene.setStageSunModelEnable((value != 0)); }, + function() { return Scene.isStageSunModelEnabled(); }, function(value) { return (value); } ); panel.newDirectionBox("Light Direction", - function(value) { Scene.setSunDirection(value); }, - function() { return Scene.getSunDirection(); }, + function(value) { Scene.setKeyLightDirection(value); }, + function() { return Scene.getKeyLightDirection(); }, function(value) { return value.x.toFixed(2) + "," + value.y.toFixed(2) + "," + value.z.toFixed(2); } ); panel.newSlider("Light Intensity", 0.0, 5, - function(value) { Scene.setSunIntensity(value); }, - function() { return Scene.getSunIntensity(); }, + function(value) { Scene.setKeyLightIntensity(value); }, + function() { return Scene.getKeyLightIntensity(); }, function(value) { return (value).toFixed(2); } ); panel.newSlider("Ambient Light Intensity", 0.0, 1.0, - function(value) { Scene.setSunAmbientIntensity(value); }, - function() { return Scene.getSunAmbientIntensity(); }, + function(value) { Scene.setKeyLightAmbientIntensity(value); }, + function() { return Scene.getKeyLightAmbientIntensity(); }, function(value) { return (value).toFixed(2); } ); panel.newColorBox("Light Color", - function(value) { Scene.setSunColor(value); }, - function() { return Scene.getSunColor(); }, + function(value) { Scene.setKeyLightColor(value); }, + function() { return Scene.getKeyLightColor(); }, function(value) { return (value); } // "(" + value.x + "," = value.y + "," + value.z + ")"; } ); diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index 68c13e5a7c..77bc3f03f0 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -250,8 +250,8 @@ void SunSkyStage::setOriginLocation(float longitude, float latitude, float altit invalidate(); } -void SunSkyStage::setEarthSunModelEnable(bool isEnabled) { - _earthSunModelEnable = isEnabled; +void SunSkyStage::setSunModelEnable(bool isEnabled) { + _sunModelEnable = isEnabled; invalidate(); } @@ -266,7 +266,7 @@ void SunSkyStage::setSunAmbientIntensity(float intensity) { } void SunSkyStage::setSunDirection(const Vec3& direction) { - if (!isEarthSunModelEnabled()) { + if (!isSunModelEnabled()) { _sunLight->setDirection(direction); } } @@ -286,7 +286,7 @@ void SunSkyStage::updateGraphicsObject() const { // And update the sunLAtitude as the declinaison depending of the time of the year _earthSunModel.setSunLatitude(evalSunDeclinaison(_yearTime)); - if (isEarthSunModelEnabled()) { + if (isSunModelEnabled()) { Vec3d sunLightDir = -_earthSunModel.getSurfaceSunDir(); _sunLight->setDirection(Vec3(sunLightDir.x, sunLightDir.y, sunLightDir.z)); diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index eca290b852..237265ed12 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -204,8 +204,8 @@ public: float getOriginSurfaceAltitude() const { return _earthSunModel.getAltitude(); } // Enable / disable the effect of the time and location on the sun direction and color - void setEarthSunModelEnable(bool isEnabled); - bool isEarthSunModelEnabled() const { return _earthSunModelEnable; } + void setSunModelEnable(bool isEnabled); + bool isSunModelEnabled() const { return _sunModelEnable; } // Sun properties void setSunColor(const Vec3& color); @@ -236,7 +236,7 @@ protected: float _dayTime = 12.0f; int _yearTime = 0; mutable EarthSunModel _earthSunModel; - bool _earthSunModelEnable = true; + bool _sunModelEnable = true; mutable bool _invalid = true; void invalidate() const { _invalid = true; } diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 557938c78a..2461487414 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -46,44 +46,44 @@ int SceneScriptingInterface::getStageYearTime() const { return _skyStage->getYearTime(); } -void SceneScriptingInterface::setSunColor(const glm::vec3& color) { +void SceneScriptingInterface::setKeyLightColor(const glm::vec3& color) { _skyStage->setSunColor(color); } -glm::vec3 SceneScriptingInterface::getSunColor() const { +glm::vec3 SceneScriptingInterface::getKeyLightColor() const { return _skyStage->getSunColor(); } -void SceneScriptingInterface::setSunIntensity(float intensity) { +void SceneScriptingInterface::setKeyLightIntensity(float intensity) { _skyStage->setSunIntensity(intensity); } -float SceneScriptingInterface::getSunIntensity() const { +float SceneScriptingInterface::getKeyLightIntensity() const { return _skyStage->getSunIntensity(); } -void SceneScriptingInterface::setSunAmbientIntensity(float intensity) { +void SceneScriptingInterface::setKeyLightAmbientIntensity(float intensity) { _skyStage->setSunAmbientIntensity(intensity); } -float SceneScriptingInterface::getSunAmbientIntensity() const { +float SceneScriptingInterface::getKeyLightAmbientIntensity() const { return _skyStage->getSunAmbientIntensity(); } -void SceneScriptingInterface::setSunDirection(const glm::vec3& direction) { +void SceneScriptingInterface::setKeyLightDirection(const glm::vec3& direction) { _skyStage->setSunDirection(direction); } -glm::vec3 SceneScriptingInterface::getSunDirection() const { +glm::vec3 SceneScriptingInterface::getKeyLightDirection() const { return _skyStage->getSunDirection(); } -void SceneScriptingInterface::setStageEarthSunModelEnable(bool isEnabled) { - _skyStage->setEarthSunModelEnable(isEnabled); +void SceneScriptingInterface::setStageSunModelEnable(bool isEnabled) { + _skyStage->setSunModelEnable(isEnabled); } -bool SceneScriptingInterface::isStageEarthSunModelEnabled() const { - return _skyStage->isEarthSunModelEnabled(); +bool SceneScriptingInterface::isStageSunModelEnabled() const { + return _skyStage->isSunModelEnabled(); } model::SunSkyStagePointer SceneScriptingInterface::getSkyStage() const { diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index e847b7ff68..c384153a0f 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -38,21 +38,23 @@ public: Q_INVOKABLE void setStageYearTime(int day); Q_INVOKABLE int getStageYearTime() const; - Q_INVOKABLE void setStageEarthSunModelEnable(bool isEnabled); - Q_INVOKABLE bool isStageEarthSunModelEnabled() const; + // Enable/disable the stage sun model which uses the key light to simulate + // the sun light based on the location of the stage trelative to earth and the current time + Q_INVOKABLE void setStageSunModelEnable(bool isEnabled); + Q_INVOKABLE bool isStageSunModelEnabled() const; - Q_INVOKABLE void setSunColor(const glm::vec3& color); - Q_INVOKABLE glm::vec3 getSunColor() const; - Q_INVOKABLE void setSunIntensity(float intensity); - Q_INVOKABLE float getSunIntensity() const; - Q_INVOKABLE void setSunAmbientIntensity(float intensity); - Q_INVOKABLE float getSunAmbientIntensity() const; + Q_INVOKABLE void setKeyLightColor(const glm::vec3& color); + Q_INVOKABLE glm::vec3 getKeyLightColor() const; + Q_INVOKABLE void setKeyLightIntensity(float intensity); + Q_INVOKABLE float getKeyLightIntensity() const; + Q_INVOKABLE void setKeyLightAmbientIntensity(float intensity); + Q_INVOKABLE float getKeyLightAmbientIntensity() const; - // Only valid if stage Earth Sun model is disabled - Q_INVOKABLE void setSunDirection(const glm::vec3& direction); + // setKeyLightDIrection is only effective if stage Sun model is disabled + Q_INVOKABLE void setKeyLightDirection(const glm::vec3& direction); - Q_INVOKABLE glm::vec3 getSunDirection() const; + Q_INVOKABLE glm::vec3 getKeyLightDirection() const;