示例#1
0
    public static void Test()
    {
        float[] values = { 0f, 1f, 2f, 3f, 4f };

        var interpolation = new CatmullRomSpline(values);
        Debug.Log(interpolation.GetValue(-1f));
        Debug.Log(interpolation.GetValue(3.5f));
        Debug.Log(interpolation.GetValue(4f));
        Debug.Log(interpolation.GetValue(5f));
    }
示例#2
0
    public static void Test()
    {
        float[] values = { 0f, 1f, 2f, 3f, 4f };

        var interpolation = new CatmullRomSpline(values);

        Debug.Log(interpolation.GetValue(-1f));
        Debug.Log(interpolation.GetValue(3.5f));
        Debug.Log(interpolation.GetValue(4f));
        Debug.Log(interpolation.GetValue(5f));
    }
示例#3
0
    void LateUpdate()
    {
        // Copy rigidbody positions to the line renderer
        LineRenderer renderer = GetComponent <LineRenderer>();

        // No interpolation
        //for (int i = 0; i < fragmentNum; i++)
        //{
        //    renderer.SetPosition(i, fragments[i].transform.position);
        //}

        int i;

        for (i = 0; i < fragmentNum; i++)
        {
            Vector3 position = fragments[i].transform.position;
            xPositions[i] = position.x;
            yPositions[i] = position.y;
            zPositions[i] = position.z;
        }

        for (i = 0; i < (fragmentNum - 1) * splineFactor + 1; i++)
        {
            renderer.SetPosition(i, new Vector3(
                                     splineX.GetValue(i / (float)splineFactor),
                                     splineY.GetValue(i / (float)splineFactor),
                                     splineZ.GetValue(i / (float)splineFactor)));
        }
    }
示例#4
0
    void DrawLines()
    {
        for (var i = 0; i < fragmentCount; i++)
        {
            var position = fragments[i].transform.position;
            xPositions[i] = position.x;
            yPositions[i] = position.y;
            zPositions[i] = position.z;
        }

        for (var i = 0; i < (fragmentCount - 1) * splineFactor + 1; i++)
        {
            lineRenderer.SetPosition(i, new Vector3(
                                         splineX.GetValue(i / (float)splineFactor),
                                         splineY.GetValue(i / (float)splineFactor),
                                         splineZ.GetValue(i / (float)splineFactor)));
        }
    }