diff options
| -rw-r--r-- | Lights.cs | 118 |
1 files changed, 103 insertions, 15 deletions
@@ -273,6 +273,7 @@ namespace WorldTuningTool public int TargetNo => MemoryUtil.Read<int>(Object + 0x614); public nint Texture => MemoryUtil.Read<nint>(Object + 0x670); public nint ShadowCacheResource => MemoryUtil.Read<nint>(Object + 0x698); + public Vector3 Position => MemoryUtil.Read<Vector3>(Object + 0x5A0); public uSpotLight(nint lightObject) : base(lightObject) { @@ -533,7 +534,8 @@ namespace WorldTuningTool private List<uLight> newLights = new List<uLight>(); private List<uLight> sceneLights = new List<uLight>(); - private bool sortByDistanceToPlayer = false; + private bool sortByDistanceToPlayerPoint = false; + private bool sortByDistanceToPlayerSpot = false; private NativeAction<nint, int, nint, int> addToScene; private NativeAction<nint> removeFromScene; @@ -817,7 +819,7 @@ namespace WorldTuningTool bool disableAll = ImGui.Button("Disable All"); if (ImGui.BeginItemTooltip()) { - ImGui.Text("Set \"Group\" to 0, Disable \"Shadow Cast\" and \"Do Volumetric\"."); + ImGui.Text("Set \"Group\" to 0, \"Intensity\" to 0.0 and Disable \"Shadow Cast\" and \"Do Volumetric\"."); ImGui.EndTooltip(); } ImGui.SameLine(); @@ -829,16 +831,58 @@ namespace WorldTuningTool { light.Parameters[0].ForceOverrideOn(); light.Parameters[0].SetOverrideValue(default, 0); + light.Parameters[3].ForceOverrideOn(); + light.Parameters[3].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); light.Parameters[7].ForceOverrideOn(); light.Parameters[7].SetOverrideValue(default, 0); light.Parameters[16].ForceOverrideOn(); light.Parameters[16].SetOverrideValue(default, 0); + if (light is uLlkPointLight) + { + light.Parameters[21].ForceOverrideOn(); + light.Parameters[21].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } + if (light is uLlkSpotLight) + { + light.Parameters[32].ForceOverrideOn(); + light.Parameters[32].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } + if (light is uHemiSphereLight) + { + light.Parameters[18].ForceOverrideOn(); + light.Parameters[18].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } + if (light is uLlkHemiSphereLight) + { + light.Parameters[21].ForceOverrideOn(); + light.Parameters[21].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + light.Parameters[23].ForceOverrideOn(); + light.Parameters[23].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } } if (enableAll) { light.Parameters[0].ForceOverrideOff(); + light.Parameters[3].ForceOverrideOff(); light.Parameters[7].ForceOverrideOff(); light.Parameters[16].ForceOverrideOff(); + if (light is uLlkPointLight) + { + light.Parameters[21].ForceOverrideOff(); + } + if (light is uLlkSpotLight) + { + light.Parameters[32].ForceOverrideOff(); + } + if (light is uHemiSphereLight) + { + light.Parameters[18].ForceOverrideOff(); + } + if (light is uLlkHemiSphereLight) + { + light.Parameters[21].ForceOverrideOff(); + light.Parameters[23].ForceOverrideOff(); + } } if (ImGui.CollapsingHeader(($"{light.Name} ({light.Info})"))) { @@ -923,33 +967,41 @@ namespace WorldTuningTool ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.Framed; if (ImGui.TreeNodeEx("Scene Lights", flags)) { + ImGui.PushID("Infinite"); if (ImGui.CollapsingHeader("Infinite")) { DrawLights(sceneLights.Where(x => (x.Type == 1)), width); ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("Point"); if (ImGui.CollapsingHeader("Point")) { - ImGui.Checkbox("Sort By Distance To Player", ref sortByDistanceToPlayer); + ImGui.Checkbox("Sort By Distance To Player", ref sortByDistanceToPlayerPoint); ImGui.SameLine(); - if (sortByDistanceToPlayer) + if (sortByDistanceToPlayerPoint) { Vector3 pos = default; Player? player = Player.MainPlayer; - if (player != null) + if (player != null) pos = player.Position; + DrawLights(Enumerable.OrderBy<uLight, uLight>(sceneLights.Where(x => (x.Type == 2)), x => x, Comparer<uLight>.Create((x, y) => { - pos = player.Position; - } - uLight[] pointLights = sceneLights.Where(x => (x.Type == 2)).ToArray(); - Array.Sort(pointLights, delegate(uLight x, uLight y) - { - float distX = Vector3.Distance(pos, ((uPointLight)x).Position); - float distY = Vector3.Distance(pos, ((uPointLight)y).Position); + Vector3 xPos = ((uPointLight)x).Position; + if (((uPointLight)x).Parent != 0x0) + { + xPos += MemoryUtil.GetRef<Vector3>(((uPointLight)x).Parent + 0x160); + } + Vector3 yPos = ((uPointLight)y).Position; + if (((uPointLight)y).Parent != 0x0) + { + yPos += MemoryUtil.GetRef<Vector3>(((uPointLight)y).Parent + 0x160); + } + float distX = Vector3.Distance(pos, xPos); + float distY = Vector3.Distance(pos, yPos); if (distX < distY) return -1; else if (distX > distY) return 1; return 0; - }); - DrawLights(pointLights, width); + })), width); } else { @@ -957,20 +1009,56 @@ namespace WorldTuningTool } ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("Spot"); if (ImGui.CollapsingHeader("Spot")) { - DrawLights(sceneLights.Where(x => (x.Type == 3)), width); + ImGui.Checkbox("Sort By Distance To Player", ref sortByDistanceToPlayerSpot); + ImGui.SameLine(); + if (sortByDistanceToPlayerSpot) + { + Vector3 pos = default; + Player? player = Player.MainPlayer; + if (player != null) pos = player.Position; + DrawLights(Enumerable.OrderBy<uLight, uLight>(sceneLights.Where(x => (x.Type == 3)), x => x, Comparer<uLight>.Create((x, y) => + { + Vector3 xPos = ((uSpotLight)x).Position; + if (((uSpotLight)x).Parent != 0x0) + { + xPos += MemoryUtil.GetRef<Vector3>(((uSpotLight)x).Parent + 0x160); + } + Vector3 yPos = ((uSpotLight)y).Position; + if (((uSpotLight)y).Parent != 0x0) + { + yPos += MemoryUtil.GetRef<Vector3>(((uSpotLight)y).Parent + 0x160); + } + float distX = Vector3.Distance(pos, xPos); + float distY = Vector3.Distance(pos, yPos); + if (distX < distY) return -1; + else if (distX > distY) return 1; + return 0; + })), width); + } + else + { + DrawLights(sceneLights.Where(x => (x.Type == 3)), width); + } ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("HemiSphere"); if (ImGui.CollapsingHeader("Hemi Sphere")) { DrawLights(sceneLights.Where(x => (x.Type == 4)), width); ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("Other"); if (ImGui.CollapsingHeader("Other")) { DrawLights(sceneLights.Where(x => (x.Type == -1 || x.Type == 5)), width); } + ImGui.PopID(); ImGui.TreePop(); } ImGui.PopID(); |