From 743dc1117cf0df97860dde141f42548ec0bd608b Mon Sep 17 00:00:00 2001 From: RDW Date: Tue, 30 Jan 2024 07:12:23 +0100 Subject: [PATCH] Refactor: Simplify the RSW directional light computation This also accounts for the inverted Y axis, but makes it clearer that the sunlight origin is located directly above the map. --- Core/FileFormats/RagnarokRSW.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/FileFormats/RagnarokRSW.lua b/Core/FileFormats/RagnarokRSW.lua index ff0fce81..5eeb9c21 100644 --- a/Core/FileFormats/RagnarokRSW.lua +++ b/Core/FileFormats/RagnarokRSW.lua @@ -253,16 +253,14 @@ function RagnarokRSW:DecodeEnvironmentalLightSources() end function RagnarokRSW:ComputeSunRayDirection(latitudeInDegrees, longitudeInDegrees) - local sunRayDirection = Vector3D(0, 1, 0) + local sunRayDirection = Vector3D(0, -1, 0) - local rotationAroundX = Matrix3D:CreateAxisRotationX(latitudeInDegrees) + local rotationAroundX = Matrix3D:CreateAxisRotationX(-latitudeInDegrees) -- Account for inverted Y axis local rotationAroundY = Matrix3D:CreateAxisRotationY(longitudeInDegrees) sunRayDirection:Transform(rotationAroundX) sunRayDirection:Transform(rotationAroundY) - sunRayDirection.y = -1 * sunRayDirection.y - return sunRayDirection end