From 0098d16e488aa2cdd6f3b96f23450d2a532c9b5c Mon Sep 17 00:00:00 2001 From: Gauge Date: Sat, 13 Jul 2024 22:15:54 -0700 Subject: [PATCH] updated the heat indicator. --- .../Data/Scripts/Thermodynamics/Session.cs | 100 +++++++++++------- .../Data/Scripts/Thermodynamics/Settings.cs | 6 +- .../Scripts/Thermodynamics/ThermalCell.cs | 2 - ThermalDynamics/Data/TransparentMaterials.sbc | 18 ++++ .../Particles/GaugeThermalTexture.dds | Bin 0 -> 16512 bytes 5 files changed, 85 insertions(+), 41 deletions(-) create mode 100644 ThermalDynamics/Data/TransparentMaterials.sbc create mode 100644 ThermalDynamics/Textures/Particles/GaugeThermalTexture.dds diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/Session.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/Session.cs index 076dcdf..786b230 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/Session.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/Session.cs @@ -7,6 +7,7 @@ using Sandbox.ModAPI; using System; using System.Collections.Generic; +using System.Net; using System.Text; using VRage.Game; using VRage.Game.Components; @@ -56,34 +57,10 @@ public Color GetTemperatureColor(float temp) return new Color(red, 0, blue, 255); } - public void DrawBillboard(ThermalCell c, MatrixD cameraMatrix) - { - Vector3D blockPosition; - - c.Block.ComputeWorldCenter(out blockPosition); - - Color color = ColorExtensions.HSVtoColor(Tools.GetTemperatureColor(c.Temperature)); - - Vector3D drawPosition = MyAPIGateway.Session.Camera.WorldToScreen(ref blockPosition); - float distance = 0.00001f; - double blockDistance = (cameraMatrix.Translation - blockPosition).Length(); - float scaler = (float)Tools.GetVisualSize(blockDistance, c.Grid.Grid.GridSizeHalf); - - - MyTransparentGeometry.AddBillboardOriented( - MyStringId.GetOrCompute("Square"), // Texture or material name for the billboard - color, // Color of the billboard - cameraMatrix.Translation + (cameraMatrix.Forward * distance) + (cameraMatrix.Up * drawPosition.Y*distance) + (cameraMatrix.Left * drawPosition.X*distance), // Position of the billboard - cameraMatrix.Left, // Left direction of the billboard - cameraMatrix.Up, // Up direction of the billboard - 1f * scaler*distance, // Width of the billboard - 1f * scaler*distance // Height of the billboard - ); - } - public override void Draw() - { + public override void Simulate() + { if (Settings.Debug && !MyAPIGateway.Utilities.IsDedicated) { //MyAPIGateway.Utilities.ShowNotification($"[Grid] Frequency: {Settings.Instance.Frequency}", 1, "White"); @@ -109,15 +86,6 @@ public override void Draw() if (c == null) return; - - DrawBillboard(c, matrix); - for (int i = 0; i < c.Neighbors.Count; i++) - { - ThermalCell n = c.Neighbors[i]; - DrawBillboard(n, matrix); - } - - MyAPIGateway.Utilities.ShowNotification($"[Env] " + $"sim: {Settings.Instance.SimulationSpeed.ToString("n2")} " + $"freq: {Settings.Instance.Frequency.ToString("n2")} " + @@ -164,5 +132,65 @@ public override void Draw() //MyAPIGateway.Utilities.ShowNotification($"[External] {tGrid.Mapper.Blocks.Count} EComplete: {tGrid.Mapper.ExternalRoomUpdateComplete} BComplete: {tGrid.ThermalCellUpdateComplete}", 1, "White"); } } - } + + public override void Draw() + { + if (Settings.Debug && !MyAPIGateway.Utilities.IsDedicated) + { + //MyAPIGateway.Utilities.ShowNotification($"[Grid] Frequency: {Settings.Instance.Frequency}", 1, "White"); + MatrixD matrix = MyAPIGateway.Session.Camera.WorldMatrix; + + Vector3D start = matrix.Translation; + Vector3D end = start + (matrix.Forward * 15); + + IHitInfo hit; + MyAPIGateway.Physics.CastRay(start, end, out hit); + MyCubeGrid grid = hit?.HitEntity as MyCubeGrid; + if (grid == null) return; + + Vector3I position = grid.WorldToGridInteger(hit.Position + (matrix.Forward * 0.01f)); + + ThermalGrid g = grid.GameLogic.GetAs(); + + IMySlimBlock block = grid.GetCubeBlock(position); + + ThermalCell c = g.Get(block.Position); + + if (c == null) return; + + MyAPIGateway.Utilities.ShowNotification($"Made it to draw", 1); + + DrawBillboard(c, matrix); + for (int i = 0; i < c.Neighbors.Count; i++) + { + ThermalCell n = c.Neighbors[i]; + DrawBillboard(n, matrix); + } + } + } + + public void DrawBillboard(ThermalCell c, MatrixD cameraMatrix) + { + Vector3D position; + c.Block.ComputeWorldCenter(out position); + + float averageBlockLength = Vector3I.DistanceManhattan(c.Block.Max + 1, c.Block.Min) * 0.33f; + + Color color = ColorExtensions.HSVtoColor(Tools.GetTemperatureColor(c.Temperature)); + + float distance = 0.01f; + position = cameraMatrix.Translation + (position - cameraMatrix.Translation) * distance; + float scaler = 1.2f * c.Grid.Grid.GridSizeHalf * averageBlockLength * distance; + + MyTransparentGeometry.AddBillboardOriented( + MyStringId.GetOrCompute("GaugeThermalTexture"), // Texture or material name for the billboard + color, // Color of the billboard + position, + cameraMatrix.Left, // Left direction of the billboard + cameraMatrix.Up, // Up direction of the billboard + scaler, // Width of the billboard + scaler // Height of the billboard + ); + } + } } diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs index 00c7638..29a934b 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs @@ -16,7 +16,7 @@ public class Settings public const string Filename = "ThermodynamicsConfig.cfg"; public const string Name = "Thermodynamics"; public const bool Debug = true; - public const bool DebugBlockColors = false; + public const bool DebugBlockColors = true; public static Settings Instance; @@ -75,8 +75,8 @@ public static Settings GetDefaults() Version = 1, EnableSolarHeat = true, EnableDamage = true, - Frequency = 60, - SimulationSpeed = 1, + Frequency = 15, + SimulationSpeed = 4, SolarEnergy = 1000f, EnvironmentalRaycastDistance = 5000f, VaccumeRadiationStrength = 0.05f, diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs index d397a80..08144ae 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs @@ -55,8 +55,6 @@ public class ThermalCell public int ExposedSurfaces = 0; public List ExposedSurfaceDirections = new List(); - - public ThermalCell(ThermalGrid g, IMySlimBlock b) { Grid = g; diff --git a/ThermalDynamics/Data/TransparentMaterials.sbc b/ThermalDynamics/Data/TransparentMaterials.sbc new file mode 100644 index 0000000..2085fba --- /dev/null +++ b/ThermalDynamics/Data/TransparentMaterials.sbc @@ -0,0 +1,18 @@ + + + + + + TransparentMaterialDefinition + GaugeThermalTexture + + false + 1 + false + false + 0.1 + Textures\Particles\GaugeThermalTexture.dds + false + + + \ No newline at end of file diff --git a/ThermalDynamics/Textures/Particles/GaugeThermalTexture.dds b/ThermalDynamics/Textures/Particles/GaugeThermalTexture.dds new file mode 100644 index 0000000000000000000000000000000000000000..48e49ab5b1f338805cf861d074e0e3e9a60b414a GIT binary patch literal 16512 zcmeI3X^d257KW?a1!Z%h;1AG<`yWLS*JyM!B)AMH5*OkhjZ2KtxS)bWO*96hi5miH z9E?%XQ9wktMuip-5LpD9eJcS$L^cInaAut6Y3q>BJ5|-yO-FysROa#S-#zbp&Ufx@ zGPhf|-kl!I<#LDoC71gvOUYIFpWhbUFX?f`$=$m3uFCEA+s-oo?ZmMQ3&&m0<$jI- z{kFk9iv6mqt8*<|w#>C^)hgGeOPAcBL4$Jnd_GrKSC`wod2{a9Uw@SgOae()5$4mB_v7QqTw18ZSDY=Ey}QwH~W>?`nGuUQF>@fl2lH{faL4>!QYa0(cU zF&UdN8f$&*YEX-s)TTzYs@b2*OE0}NH((BGr!WfR@c>BQt&;nXPJ2(c; zhO3}27?<%)gqg4amVz4cuntn~->|*8fb04Z9(ZmZR)J$Igjt}k!{HgY7p{hL;8-vw zV>3o$HD+U1L%kn*phmT-Ir8rI^y$-cJ9g~ItzEk|w0o^%90&(P8#oN~`Z(wcJ>hP6 z9!9}rQ2Sgk=EV^CPxY(!Ti8;-b-mC7J@Q=h@3l+7u^dwmrog)}818|~;dD42jLjI^ zf-xKWULVw^MzyLrYF3r84k8jwpLH*UBcV6EPj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