Exemple #1
0
    void CalcParticlesPos()
    {
        int   particlesPerDir = 0;
        float perAngle        = 0;

        particlesPerDir = particleCountPerWave / dirCount;
        perAngle        = 2 * Mathf.PI / dirCount;

        for (int waveIndex = 0; waveIndex < waveInfos.Length; ++waveIndex)
        {
            for (int i = 0; i < dirCount; ++i)
            {
                for (int j = 0; j < particlesPerDir; ++j)
                {
                    PolarPos particlesPos = new PolarPos();
                    particlesPos.radius = j * delta;
                    particlesPos.angle  = i * perAngle;

                    var index = i * particlesPerDir + j;
                    var x     = particlesPos.X + waveInfos[waveIndex].startPoint.position.x;
                    var y     = Mathf.Clamp(
                        waveInfos[waveIndex].sinInfo.A - (particlesPos.radius * decreasingSpeed),
                        0f,
                        waveInfos[waveIndex].sinInfo.A)
                                * Mathf.Sin((particlesPos.radius - offset) * waveInfos[waveIndex].sinInfo.omega);
                    var z = particlesPos.Z + waveInfos[waveIndex].startPoint.position.z;

                    pos[waveIndex][index] = new Vector3(x, y, z);
                }
            }
        }
    }
Exemple #2
0
    void CalcCompound()
    {
        int     particlesPerDir = particleCountPerWave / dirCount;
        float   perAngle        = 2 * Mathf.PI / dirCount;
        Vector3 pointSum        = Vector3.zero;

        foreach (var waveInfo in waveInfos)
        {
            pointSum += waveInfo.startPoint.position;
        }
        Vector3 startPoint = pointSum / waveInfos.Length;

        for (int i = 0; i < dirCount; ++i)
        {
            for (int j = 0; j < particlesPerDir; ++j)
            {
                PolarPos particlesPos = new PolarPos();
                particlesPos.radius = j * delta;
                particlesPos.angle  = i * perAngle;

                var index = i * particlesPerDir + j;
                var x     = particlesPos.X + startPoint.x;
                var z     = particlesPos.Z + startPoint.z;
                var y     = 0f;
                foreach (var info in waveInfos)
                {
                    var wX = info.startPoint.position.x;
                    var wY = info.startPoint.position.y;
                    var wZ = info.startPoint.position.z;
                    var wR = Mathf.Sqrt(Mathf.Pow(x - wX, 2) + Mathf.Pow(z - wZ, 2));
                    y += Mathf.Clamp(waveInfos[0].sinInfo.A - wR * decreasingSpeed, 0f, waveInfos[0].sinInfo.A)
                         * Mathf.Sin(waveInfos[0].sinInfo.omega
                                     * (wR - offset)) + wY;
                }

                compoundPos[index] = new Vector3(x, y, z);
            }
        }
    }