Example #1
0
    void UpdateFunctionTransition()
    {
        var from = FunctionLibrary.GetFunction(transitionFunction);
        var to   = FunctionLibrary.GetFunction(function);

        var progress = duration / transitionDuration;

        var time = Time.time;
        var step = 2f / resolution;

        var v = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; ++i, ++x)
        {
            if (x == resolution)
            {
                x = 0;
                ++z;
                v = (z + 0.5f) * step - 1f;
            }

            var u = (x + 0.5f) * step - 1f;

            points[i].localPosition = FunctionLibrary.Morph(u, v, time, from, to, progress);
        }
    }
Example #2
0
    void Update()
    {
        FunctionLibrary.Function f = FunctionLibrary.GetFunction(function);



        float time = Time.time;

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;

            if (Invert == 0)
            {
                position.x += (speed * Time.deltaTime);
            }
            else
            {
                position.x -= (speed * Time.deltaTime);
            }

            position.y = f(position.x, time);

            point.localPosition = position;
        }
    }
    void UpdateFunctionTransition()
    {
        FunctionLibrary.Function
            from       = FunctionLibrary.GetFunction(transitionFunction),
            to         = FunctionLibrary.GetFunction(function);
        float progress = duration / transitionDuration;
        float time     = Time.time;
        float step     = 2f / resolution;
        float v        = 0.5f * step - 1f;

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

            points[i].localPosition = FunctionLibrary.Morph(
                u, v, time, from, to, progress
                ) * range;
        }
    }
Example #4
0
    void UpdateFunctionTransition()
    {
        FunctionLibrary.Function
            from       = FunctionLibrary.GetFunction(transitionFunction),
            to         = FunctionLibrary.GetFunction(function);
        float progress = duration / transitionDuration;
        float time     = Time.time;
        float step     = 2f / resolution;
        // uv space added so that we're not confined in 3 coordinates (Sphere, Torus)
        float v = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (x == resolution)
            {
                x  = 0;
                z += 1;
                v  = (z + 0.5f) * step - 1f;
            }
            float u = (x + 0.5f) * step - 1f;
            points[i].localPosition = FunctionLibrary.Morph(
                u, v, time, from, to, progress
                );
        }
    }
Example #5
0
    private void AnimatingGraph()
    {
        FunctionLibrary.Function f = FunctionLibrary.GetFunction(functions);

        float time = Time.time;

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;



            point.localPosition = position;
        }
    }
Example #6
0
    private void Update()
    {
        // the function and current time
        FunctionLibrary.Function f = FunctionLibrary.GetFunction(function);
        float time = Time.time;

        // Animating Points
        for (int i = 0; i < points.Length; i++)
        {
            Transform point = points[i];

            Vector3 position = point.localPosition;
            position.y = f(position.x, time);

            point.localPosition = position;
        }
    }
Example #7
0
    private void Update()
    {
        FunctionLibrary.FunctionData functionData;

        if (AutomaticTransition && (this.duration > this.FunctionDuration || isTransitioning))
        {
            duration             = 0f;
            this.isTransitioning = true;
            functionData         = FunctionLibrary.GetNextFunction(this.function);
        }
        else
        {
            this.duration += Time.deltaTime;
            functionData   = FunctionLibrary.GetFunction(this.function);
        }

        this.UpdateGraph(functionData);
    }
Example #8
0
    private void UpdateFunction()
    {
        var f = FunctionLibrary.GetFunction(functionName);

        for (int x = 0; x < resolution; x++)
        {
            for (int z = 0; z < resolution; z++)
            {
                var point    = points[x * resolution + z];
                var position = point.transform.localPosition;
                var step     = (resolution / 2f);
                var u        = (x + 0.5f) / step - 1f;
                var v        = (z + 0.5f) / step - 1f;
                position = f(u, v, Time.time);
                point.transform.localPosition = position;
            }
        }
    }
Example #9
0
    private void UpdateFunction()
    {
        FunctionLibrary.Function function = FunctionLibrary.GetFunction(targetFunction);

        float time  = Time.time;
        int   index = 0;
        float step  = 2.0f / resolution;

        for (int x = 0; x != resolution; ++x)
        {
            for (int z = 0; z != resolution; ++z)
            {
                float u = (x + 0.5f) * step - 1f;
                float v = (z + 0.5f) * step - 1f;
                points[index++].localPosition = function(u, v, time);
            }
        }
    }
Example #10
0
    private void UpdateFunction()
    {
        float time = Time.time;
        float step = 2f / resolution;
        float v    = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (x == resolution)
            {
                x  = 0;
                z += 1;
                v  = (z + 0.5f) * step - 1f;
            }

            float u = (x + 0.5f) * step - 1f;
            points[i].localPosition = (Vector3)function.GetFunction(u, v, time);
        }
    }
Example #11
0
    void UpdateFunction()
    {
        FunctionLibrary.Function f = FunctionLibrary.GetFunction(function);
        float time = Time.time;
        float step = 2f / resolution;
        float v    = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (x == resolution)
            {
                x  = 0;
                z += 1;
                v  = (z + 0.5f) * step - 1f;
            }
            float u = (x + 0.5f) * step - 1f;
            points[i].localPosition = f(u, v, time);
        }
    }
Example #12
0
    void UpdateFunction()
    {
        FunctionLibrary.Function func = FunctionLibrary.GetFunction(functionName);
        float t    = Time.time;
        float step = 2f / resolution;
        float v    = .5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (resolution == x)
            {
                x  = 0;
                z += 1;
                v  = (z + .5f) * step - 1f;
            }
            float u = (x + .5f) * step - 1f;
            points[i].localPosition = func(u, v, t);
        }
    }
Example #13
0
    public void UpdateGraph(FunctionLibrary.FunctionData functionData)
    {
        float time = Time.time;
        float v    = 0.5f * this.grad - 1f;
        float u    = 0f;

        for (int i = 0, x = 0, z = 0; i < maximumUnit * maximumUnit; i++, x++)
        {
            u = (x + 0.5f) * this.grad - 1f;
            if (x == maximumUnit)
            {
                x = 0;
                z++;
                v = (z + 0.5f) * this.grad - 1f;
            }

            if (isTransitioning && this.currentLerpDuration < this.LerpDuration)
            {
                points[i].transform.localPosition = FunctionLibrary.MorphGraphs(u, v, time,
                                                                                FunctionLibrary.GetFunction(this.function).function,
                                                                                functionData.function,
                                                                                this.currentLerpDuration / LerpDuration);
            }
            else
            {
                points[i].transform.localPosition = functionData.function(u, v, time);
                this.isTransitioning = false;
            }
        }


        if (isTransitioning)
        {
            this.currentLerpDuration += Time.deltaTime;
            //this.function = FunctionLibrary.GetFunction(this.function).functionName;
        }
        else
        {
            this.currentLerpDuration = 0;
            this.function            = functionData.functionName;
        }
    }
Example #14
0
    private void UpdateFunctionTransition()
    {
        FunctionLibrary.Function from = FunctionLibrary.GetFunction(transitionFunction);
        FunctionLibrary.Function to   = FunctionLibrary.GetFunction(targetFunction);
        float progress = duration / transitionDuration;

        float time  = Time.time;
        int   index = 0;
        float step  = 2.0f / resolution;

        for (int x = 0; x != resolution; ++x)
        {
            for (int z = 0; z != resolution; ++z)
            {
                float u = (x + 0.5f) * step - 1f;
                float v = (z + 0.5f) * step - 1f;
                points[index++].localPosition = FunctionLibrary.Morph(u, v, time, from, to, progress);
            }
        }
    }
Example #15
0
    void UpdateFunction()
    {
        // delegate based on enum selection
        FunctionLibrary.Function f = FunctionLibrary.GetFunction(function);
        float time = Time.time;
        float step = 2f / resolution;
        // uv space added so that we're not confined in 3 coordinates (Sphere, Torus)
        float v = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (x == resolution)
            {
                x  = 0;
                z += 1;
                v  = (z + 0.5f) * step - 1f;
            }
            float u = (x + 0.5f) * step - 1f;
            points[i].localPosition = f(u, v, time);
        }
    }
Example #16
0
    void UpdateFunctionTransition()
    {
        FunctionLibrary.Function from = FunctionLibrary.GetFunction(transitionFromFunc);
        FunctionLibrary.Function to   = FunctionLibrary.GetFunction(functionName);
        float progress = duration / transitionDuration;
        float t        = Time.time;
        float step     = 2f / resolution;
        float v        = .5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (resolution == x)
            {
                x  = 0;
                z += 1;
                v  = (z + .5f) * step - 1f;
            }
            float u = (x + .5f) * step - 1f;
            points[i].localPosition = FunctionLibrary.Morph(u, v, t, from, to, progress);
        }
    }
Example #17
0
    private void UpdateFunctionTransition()
    {
        float progress = duration / transitionDuration;
        float time     = Time.time;
        float step     = 2f / resolution;
        float v        = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
        {
            if (x == resolution)
            {
                x  = 0;
                z += 1;
                v  = (z + 0.5f) * step - 1f;
            }

            float   u            = (x + 0.5f) * step - 1f;
            Vector3 fromFunction = (Vector3)previousFunction.GetFunction(u, v, time);
            Vector3 toFunction   = (Vector3)currentFunction.GetFunction(u, v, time);
            points[i].localPosition = (Vector3)function.Morph(u, v, time, progress, fromFunction, toFunction);
        }
    }
Example #18
0
    void UpdateFunction()
    {
        var f = FunctionLibrary.GetFunction(function);

        var time = Time.time;
        var step = 2f / resolution;

        var v = 0.5f * step - 1f;

        for (int i = 0, x = 0, z = 0; i < points.Length; ++i, ++x)
        {
            if (x == resolution)
            {
                x = 0;
                ++z;
                v = (z + 0.5f) * step - 1f;
            }

            var u = (x + 0.5f) * step - 1f;

            points[i].localPosition = f(u, v, time);
        }
    }