diff --git a/Client/App/App.vcproj b/Client/App/App.vcproj
index 813b5c2f..475f3f28 100644
--- a/Client/App/App.vcproj
+++ b/Client/App/App.vcproj
@@ -1306,6 +1306,10 @@
RelativePath=".\v8datamodel\JointInstance.cpp"
>
+
+
diff --git a/Client/App/include/v8datamodel/Lighting.h b/Client/App/include/v8datamodel/Lighting.h
index 3cb8ff97..a5fb9b7b 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 seconds);
+ 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..e1f32192
--- /dev/null
+++ b/Client/App/v8datamodel/Lighting.cpp
@@ -0,0 +1,195 @@
+#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(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(152/255.0f, 137/255.0f, 102/255.0f);
+ skyParameters.setTime(timeOfDay.total_seconds());
+ setName("Lighting");
+ }
+
+ Lighting::~Lighting()
+ {
+ }
+
+ G3D::Vector3 Lighting::getMoonPosition()
+ {
+ return (skyParameters.physicallyCorrect) ? skyParameters.trueMoonPosition : skyParameters.moonPosition;
+ }
+
+ G3D::Vector3 Lighting::getSunPosition()
+ {
+ return (skyParameters.physicallyCorrect) ? skyParameters.trueSunPosition : 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();
+ }
+ }
+
+ //65.93% matching.
+ void Lighting::setTime(const boost::posix_time::time_duration& time)
+ {
+ if (timeOfDay != time)
+ {
+ timeOfDay = boost::posix_time::time_duration(0, 0, time.total_seconds());
+ 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.total_milliseconds() / 60000.0;
+ }
+
+ void Lighting::setMinutesAfterMidnight(double seconds)
+ {
+ setTime(boost::posix_time::time_duration(0, 0, seconds * 60));
+ }
+
+ 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