Beispiel #1
0
    void UpdateVertices(float[] samples)
    {
        for (var i = 0; i + 8 < vertices.Length; i += 8)
        {
            float t = (float)i / vertices.Length;

            int     index  = Mathf.RoundToInt(Easing.EaseInExpo(0, samples.Length, 0.99f - t));
            float   sample = samples[index] * GlobalState.I.WaveStickAmplifier;
            Vector3 top    = Vector3.up * sample / 2;
            Vector3 bot    = Vector3.down * sample / 2;

            Vector3 a = new Vector3(-0.5f, 0, 0.5f);
            Vector3 b = new Vector3(-0.5f, 0, -0.5f);
            Vector3 c = new Vector3(0.5f, 0, -0.5f);
            Vector3 d = new Vector3(0.5f, 0, 0.5f);

            vertices[i + 0] = Spiral(t, top + a);
            vertices[i + 1] = Spiral(t, top + b);
            vertices[i + 2] = Spiral(t, top + c);
            vertices[i + 3] = Spiral(t, top + d);

            vertices[i + 4] = Spiral(t, bot + a);
            vertices[i + 5] = Spiral(t, bot + b);
            vertices[i + 6] = Spiral(t, bot + c);
            vertices[i + 7] = Spiral(t, bot + d);
        }
    }