From f0cfb500b78089bdec4c8dc661be3a2dcb7cec08 Mon Sep 17 00:00:00 2001 From: Tad Walter Date: Sat, 3 Jan 2026 18:45:48 -0500 Subject: [PATCH 1/6] Work on Lighting --- Client/App/App.vcproj | 4 + Client/App/include/v8datamodel/Lighting.h | 74 +++++--- Client/App/v8datamodel/Lighting.cpp | 200 ++++++++++++++++++++++ 3 files changed, 255 insertions(+), 23 deletions(-) create mode 100644 Client/App/v8datamodel/Lighting.cpp diff --git a/Client/App/App.vcproj b/Client/App/App.vcproj index fe1db49b..d7680bf1 100644 --- a/Client/App/App.vcproj +++ b/Client/App/App.vcproj @@ -1262,6 +1262,10 @@ RelativePath=".\v8datamodel\GlobalSettings.cpp" > + + diff --git a/Client/App/include/v8datamodel/Lighting.h b/Client/App/include/v8datamodel/Lighting.h index 3cb8ff97..c745e4ee 100644 --- a/Client/App/include/v8datamodel/Lighting.h +++ b/Client/App/include/v8datamodel/Lighting.h @@ -1,6 +1,7 @@ #pragma once -#include "v8tree/Service.h" #include +#include "v8tree/Service.h" +#include "v8datamodel/Sky.h" namespace RBX { @@ -27,38 +28,65 @@ namespace RBX //Lighting(const Lighting&); Lighting(); public: - void replaceSky(Sky*); + void replaceSky(Sky* sky); bool isSkySuppressed() const; void suppressSky(const bool); - const G3D::LightingParameters& getSkyParameters() const; + const G3D::LightingParameters& getSkyParameters() const + { + return skyParameters; + } G3D::Color4 getClearColor() const; - void setClearColor(G3D::Color4); - G3D::Color3 getLightColor() const; - void setLightColor(G3D::Color3); - G3D::Color3 getAmbientTop() const; - void setAmbientTop(G3D::Color3); - G3D::Color3 getAmbientBottom() const; - void setAmbientBottom(G3D::Color3); + void setClearColor(G3D::Color4 newClearColor); + G3D::Color3 getLightColor() const + { + return skyParameters.lightColor; + } + void setLightColor(G3D::Color3 newLightColor); + G3D::Color3 getAmbientTop() const + { + return ambientTop; + } + void setAmbientTop(G3D::Color3 newAmbientTop); + G3D::Color3 getAmbientBottom() const + { + return ambientBottom; + } + void setAmbientBottom(G3D::Color3 newAmbientBottom); std::string getTimeStr() const; - void setTimeStr(const std::string&); - void setTime(const boost::posix_time::time_duration&); + void setTimeStr(const std::string& time); + void setTime(const boost::posix_time::time_duration& time); double getGameTime() const; double getMinutesAfterMidnight(); - void setMinutesAfterMidnight(double); - float getMoonPhase(); + void setMinutesAfterMidnight(double minutes); + float getMoonPhase() + { + return skyParameters.moonPhase; + } G3D::Vector3 getMoonPosition(); G3D::Vector3 getSunPosition(); - float getGeographicLatitude() const; - void setGeographicLatitude(float); - G3D::Color3 getClearColor3() const; - void setClearColor3(G3D::Color3); + float getGeographicLatitude() const + { + return skyParameters.geoLatitude; + } + void setGeographicLatitude(float newGeographicLatitude); + G3D::Color3 getClearColor3() const + { + return G3D::Color3(clearColor.r, clearColor.g, clearColor.b); + } + void setClearColor3(G3D::Color3 color) + { + setClearColor(G3D::Color4(color)); + } protected: - virtual void onChildAdded(Instance*); - virtual void onChildRemoving(Instance*); - virtual void onChildChanged(Instance*, const PropertyChanged&); - virtual bool askAddChild(const Instance*) const; + virtual void onChildAdded(Instance* instance); + virtual void onChildRemoving(Instance* instance); + virtual void onChildChanged(Instance* instance, const PropertyChanged& propEvent); + virtual bool askAddChild(const Instance* instance) const; private: - void fireLightingChanged(bool); + void fireLightingChanged(bool value) + { + event_LightingChanged.fire(this, value); + } public: virtual ~Lighting(); public: diff --git a/Client/App/v8datamodel/Lighting.cpp b/Client/App/v8datamodel/Lighting.cpp new file mode 100644 index 00000000..8788e363 --- /dev/null +++ b/Client/App/v8datamodel/Lighting.cpp @@ -0,0 +1,200 @@ +#include "v8datamodel/Lighting.h" +#include "util/RunStateOwner.h" + +namespace RBX +{ + const char* sLighting = "Lighting"; + + static const Reflection::PropDescriptor desc_AmbientTop("TopAmbientV9", "Appearance", &Lighting::getAmbientTop, &Lighting::setAmbientTop, Reflection::PropertyDescriptor::STANDARD); + static const Reflection::PropDescriptor desc_AmbientBottom("BottomAmbientV9", "Appearance", &Lighting::getAmbientBottom, &Lighting::setAmbientBottom, Reflection::PropertyDescriptor::STANDARD); + static const Reflection::PropDescriptor desc_LightColor("SpotLightV9", "Appearance", &Lighting::getLightColor, &Lighting::setLightColor, Reflection::PropertyDescriptor::STANDARD); + static const Reflection::PropDescriptor desc_ClearColor("ClearColor", "Appearance", &Lighting::getClearColor3, &Lighting::setClearColor3, Reflection::PropertyDescriptor::STANDARD); + static const Reflection::PropDescriptor prop_Time("TimeOfDay", "Data", &Lighting::getTimeStr, &Lighting::setTimeStr, Reflection::PropertyDescriptor::STANDARD); + static const Reflection::PropDescriptor prop_GeographicLatitude("GeographicLatitude", "Data", &Lighting::getGeographicLatitude, &Lighting::setGeographicLatitude, Reflection::PropertyDescriptor::STANDARD); + + Lighting::Lighting() + : Base(), + ambientTop(.8f, .8f, .8f), + ambientBottom(.4f, .5f, .4f), + hasSky(true), + clearColor(G3D::Color3::white()), + timeOfDay(boost::posix_time::duration_from_string("14:00:00")) + { + skyParameters.lightColor = G3D::Color3(.5f, .5f, .4f); + skyParameters.setTime(timeOfDay.total_seconds()); + setName("Lighting"); + } + + Lighting::~Lighting() + { + } + + G3D::Vector3 Lighting::getMoonPosition() + { + if (skyParameters.physicallyCorrect) + return skyParameters.trueMoonPosition; + else + return skyParameters.moonPosition; + } + + G3D::Vector3 Lighting::getSunPosition() + { + if (skyParameters.physicallyCorrect) + return skyParameters.trueSunPosition; + else + return skyParameters.sunPosition; + } + + void Lighting::replaceSky(Sky* sky) + { + Sky* currentSky = findFirstChildOfType(); + while (currentSky) + { + currentSky->setParent(NULL); + currentSky = findFirstChildOfType(); + } + sky->setParent(this); + } + + std::string Lighting::getTimeStr() const + { + return boost::posix_time::to_simple_string(timeOfDay); + } + + void Lighting::setTimeStr(const std::string &time) + { + setTime(boost::posix_time::duration_from_string(time)); + } + + void Lighting::setClearColor(G3D::Color4 newClearColor) + { + if (newClearColor != clearColor) + { + clearColor = newClearColor; + raisePropertyChanged(desc_ClearColor); + fireLightingChanged(false); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::setLightColor(G3D::Color3 newLightColor) + { + if (newLightColor != skyParameters.lightColor) + { + skyParameters.lightColor = newLightColor; + raisePropertyChanged(desc_LightColor); + fireLightingChanged(false); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::setAmbientBottom(G3D::Color3 newAmbientBottom) + { + if (newAmbientBottom != ambientBottom) + { + ambientBottom = newAmbientBottom; + raisePropertyChanged(desc_AmbientBottom); + fireLightingChanged(false); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::setAmbientTop(G3D::Color3 newAmbientTop) + { + if (newAmbientTop != ambientTop) + { + ambientTop = newAmbientTop; + raisePropertyChanged(desc_AmbientTop); + fireLightingChanged(false); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::setGeographicLatitude(float newGeographicLatitude) + { + if (newGeographicLatitude != skyParameters.geoLatitude) + { + skyParameters.geoLatitude = newGeographicLatitude; + raisePropertyChanged(prop_GeographicLatitude); + fireLightingChanged(false); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::setTime(const boost::posix_time::time_duration& time) + { + if (timeOfDay != time) + { + timeOfDay = time; + skyParameters.setTime(timeOfDay.total_seconds()); + raisePropertyChanged(prop_Time); + fireLightingChanged(false); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + double Lighting::getMinutesAfterMidnight() + { + return timeOfDay.hours() * 60; + } + + void Lighting::setMinutesAfterMidnight(double minutes) + { + setTime(boost::posix_time::time_duration(0, minutes, 0)); + } + + void Lighting::onChildAdded(Instance* instance) + { + Sky* newSky = fastDynamicCast(instance); + + if (newSky) + { + sky = shared_from(newSky); + fireLightingChanged(true); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::onChildRemoving(Instance* instance) + { + if (sky.get() == instance) + { + sky.reset(); + fireLightingChanged(true); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + void Lighting::onChildChanged(Instance* instance, const PropertyChanged& propEvent) + { + Instance::onChildChanged(instance, propEvent); + if (sky.get() == instance) + { + fireLightingChanged(true); + RunService* runService = ServiceProvider::findServiceProvider(this)->find(); + if (runService) + runService->invalidateRunViews(); + } + } + + bool Lighting::askAddChild(const Instance* instance) const + { + return fastDynamicCast(instance) != NULL; + } +} \ No newline at end of file From fc59b9ece845b73a440cd0724c10ab886f05d01a Mon Sep 17 00:00:00 2001 From: Tad Walter Date: Sat, 24 Jan 2026 16:28:05 -0500 Subject: [PATCH 2/6] Lighting (88%) in Total! --- Client/App/v8datamodel/Lighting.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Client/App/v8datamodel/Lighting.cpp b/Client/App/v8datamodel/Lighting.cpp index 8788e363..24f95220 100644 --- a/Client/App/v8datamodel/Lighting.cpp +++ b/Client/App/v8datamodel/Lighting.cpp @@ -14,13 +14,13 @@ namespace RBX Lighting::Lighting() : Base(), - ambientTop(.8f, .8f, .8f), - ambientBottom(.4f, .5f, .4f), + ambientTop(209/255.0f, 208/255.0f, 217/255.0f), + ambientBottom(122/255.0f, 134/255.0f, 120/255.0f), hasSky(true), clearColor(G3D::Color3::white()), timeOfDay(boost::posix_time::duration_from_string("14:00:00")) { - skyParameters.lightColor = G3D::Color3(.5f, .5f, .4f); + skyParameters.lightColor = G3D::Color3(152/255.0f, 137/255.0f, 102/255.0f); skyParameters.setTime(timeOfDay.total_seconds()); setName("Lighting"); } @@ -31,18 +31,12 @@ namespace RBX G3D::Vector3 Lighting::getMoonPosition() { - if (skyParameters.physicallyCorrect) - return skyParameters.trueMoonPosition; - else - return skyParameters.moonPosition; + return (skyParameters.physicallyCorrect) ? skyParameters.trueMoonPosition : skyParameters.moonPosition; } G3D::Vector3 Lighting::getSunPosition() { - if (skyParameters.physicallyCorrect) - return skyParameters.trueSunPosition; - else - return skyParameters.sunPosition; + return (skyParameters.physicallyCorrect) ? skyParameters.trueSunPosition : skyParameters.sunPosition; } void Lighting::replaceSky(Sky* sky) @@ -131,6 +125,7 @@ namespace RBX } } + //43.30% matching. void Lighting::setTime(const boost::posix_time::time_duration& time) { if (timeOfDay != time) @@ -145,6 +140,7 @@ namespace RBX } } + //50% matching. double Lighting::getMinutesAfterMidnight() { return timeOfDay.hours() * 60; From 08f33314085d6514e51b0a99da0ce45a54bfb828 Mon Sep 17 00:00:00 2001 From: Tad Walter Date: Sat, 24 Jan 2026 16:36:05 -0500 Subject: [PATCH 3/6] Update App.vcproj --- Client/App/App.vcproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Client/App/App.vcproj b/Client/App/App.vcproj index 69a3788c..40b5d6af 100644 --- a/Client/App/App.vcproj +++ b/Client/App/App.vcproj @@ -1282,6 +1282,10 @@ RelativePath=".\v8datamodel\JointInstance.cpp" > + + From 483ae9fa144089b9ec912fb123c6acc047fb0db0 Mon Sep 17 00:00:00 2001 From: Tad Walter Date: Sat, 24 Jan 2026 22:47:28 -0500 Subject: [PATCH 4/6] setMinutesAfterMidnight 100% --- Client/App/include/v8datamodel/Lighting.h | 2 +- Client/App/v8datamodel/Lighting.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/App/include/v8datamodel/Lighting.h b/Client/App/include/v8datamodel/Lighting.h index c745e4ee..a5fb9b7b 100644 --- a/Client/App/include/v8datamodel/Lighting.h +++ b/Client/App/include/v8datamodel/Lighting.h @@ -57,7 +57,7 @@ namespace RBX void setTime(const boost::posix_time::time_duration& time); double getGameTime() const; double getMinutesAfterMidnight(); - void setMinutesAfterMidnight(double minutes); + void setMinutesAfterMidnight(double seconds); float getMoonPhase() { return skyParameters.moonPhase; diff --git a/Client/App/v8datamodel/Lighting.cpp b/Client/App/v8datamodel/Lighting.cpp index 24f95220..d650d170 100644 --- a/Client/App/v8datamodel/Lighting.cpp +++ b/Client/App/v8datamodel/Lighting.cpp @@ -146,9 +146,9 @@ namespace RBX return timeOfDay.hours() * 60; } - void Lighting::setMinutesAfterMidnight(double minutes) + void Lighting::setMinutesAfterMidnight(double seconds) { - setTime(boost::posix_time::time_duration(0, minutes, 0)); + setTime(boost::posix_time::time_duration(0, 0, seconds * 60)); } void Lighting::onChildAdded(Instance* instance) From aeb4a8d86509e6bb0d9dd50f06fd3427408169ed Mon Sep 17 00:00:00 2001 From: Tad Walter Date: Sun, 25 Jan 2026 10:53:34 -0500 Subject: [PATCH 5/6] getMinutesAfterMidnight 100% --- Client/App/v8datamodel/Lighting.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Client/App/v8datamodel/Lighting.cpp b/Client/App/v8datamodel/Lighting.cpp index d650d170..c5e00134 100644 --- a/Client/App/v8datamodel/Lighting.cpp +++ b/Client/App/v8datamodel/Lighting.cpp @@ -140,10 +140,9 @@ namespace RBX } } - //50% matching. double Lighting::getMinutesAfterMidnight() { - return timeOfDay.hours() * 60; + return timeOfDay.total_milliseconds() / 60000.0; } void Lighting::setMinutesAfterMidnight(double seconds) From 5c40c2fecb02c06b563dff29615be1358dd93a71 Mon Sep 17 00:00:00 2001 From: Tad Walter Date: Sun, 25 Jan 2026 16:12:57 -0500 Subject: [PATCH 6/6] setTime 65.93% matching I feel like the if statement is the issue. I don't know how to do that though. --- Client/App/v8datamodel/Lighting.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/App/v8datamodel/Lighting.cpp b/Client/App/v8datamodel/Lighting.cpp index c5e00134..e1f32192 100644 --- a/Client/App/v8datamodel/Lighting.cpp +++ b/Client/App/v8datamodel/Lighting.cpp @@ -125,12 +125,12 @@ namespace RBX } } - //43.30% matching. + //65.93% matching. void Lighting::setTime(const boost::posix_time::time_duration& time) { if (timeOfDay != time) { - timeOfDay = time; + timeOfDay = boost::posix_time::time_duration(0, 0, time.total_seconds()); skyParameters.setTime(timeOfDay.total_seconds()); raisePropertyChanged(prop_Time); fireLightingChanged(false);