diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-09-22 12:54:48 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-09-22 12:54:48 +0100 |
commit | 3573ecff39a617cc4084660aba2baf6f4bebfaaf (patch) | |
tree | 5f5b35aed4b4f543692a79243a07cf3d8bddefb1 /game/environment.cpp | |
parent | Move getSunPos to Environment (diff) | |
download | ilt-3573ecff39a617cc4084660aba2baf6f4bebfaaf.tar.bz2 ilt-3573ecff39a617cc4084660aba2baf6f4bebfaaf.tar.xz ilt-3573ecff39a617cc4084660aba2baf6f4bebfaaf.zip |
Calculate sunlight direction from worldTime
Diffstat (limited to 'game/environment.cpp')
-rw-r--r-- | game/environment.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/game/environment.cpp b/game/environment.cpp index 665c11b..1ef9bcb 100644 --- a/game/environment.cpp +++ b/game/environment.cpp @@ -7,14 +7,16 @@ Environment::Environment() : worldTime {"2024-01-01T12:00:00"_time_t} { } void Environment::tick(TickDuration) { - worldTime += 1; + worldTime += 50; } void Environment::render(const SceneRenderer & renderer, const SceneProvider & scene) const { + const auto sunPos = getSunPos({}, worldTime); + const auto sunDir = (glm::mat3 {rotate_yp({sunPos.y + pi, sunPos.x})} * north); renderer.setAmbientLight({0.5F, 0.5F, 0.5F}); - renderer.setDirectionalLight({0.6F, 0.6F, 0.6F}, {-1, 1, -1}, scene); + renderer.setDirectionalLight({0.6F, 0.6F, 0.6F}, sunDir, scene); } // Based on the C++ code published at https://www.psa.es/sdg/sunpos.htm |