mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 12:59:41 +00:00
Improve temperature colours to allow for different base colours.
Make a start on insulation. Code the characteristics of air into static IHeatTransfer variables.
This commit is contained in:
1 parent
7214a88a7a
commit
ab2a7cb6c7
6 files changed
+92
-32
No files matched your search
@@ -2,6 +2,8 @@ package mekanism.client.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.api.IHeatTransfer;
|
||||
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
|
||||
public class ColourTemperature extends ColourRGBA
|
||||
@@ -16,65 +18,75 @@ public class ColourTemperature extends ColourRGBA
|
||||
temp = t;
|
||||
}
|
||||
|
||||
public static ColourTemperature fromTemperature(double temperature)
|
||||
public static ColourTemperature fromTemperature(double temperature, ColourRGBA baseColour)
|
||||
{
|
||||
temperature += 300;
|
||||
temperature = temperature / 100;
|
||||
|
||||
if(cache.containsKey((int)temperature))
|
||||
if(temperature < 0)
|
||||
{
|
||||
return cache.get((int)temperature);
|
||||
double alphaBlend = -temperature/IHeatTransfer.AMBIENT_TEMP;
|
||||
if(alphaBlend < 0)
|
||||
alphaBlend = 0;
|
||||
if(alphaBlend > 1)
|
||||
alphaBlend = 1;
|
||||
return new ColourTemperature(1, 1, 1, alphaBlend, temperature).blendOnto(baseColour);
|
||||
}
|
||||
double absTemp = temperature + IHeatTransfer.AMBIENT_TEMP;
|
||||
absTemp /= 100;
|
||||
|
||||
if(cache.containsKey((int)absTemp))
|
||||
{
|
||||
return cache.get((int)absTemp).blendOnto(baseColour);
|
||||
}
|
||||
|
||||
double tmpCalc;
|
||||
double red, green, blue, alpha;
|
||||
double effectiveTemp = absTemp;
|
||||
|
||||
if(temperature < 10)
|
||||
temperature = 10;
|
||||
if(temperature > 400)
|
||||
temperature = 400;
|
||||
if(effectiveTemp < 10)
|
||||
effectiveTemp = 10;
|
||||
if(effectiveTemp > 400)
|
||||
effectiveTemp = 400;
|
||||
|
||||
if(temperature <= 66)
|
||||
if(effectiveTemp <= 66)
|
||||
{
|
||||
red = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpCalc = temperature - 60;
|
||||
tmpCalc = effectiveTemp - 60;
|
||||
tmpCalc = 329.698727446 * Math.pow(tmpCalc,-0.1332047592);
|
||||
red = tmpCalc/255D;
|
||||
}
|
||||
|
||||
if(temperature <= 66)
|
||||
if(effectiveTemp <= 66)
|
||||
{
|
||||
tmpCalc = temperature;
|
||||
tmpCalc = effectiveTemp;
|
||||
tmpCalc = 99.4708025861 * Math.log(tmpCalc) - 161.1195681661;
|
||||
green = tmpCalc/255D;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpCalc = temperature - 60;
|
||||
tmpCalc = effectiveTemp - 60;
|
||||
tmpCalc = 288.1221695283 * Math.pow(tmpCalc, -0.0755148492);
|
||||
green = tmpCalc/255D;
|
||||
}
|
||||
|
||||
if(temperature >= 66)
|
||||
if(effectiveTemp >= 66)
|
||||
{
|
||||
blue = 1;
|
||||
}
|
||||
else if(temperature <= 19)
|
||||
else if(effectiveTemp <= 19)
|
||||
{
|
||||
blue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpCalc = temperature - 10;
|
||||
tmpCalc = effectiveTemp - 10;
|
||||
tmpCalc = 138.5177312231 * Math.log(tmpCalc) - 305.0447927307;
|
||||
|
||||
blue = tmpCalc / 255D;
|
||||
}
|
||||
|
||||
alpha = (temperature - 3)/10;
|
||||
alpha = temperature/1000;
|
||||
|
||||
if(red < 0) red = 0;
|
||||
if(red > 1) red = 1;
|
||||
@@ -88,10 +100,23 @@ public class ColourTemperature extends ColourRGBA
|
||||
if(alpha < 0) alpha = 0;
|
||||
if(alpha > 1) alpha = 1;
|
||||
|
||||
ColourTemperature colourTemperature = new ColourTemperature(red, green, blue, alpha, temperature*100-300);
|
||||
ColourTemperature colourTemperature = new ColourTemperature(red, green, blue, alpha, temperature);
|
||||
|
||||
cache.put((int)(temperature), colourTemperature);
|
||||
cache.put((int)(absTemp), colourTemperature);
|
||||
|
||||
return colourTemperature;
|
||||
return colourTemperature.blendOnto(baseColour);
|
||||
}
|
||||
|
||||
public ColourTemperature blendOnto(ColourRGBA baseColour)
|
||||
{
|
||||
double sR = (r & 0xFF)/255D, sG = (g & 0xFF)/255D, sB = (b & 0xFF)/255D, sA = (a & 0xFF)/255D;
|
||||
double dR = (baseColour.r & 0xFF)/255D, dG = (baseColour.g & 0xFF)/255D, dB = (baseColour.b & 0xFF)/255D, dA = (baseColour.a & 0xFF)/255D;
|
||||
|
||||
double rR = sR * sA + dR * (1-sA);
|
||||
double rG = sG * sA + dG * (1-sA);
|
||||
double rB = sB * sA + dB * (1-sA);
|
||||
double rA = dA * 1D + sA * (1-dA);
|
||||
|
||||
return new ColourTemperature(rR, rG, rB, rA, temp);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user