Beispiel #1
0
 public void AddParticle(Vector2 position, Vector2 velocity, float amplitude, float dispersionAngle)
 {
     if (amplitude > _waveParticleKillThreshold)
     {
         WaveParticle wp = WaveParticle.createWaveParticle(position, velocity, amplitude, dispersionAngle, currentFrame);
         waveParticles.addParticle(wp);
     }
 }
    public void TestSubdivisions()
    {
        var pc = new CPUParticleContainer();

        pc.Initialise(30000, 0.0001f);
        for (int i = 0; i < 1000000; i++)
        {
            pc.addParticle(WaveParticle.createWaveParticle(new Vector2(0, 0), new Vector2(0.5f, 0.5f), 1f, Mathf.PI / 2, 0));
        }
    }
    public void TestParticleAdditions()
    {
        var pc = new CPUParticleContainer();

        pc.Initialise(30000, 0.0001f);
        pc.addParticle(WaveParticle.createWaveParticle(new Vector2(0, 0), new Vector2(1, 0), 1f, Mathf.PI / 2, 0));
        int count = 0;

        foreach (var wp in pc)
        {
            count++;
        }
        Assert.That(count, Is.EqualTo(1));
        //Assert.That(count, Is.EqualTo(pc.numActiveParticles));
    }
Beispiel #4
0
    /// <summary>
    /// Create new wave particles due to computed object motion.
    /// </summary>
    void GenerateWaveParticles()
    {
        // TODO: Fix the ripple generator.
        if (Input.GetKey(KeyCode.Mouse0))
        {
            RaycastHit globalMousePosition;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out globalMousePosition))
            {
                Vector3 localMousePosition = transform.InverseTransformPoint(globalMousePosition.point);
                Vector2 clickLocation      = new Vector2(localMousePosition.x + extendedHeightField.Width / 2f, localMousePosition.z + extendedHeightField.Height / 2f);


                // Create a small ripple of particles
                {
                    WaveParticle wp = WaveParticle.createWaveParticle(clickLocation, new Vector2(0.5f, 0.5f), 0.8f, Mathf.PI * 2, currentFrame);
                    waveParticles.addParticle(wp);
                }
            }
        }
    }