Skip to content

Commit

Permalink
1.4 release.
Browse files Browse the repository at this point in the history
Reduced plasma trail scale.
Added new GUI elements.
Set GUI to show in Debug builds.
  • Loading branch information
pizzaoverhead committed Feb 13, 2019
1 parent 72af9d7 commit b911bd8
Showing 1 changed file with 48 additions and 10 deletions.
58 changes: 48 additions & 10 deletions ReentryParticleEffect/ReentryParticleEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ReentryParticleEffect : MonoBehaviour
public Vector3 velocity;
public static int MaxParticles = 3000;
public static int MaxEmissionRate = 200;
public static float TrailScale = 0.15f;
// Minimum reentry strength that the effects will activate at.
// 0 = Activate at the first sign of the flame effects.
// 1 = Never activate, even at the strongest reentry strength.
Expand Down Expand Up @@ -60,7 +61,10 @@ public ReentryEffect CreateEffect()
ReentryEffect reentryFx = new ReentryEffect(effect);
// Set the effect speed high to animate as fast as is visible.
var trailMain = reentryFx.Trail.main;
reentryFx.Trail.transform.localScale = new Vector3(TrailScale, TrailScale, TrailScale);
trailMain.scalingMode = ParticleSystemScalingMode.Local;
trailMain.simulationSpeed = 5;

var sparksMain = reentryFx.Sparks.main;
sparksMain.simulationSpeed = 5;

Expand All @@ -69,10 +73,6 @@ public ReentryEffect CreateEffect()

public static Dictionary<Guid, ReentryEffect> VesselDict = new Dictionary<Guid, ReentryEffect>();

// Temporary for GUI
/*private static float effectStrength = 0;
private static AerodynamicsFX afx1 = null;*/

private void FixedUpdate()
{
float effectStrength = (AeroFX.FxScalar * AeroFX.state - EffectThreshold) * (1 / EffectThreshold);
Expand Down Expand Up @@ -111,7 +111,16 @@ private void FixedUpdate()
ParticleSystem.EmissionModule sparksEmission = effects.Sparks.emission;
if (AeroFX != null)
{
//afx1 = AeroFX;
//effects.Trail.transform.localScale = new Vector3(TrailScale, TrailScale, TrailScale);
#if DEBUG
afx1 = AeroFX;

effects.Trail.transform.localScale = new Vector3(scaleX, scaleY, scaleZ);

var main = effects.Trail.main;
main.scalingMode = _scalingMode;
#endif

// FxScalar: Strength of the effects.
// state: 0 = condensation, 1 = reentry.
if (effectStrength > 0)
Expand Down Expand Up @@ -178,7 +187,8 @@ AerodynamicsFX AeroFX
return _aeroFX;
}
}
/*


public static Color BlackBodyToRgb(float tempKelvin)
{
// C# implementation of Tanner Helland's approximation from here:
Expand Down Expand Up @@ -243,9 +253,31 @@ public static Color BlackBodyToRgb(float tempKelvin)
return new Color(red/255, green/255, blue/255, 1);
}

#if DEBUG
private static float effectStrength = 0;
private static AerodynamicsFX afx1 = null;
private static Rect windowPos = new Rect(Screen.width / 4, Screen.height / 4, 10f, 10f);

/// <summary>
/// GUI draw event. Called (at least once) each frame.
/// </summary>
public void OnGUI()
{
if (DrawGui)
windowPos = GUILayout.Window(GetInstanceID(), windowPos, Gui, "Test GUI", GUILayout.Width(600), GUILayout.Height(50));
}
private static string _trailPlaybackText = "5";
private static string _sparksPlaybackText = "5";
public static void Gui()
private static ParticleSystemScalingMode _scalingMode;
private static float scaleX;
private static float scaleY;
private static float scaleZ;
private static string scaleXText = "1";
private static string scaleYText = "1";
private static string scaleZText = "1";


public static void Gui(int windowID)
{
ReentryEffect effects = null;
if (VesselDict.ContainsKey(FlightGlobals.ActiveVessel.id))
Expand Down Expand Up @@ -309,7 +341,7 @@ public static void Gui()
new GradientColorKey[] { new GradientColorKey(Color.blue, 0.0f), new GradientColorKey(Color.red, 1.0f) },
new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) }
);
* /
*/

key0 = GuiUtils.rgbaSlider("Colour Gradient 0", ref key0.r, ref key0.g, ref key0.b, ref key0.a, 0f, 1f);
key1 = GuiUtils.rgbaSlider("Colour Gradient 1", ref key1.r, ref key1.g, ref key1.b, ref key1.a, 0f, 1f);
Expand All @@ -335,7 +367,12 @@ public static void Gui()
float sparksPlaybackSpeed = sparksMain.simulationSpeed;
_sparksPlaybackText = GuiUtils.editFloat("Playback speed", _sparksPlaybackText, out sparksPlaybackSpeed, 5);
sparksMain.simulationSpeed = sparksPlaybackSpeed;
}* /
}*/

scaleXText = GuiUtils.editFloat("X Scale", scaleXText, out scaleX, 1);
scaleYText = GuiUtils.editFloat("Y Scale", scaleYText, out scaleY, 1);
scaleZText = GuiUtils.editFloat("Z Scale", scaleZText, out scaleZ, 1);
GUI.DragWindow();
}

public static float GetVesselMaxSkinTemp()
Expand All @@ -349,7 +386,8 @@ public static float GetVesselMaxSkinTemp()
}

return maxTemp;
}*/
}
#endif
}

/*[KSPAddon(KSPAddon.Startup.MainMenu, false)]
Expand Down

0 comments on commit b911bd8

Please sign in to comment.