Пример #1
0
    // Update is called once per frame
    void Update()
    {
        float           t   = Time.time;
        GraphFunction   f   = functions[(int)function];
        Graph3DFunction f3d = functions3D[(int)function3D];

        if (is3D)
        {
            float step = 2f / resolution;
            for (int i = 0, z = 0; z < resolution; z++)
            {
                float v = (z + 0.5f) * step - 1f;
                for (int x = 0; x < resolution; x++, i++)
                {
                    float u = (x + 0.5f) * step - 1f;
                    points[i].localPosition = f3d(u, v, t);
                }
            }
        }
        else
        {
            for (int i = 0; i < points.Length; i++)
            {
                Transform point    = points[i];
                Vector3   position = point.localPosition;
                position.y          = f(position.x, position.z, t);
                point.localPosition = position;
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        float           t = Time.time;
        Graph3DFunction f = functions[(int)function];

        float step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }