private void AddTimeline(ParticleContainer container, ParticleInfo info, ChemicalVisualization viz) { Timeline tl = new Timeline(info.Name, ConvertColor(info.Color)); Functions.Add(new BasicFunctionPair(() => viz.Time, () => container.GetNParticles(info.Name))); AddTimeline(tl); }
void OnEnable() { if (inputControls == null) { inputControls = new InputMaster(); inputControls.Player.SetCallbacks(this); } inputControls.Player.Enable(); James = GameObject.FindGameObjectWithTag("James"); John = GameObject.FindGameObjectWithTag("John"); pc = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ParticleContainer>(); if (James != null) { rbJames = James.GetComponent <Rigidbody>(); } if (John != null) { rbJohn = John.GetComponent <Rigidbody>(); } onRewind += null; onJamesDeath += null; }
bool Init() { if (failedInitilization) { return(false); } if (!initialized) { m_particles = new ParticleContainer[particleSystemPrefabs.Length]; for (int i = 0; i < m_particles.Length; i++) { m_particles[i] = new ParticleContainer(particleSystemPrefabs[i]); } if (m_particles.Length == 0 || clips.Length == 0) { failedInitilization = true; Debug.Log(string.Format("Compound Effect {0} should have at least one audio clip and one particle effect!", name)); return(false); } initialized = true; } return(initialized); }
public ChemicalGraph(ParticleContainer container, ChemicalVisualization viz) : base("Time (s)", "Number of particles") { foreach (var info in container.Dictionary.Map.Values) { AddTimeline(container, info, viz); } }
public ThermodynamicsEngineAdapter(ParticleContainer cont) { this.cont = cont; foreach (var part in cont.Projectiles) { particles.Add(new ThermodynamicsProjectileAdapter(part)); } }
public MTile() { this._adjacent = new List <MTile>(); this._flags = new FTile(); this._height = 1; this._liquid = false; this._particles = new ParticleContainer(); }
public ChemicalGraph(ParticleContainer container, List <string> particleNames, ChemicalVisualization viz) : base("Time (s)", "Number of particles") { foreach (var part in particleNames) { AddTimeline(container, container.Dictionary.Map[part], viz); } }
override public void Initialise(ExtendedHeightField.HeightFieldInfo heightFieldInfo, ParticleContainer waveParticles) { this.heightFieldInfo = heightFieldInfo; this.waveParticles = waveParticles; sectionWidth = Mathf.CeilToInt((WaveParticle.RADIUS / heightFieldInfo.Width) * heightFieldInfo.HoriRes); sectionHeight = Mathf.CeilToInt((WaveParticle.RADIUS / heightFieldInfo.Height) * heightFieldInfo.VertRes); }
private void Start() { pc = GetComponent <ParticleContainer>(); spawner = GetComponent <EnemySpawner>(); volume = GameObject.Find("Post-process Volume").GetComponent <Volume>(); volume.profile.TryGet(out color); volume.profile.TryGet(out vignette); volume.profile.TryGet(out curves); }
public void SetSplatImplementation(SplatImplementation implementation) { if (implementation == _splatImplementationChoice) { return; } _particleContainer = SplatEnumToInstance(_splatImplementationChoice); _particleContainer.Initialise(_numParticles, _waveParticleKillThreshold); }
static internal void Thermodynamics() { const double containerSize = 50; const double minSpeed = 0; const double maxSpeed = 1500; //const double mass = 2.992e-26; const double mass = 2.992e-18; Color color1 = Colors.Aquamarine; Color color2 = Colors.Goldenrod; const int nParticles = 100; const double deltaTime = .0001; const double meanFreeTime = 2; var cont = new ParticleContainer(containerSize, containerSize, containerSize); //Level 3 //var generator1 = new MaxwellBoltzmann(mass, color1, meanFreeTime, minSpeed, maxSpeed, 273.15, 0, containerSize / 2); //var generator2 = new MaxwellBoltzmann(mass, color2, meanFreeTime, minSpeed, maxSpeed, 373.15, containerSize / 2, containerSize); //cont.AddRandomParticles(generator1, nParticles/2); //cont.AddRandomParticles(generator2, nParticles / 2); //Challenge var generator = new MaxwellBoltzmann(mass, color1, meanFreeTime, minSpeed, maxSpeed, 150, 0, containerSize); cont.AddCube(generator, nParticles); //Level 1,2,3 //var adapter = new ThermodynamicsEngineAdapter(cont); //var visualization = new SingleParticleVisualization(adapter); //Challenge var adapter = new ThermodynamicsEngineAdapter(cont); var visualization = new ConnectorVisualization(adapter); visualization.Radius = .5; var viz = new VisualizerControl.Visualizer(visualization); visualization.AddBox(containerSize, new Vector3D(containerSize / 2, containerSize / 2, containerSize / 2)); viz.TimeIncrement = deltaTime; viz.AddHist(ThermodynamicsProjectileAdapter.GetSpeed, adapter, 50, Colors.BlueViolet, "Speed (m/s)"); //Level 3 //viz.Add3DGraph("Temperature", (() => adapter.Time), cont.GetTemperatureVec, "Time (s)", "Temperature (K)"); //viz.AddText("Temperature Difference (K)", cont.GetTemperatureDiff, Colors.CadetBlue); //Challenge viz.AddSingleGraph("Temperature", () => adapter.Time, cont.GetTemperature, Colors.Aquamarine, "Time (s)", "Temperature (K)"); viz.AddText("Temperature (K)", cont.GetTemperature, Colors.CadetBlue); viz.AutoCamera = true; viz.Show(); }
override public void Initialise(ExtendedHeightField.HeightFieldInfo hf, ParticleContainer wp) { heightFieldInfo = hf; pointMap = new ExtendedHeightField(hf.Width, hf.Height, hf.HoriRes, hf.VertRes); pointMap.textureHeightMap.name = "Point Map Texture"; waveParticles = wp; kernelWidth = Mathf.CeilToInt((WaveParticle.RADIUS / heightFieldInfo.Width) * heightFieldInfo.HoriRes); kernelHeight = Mathf.CeilToInt((WaveParticle.RADIUS / heightFieldInfo.Height) * heightFieldInfo.VertRes); kernel = creatKernel(kernelWidth, kernelHeight, heightFieldInfo); }
static internal void Run() { const double containerSize = 50; const double minSpeed = 0; const double maxSpeed = 4200; const double mass = 1.7e-25; Color color = Colors.Lavender; const int nParticles = 1000; const double deltaTime = 0.1; const string name = "Molecule"; double temperature = 293.15; var cont = new ParticleContainer(containerSize); var info = new ParticleInfo(name, mass, ConvertColor(color)); var generator = new BoltzmannGenerator(cont, minSpeed, maxSpeed); cont.Dictionary.AddParticle(info); cont.AddRandomParticles(generator, name, nParticles); var visualization = new ThermodynamicsVisualization(cont) { BoxColor = Colors.IndianRed }; var viz = new MotionVisualizer3DControl(visualization) { TimeIncrement = deltaTime, TimeScale = 1 }; viz.FastDraw = true; const int histogramBins = 50; viz.Manager.AddSingleGraph("Temperature", ConvertColor(Colors.CornflowerBlue), () => visualization.Time, () => cont.GetTemperature(), "Time (s)", "Temperature (K)"); viz.Manager.AddHist(histogramBins, ConvertColor(Colors.BlueViolet), () => cont.GetParticlePropertyList((Particle part) => part.Velocity.Magnitude), "Speed (m/s)"); //viz.Manager.AddText("Temperature (K)", ConvertColor(Colors.CadetBlue), () => GetTemperature(cont)+""); viz.Manager.AddSingleGraph("Pressure", ConvertColor(Colors.Red), () => visualization.Time, () => cont.Pressure, "Time (s)", "Pressure (Pa)"); viz.Manager.AddSingleGraph("# Particles", ConvertColor(Colors.Green), () => visualization.Time, () => cont.Particles.Count, "Time (s)", "# Particles"); viz.Manager.AddSingleGraph("Volume", ConvertColor(Colors.Orange), () => visualization.Time, () => Math.Pow(cont.Size.X, 3), "Time (s)", "Volume (m^3)"); viz.Show(); }
// Use this for initialization void Awake() { if(particles == null || particles == this) { particles = this; } else { Destroy(this); } }
static internal void Run() { const double containerSize = 50; const double minSpeed = 1; const double maxSpeed = 100; const double mass = 4.65e-23; Color color = Colors.Lavender; const int nParticles = 1000; const double deltaTime = .01; const string name = "Molecule"; double temperature = 293.15; var cont = new ParticleContainer(containerSize, containerSize, containerSize); var info = new ParticleInfo(name, mass, ConvertColor(color)); //var generator = new FlatGenerator(cont, minSpeed, maxSpeed); var generator = new BoltzmannDistribution(cont, minSpeed, maxSpeed, temperature); cont.Dictionary.AddParticle(info); cont.AddRandomParticles(generator, name, nParticles); cont.Pressure = cont.Particles.Count * DongUtility.Constants.BoltzmannConstant * cont.GetTemperature() / (50 * 50 * 50); var visualization = new ThermodynamicsVisualization(cont) { BoxColor = Colors.IndianRed }; var viz = new MotionVisualizer(visualization) { TimeIncrement = deltaTime, TimeScale = 1 }; const int histogramBins = 50; viz.AddSingleGraph("Pressure", Colors.CornflowerBlue, () => visualization.Time, () => cont.Pressure, "Time (s)", "Pressure (N/m^2)"); //viz.AddText("Pressure", Colors.CadetBlue, () => cont.GetTemperature() * nParticles * DongUtility.Constants.BoltzmannConstant / (Math.Pow(containerSize,3)) ); //viz.AddSingleGraph("Pressure vs. Temperature", Colors.CornflowerBlue, () => cont.GetTemperature(), () => cont.Pressure, "Temperature (K)", "Pressure (N/m^2)"); viz.AddSingleGraph("Temperature vs. Time", Colors.CornflowerBlue, () => visualization.Time, () => cont.GetTemperature(), "Time (s)", "Temperature (K)"); //viz.AddHist(histogramBins, Colors.BlueViolet, () => cont.GetParticlePropertyList((Particle part) => part.Velocity.Magnitude), "Speed (m/s)"); //Volume vs. Temperature when n and P are constant viz.AddSingleGraph("Volume vs. Temperature", Colors.CornflowerBlue, () => cont.GetTemperature(), () => nParticles * DongUtility.Constants.BoltzmannConstant * cont.GetTemperature() / cont.Pressure, "Temperature (K)", "Volume (m^3)"); //viz.AddText("Volume", Colors.CadetBlue, () => cont.GetTemperature() * nParticles * DongUtility.Constants.BoltzmannConstant / (cont.Pressure) ); viz.AutoCamera = true; viz.AutoCamera = false; viz.Show(); }
private void Start() { if (Instance != null) { Destroy(this); return; } walkParticles = walkParticle.GetComponentsInChildren <ParticleSystem>(); interactParticles = interactParticle.GetComponentsInChildren <ParticleSystem>(); Instance = this; }
public WaveParticleSystem(float particleSpeed, float particleRadius, int maxNumParticles, int horRes, int vertRes, float height, float width, float waveParticleKillThreshold) { _particleSpeed = particleSpeed; _particleRadius = particleRadius; _numParticles = maxNumParticles; _waveParticleKillThreshold = waveParticleKillThreshold; _currentFrame = 0; // TODO: move all relvant code to do with this to here! _frameCycleLength = WaveParticle.FRAME_CYCLE_LENGTH; _extendedHeightField = new ExtendedHeightField(width, height, horRes, vertRes); _extendedHeightField.Clear(); _particleContainer = SplatEnumToInstance(_splatImplementationChoice); _particleContainer.Initialise(maxNumParticles, waveParticleKillThreshold); _heightFieldGenerator = ConvEnumToInstance(_convolutionImplementationChoice); _heightFieldGenerator.Initialise(_extendedHeightField.heightFieldInfo, _particleContainer); }
override public void Initialise(ExtendedHeightField.HeightFieldInfo hf, ParticleContainer wp) { heightFieldInfo = hf; pointMap = new ExtendedHeightField(hf.Width, hf.Height, hf.HoriRes, hf.VertRes); convolvedTexture = new Texture2D(heightFieldInfo.HoriRes, heightFieldInfo.VertRes, TextureFormat.RGBAFloat, false); convolvedTexture.anisoLevel = 1; convolvedTexture.filterMode = FilterMode.Point; convolvedTexture.wrapMode = TextureWrapMode.Clamp; convolvedTexture.name = "Convolved Texture"; shaderTexture = new RenderTexture(heightFieldInfo.HoriRes, heightFieldInfo.VertRes, 24, RenderTextureFormat.ARGBFloat); shaderTexture.antiAliasing = 1; shaderTexture.anisoLevel = 0; shaderTexture.autoGenerateMips = false; shaderTexture.wrapMode = TextureWrapMode.Clamp; shaderTexture.filterMode = FilterMode.Point; int kernelWidth = Mathf.CeilToInt((WaveParticle.RADIUS / heightFieldInfo.Width) * heightFieldInfo.HoriRes); int kernelHeight = Mathf.CeilToInt((WaveParticle.RADIUS / heightFieldInfo.Height) * heightFieldInfo.VertRes); Color[] kernelArray = Convolution2DFastHeightFieldGenerator.creatKernel(kernelHeight, kernelWidth, heightFieldInfo); kernel = new Texture2D(kernelWidth, kernelHeight, TextureFormat.RGBAFloat, false); kernel.SetPixels(kernelArray); kernel.Apply(); convolutionMaterial = new Material(Shader.Find("Unlit/2DFunction")); convolutionMaterial.SetTexture(Shader.PropertyToID("_KernelTex"), kernel); convolutionMaterial.SetFloat(Shader.PropertyToID("_Width"), heightFieldInfo.Width); convolutionMaterial.SetFloat(Shader.PropertyToID("_Height"), heightFieldInfo.Height); convolutionMaterial.SetInt(Shader.PropertyToID("_HoriRes"), heightFieldInfo.HoriRes); convolutionMaterial.SetInt(Shader.PropertyToID("_VertRes"), heightFieldInfo.VertRes); convolutionMaterial.SetFloat(Shader.PropertyToID("_ParticleRadii"), WaveParticle.RADIUS); convolutionMaterial.SetFloat(Shader.PropertyToID("_KernelWidth"), kernelWidth); convolutionMaterial.SetFloat(Shader.PropertyToID("_KernelHeight"), kernelHeight); waveParticles = wp; }
void Start() { pc = GameObject.Find("GameManager").GetComponent <ParticleContainer>(); }
public ThermodynamicsVisualization(ParticleContainer container) { this.container = container; }
private void Awake() { explosionPrefab = Resources.Load <ParticleContainer>("Prefabs/Explosion"); particlePool = new Pool <ParticleContainer>(initialStock, ParticleFactory, ParticleContainer.InitializePC, ParticleContainer.DisposePC, isDyanmic); }
private void Awake() { pc = GameObject.Find("GameManager").GetComponent <ParticleContainer>(); anim = GetComponent <Animator>(); }
public static void InitializePC(ParticleContainer asteroidObj) { asteroidObj.Initialize(); }
public static void DisposePC(ParticleContainer asteroidObj) { asteroidObj.Dispose(); }
public ChemicalVisualization(ParticleContainer container) { this.container = container; }
public static HeightFieldGenerator CreateAndInitialise(Choice hfge, ExtendedHeightField.HeightFieldInfo heightFieldInfo, ParticleContainer waveParticles) { HeightFieldGenerator heightFieldGenerator; switch (hfge) { case Choice.GPU_CONVOLUTION_2D: { heightFieldGenerator = new GPUConvolution2DFastHeightFieldGenerator(); } break; case Choice.CPU_CONVOLUTION_2D: { heightFieldGenerator = new Convolution2DFastHeightFieldGenerator(); } break; case Choice.PRECISE: { heightFieldGenerator = new PreciseHeightFieldGenerator(); } break; case Choice.NONE: { heightFieldGenerator = new EmptyHeightFieldGenerator(); } break; default: { // TODO: throw an appropriate exception! throw new System.Exception(); } } heightFieldGenerator.Initialise(heightFieldInfo, waveParticles); return(heightFieldGenerator); }
public override void Initialise(ExtendedHeightField.HeightFieldInfo heightFieldInfo, ParticleContainer waveParticles) { return; }
// Start is called before the first frame update void Start() { pc = GetComponent <ParticleContainer>(); StartCoroutine(SpawnTriangles()); StartCoroutine(SpawnStanders()); }
public abstract void Initialise(ExtendedHeightField.HeightFieldInfo heightFieldInfo, ParticleContainer waveParticles);