예제 #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Space))
     {
         Vector3[] particles = new Vector3[amount];
         for (int i = 0; i < particles.Length; i++)
         {
             particles[i] = 5 * new Vector3(Random.value, Random.value, Random.value);
         }
         Color[] colors = new Color[amount];
         for (int i = 0; i < colors.Length; i++)
         {
             colors[i] = Random.ColorHSV();
         }
         Vector3[] scales   = new Vector3[amount];
         Vector3   baseSize = 0.01f * Vector3.one;
         for (int i = 0; i < particles.Length; i++)
         {
             scales[i] = 0.05f * (new Vector3(Random.value, Random.value, Random.value)) + baseSize;
         }
         manager.AddPoints(particles, scales: scales, colors: colors);
     }
     if (Input.GetKeyUp(KeyCode.Delete))
     {
         manager.Clear();
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (!added)
        {
            cpu_particles = GenerateCpuParticles(numCpuParticles);
            cpu_particles_manager.AddParticles(cpu_particles, 0, numCpuParticles);
            simulator = new PhysicalParticleSimulator(Vector3.one * cellSize * Mathf.Sqrt(numCpuParticles) * Mathf.Log10(numCpuParticles), particles: cpu_particles,
                                                      method: PhysicalParticleSimulator.SimulatorAlgorithm.HASHING, gravitational_constant: 6.67408e-12f);
            //simulator = new PhysicalParticleSimulator(Vector3.one * cellSize * Mathf.Sqrt(numCpuParticles) * Mathf.Log10(numCpuParticles), particles: cpu_particles);

            GenerateGpuParticles(numGpuParticles);
            added = true;
        }

        if (Input.GetKeyUp(KeyCode.Space))
        {
            gpu_particles_manager.Clear();
            GenerateGpuParticles(numGpuParticles);
        }

        ReinitializeParticles();
    }