Installed Surge, fixed compile errors, moved a bunch of external stuff into folder

This commit is contained in:
2025-09-10 10:53:04 +02:00
parent a3649c65b0
commit 52bd7ef585
433 changed files with 10589 additions and 4 deletions

View File

@@ -0,0 +1,96 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Forces a referenced particle system to flow along this spline. To optimize performance limit Max Particles to just what is necessary. Particle speed along the path is determined by Start Lifetime.
///
/// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pixelplacement;
[ExecuteInEditMode]
[RequireComponent (typeof (Spline))]
public class SplineControlledParticleSystem : MonoBehaviour
{
//Public Variables:
public float startRadius;
public float endRadius;
//Private Variables:
[SerializeField] ParticleSystem _particleSystem = null;
Spline _spline;
ParticleSystem.Particle[] _particles;
const float _previousDiff = .01f;
//Init:
void Awake ()
{
_spline = GetComponent<Spline> ();
}
//Loops:
void LateUpdate ()
{
if (_particleSystem == null) return;
if (_particles == null) _particles = new ParticleSystem.Particle[_particleSystem.main.maxParticles];
int aliveParticlesCount = _particleSystem.GetParticles (_particles);
for (int i = 0; i < aliveParticlesCount; i++)
{
//get calculation pieces:
float seedMax = Mathf.Pow(10, _particles[i].randomSeed.ToString().Length);
float seedAsPercent = _particles[i].randomSeed / seedMax;
float travelPercentage = 1 - (_particles[i].remainingLifetime / _particles[i].startLifetime);
//bypass issue while running at edit time when particles haven't reached the spline end:
if (_spline.GetDirection(travelPercentage, false) == Vector3.zero) continue;
//get a direction off our current point on the path - rotating by 1080 results in better distribution since Unity's randomSeed for particles favors lower numbers:
Vector3 offshootDirection = Quaternion.AngleAxis(1080 * seedAsPercent, -_spline.GetDirection(travelPercentage, false)) * _spline.Up(travelPercentage);
Vector3 previousOffshootDirection = Quaternion.AngleAxis(1080 * seedAsPercent, -_spline.GetDirection(travelPercentage - _previousDiff, false)) * _spline.Up(travelPercentage - _previousDiff, false);
//cache our positions:
Vector3 position = _spline.GetPosition(travelPercentage, false);
//cache a previous position for velocity if possible:
Vector3 lastPosition = position;
if (travelPercentage - .01f >= 0) lastPosition = _spline.GetPosition(travelPercentage - _previousDiff, false);
//decide how far to offshoot from the spline based on where we are between the start and end radius:
float offset = Mathf.Lerp(startRadius, endRadius, travelPercentage);
float previousOffset = Mathf.Lerp(startRadius, endRadius, travelPercentage - _previousDiff);
//place particles depending on simulation space:
Vector3 currentPosition = Vector3.zero;
Vector3 previousPosition = Vector3.zero;
switch (_particleSystem.main.simulationSpace)
{
case ParticleSystemSimulationSpace.Local:
currentPosition = _particleSystem.transform.InverseTransformPoint(position + offshootDirection * offset);
previousPosition = _particleSystem.transform.InverseTransformPoint(lastPosition + previousOffshootDirection * previousOffset);
break;
case ParticleSystemSimulationSpace.World:
case ParticleSystemSimulationSpace.Custom:
currentPosition = position + offshootDirection * offset;
previousPosition = position + previousOffshootDirection * previousOffset;
break;
}
//apply:
_particles[i].position = currentPosition;
_particles[i].velocity = currentPosition - previousPosition;
}
//apply the particle changes back to the system:
_particleSystem.SetParticles (_particles, _particles.Length);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 390cd5d7e4c3ca3459339daddc886b38
timeCreated: 1505006763
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Spline/Utilities/SplineControlledParticleSystem.cs
uploadId: 467433

View File

@@ -0,0 +1,122 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Renders a spline by interfacing with an attached LineRenderer.
///
/// </summary>
using UnityEngine;
using System.Collections;
namespace Pixelplacement
{
[ExecuteInEditMode]
[RequireComponent (typeof (LineRenderer))]
[RequireComponent (typeof (Spline))]
public class SplineRenderer : MonoBehaviour
{
//Public Variables:
public int segmentsPerCurve = 25;
[Range (0,1)] public float startPercentage;
[Range (0,1)] public float endPercentage = 1;
//Private Variables:
LineRenderer _lineRenderer;
Spline _spline;
bool _initialized;
int _previousAnchorsLength;
int _previousSegmentsPerCurve;
int _vertexCount;
float _previousStart;
float _previousEnd;
//Init:
void Reset ()
{
_lineRenderer = GetComponent<LineRenderer> ();
_initialized = false;
_lineRenderer.startWidth = .03f;
_lineRenderer.endWidth = .03f;
_lineRenderer.startColor = Color.white;
_lineRenderer.endColor = Color.yellow;
_lineRenderer.material = Resources.Load("SplineRenderer") as Material;
}
//Loop:
void Update ()
{
//initialize:
if (!_initialized)
{
//refs:
_lineRenderer = GetComponent<LineRenderer> ();
_spline = GetComponent<Spline> ();
//initial setup:
ConfigureLineRenderer ();
UpdateLineRenderer ();
_initialized = true;
}
//configure line renderer:
if (segmentsPerCurve != _previousSegmentsPerCurve || _previousAnchorsLength != _spline.Anchors.Length)
{
ConfigureLineRenderer ();
UpdateLineRenderer ();
}
if (_spline.Anchors.Length <= 1)
{
_lineRenderer.positionCount = 0;
return;
}
//if any part of the spline is changed update line renderer:
foreach (var item in _spline.Anchors)
{
if (item.RenderingChange)
{
item.RenderingChange = false;
UpdateLineRenderer ();
}
}
//if the range has changed, update:
if (startPercentage != _previousStart || endPercentage != _previousEnd)
{
UpdateLineRenderer ();
//reset:
_previousStart = startPercentage;
_previousEnd = endPercentage;
}
}
//Private Methods:
void UpdateLineRenderer ()
{
if (_spline.Anchors.Length < 2) return;
for (int i = 0; i < _vertexCount; i++)
{
float percentage = i/(float)(_vertexCount - 1);
float sample = Mathf.Lerp (startPercentage, endPercentage, percentage);
_lineRenderer.SetPosition (i, _spline.GetPosition(sample, false));
}
}
void ConfigureLineRenderer ()
{
segmentsPerCurve = Mathf.Max (0, segmentsPerCurve);
_vertexCount = (segmentsPerCurve * (_spline.Anchors.Length - 1)) + 2;
if (Mathf.Sign (_vertexCount) == 1) _lineRenderer.positionCount = _vertexCount;
_previousSegmentsPerCurve = segmentsPerCurve;
_previousAnchorsLength = _spline.Anchors.Length;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 59d7ebe8a03344a7a869c5061d6607a0
timeCreated: 1483504895
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Spline/Utilities/SplineRenderer.cs
uploadId: 467433