Exemple #1
0
    private void LateUpdate()
    {
        for (int i = 0, j = 0; i < cpts.Count; i += 3, j++)
        {
            int offset = 0;
            if (i / 4 > 0)
            {
                offset = 1;
            }

            int     curveIndex = i == 0 ? 0 : (i - 1) / 3;
            Vector3 p1         = cpts[i + 1 - offset].transform.position;
            Vector3 p2         = cpts[i + 2 - offset].transform.position;
            Vector3 p3         = cpts[i + 3 - offset].transform.position;
            Vector3 p0         = Vector3.zero;
            if (i == 0)
            {
                p0 = cpts[i].transform.position;
                i++;
            }
            else
            {
                p0 = cpts[i - offset].transform.position;
            }
            curves[j] = new burningmime.curves.CubicBezier(p0, p1, p2, p3);
        }
        DrawMutiCurve();
    }
Exemple #2
0
    void DrawCurve(int c_numSamples, burningmime.curves.CubicBezier bezier, int index)
    {
        List <Vector3> drawpoint = new List <Vector3>();

        for (int i = 0; i < c_numSamples; ++i)
        {
            float percent = ((float)i) / (c_numSamples - 1);

            Vector3 drawpts = new Vector3();
            //drawpts = Hermitefunc(A, B, C, D, t);
            drawpts = bezier.Sample(percent);
            drawpoint.Add(drawpts);
            pts.Add(drawpts);
            dpts.Add(bezier.Tangent(percent));
            if (arcLen.Count == 0)
            {
                arcLen.Add(0);
            }
            else
            {
                arcLen.Add(arcLen[arcLen.Count - 1] + Vector3.Distance(pts[pts.Count - 1], pts[pts.Count - 2]));
            }
        }
        LineRenderer lineRenderer;

        if (line[index].GetComponent <LineRenderer>() == null)
        {
            line[index].AddComponent <LineRenderer>();
        }
        lineRenderer          = line[index].GetComponent <LineRenderer>();
        lineRenderer.material = new Material(Shader.Find("Standard"));
        lineRenderer.sharedMaterial.SetColor("_Color", Color.red);
        lineRenderer.positionCount = drawpoint.Count;
        lineRenderer.SetPositions(drawpoint.ToArray());
    }
                static bool Equals(BMCurves.CubicBezier a, OPCurves.CubicBezier b)
                {
                    var r0 = math.all(aprox(a.p0, b.p0));
                    var r1 = math.all(aprox(a.p1, b.p1));
                    var r2 = math.all(aprox(a.p2, b.p2));
                    var r3 = math.all(aprox(a.p3, b.p3));

                    return(math.all(aprox(a.p0, b.p0)) &&
                           math.all(aprox(a.p1, b.p1)) &&
                           math.all(aprox(a.p2, b.p2)) &&
                           math.all(aprox(a.p3, b.p3)));
                }
Exemple #4
0
    public void AddCurve()
    {
        burningmime.curves.CubicBezier last = curves[curves.Count - 1];
        Vector3 dir = last.p3 - last.p2;

        dir *= 2;
        Vector3 p0 = last.p3 + dir;
        Vector3 p1 = last.p3 + dir * 1.5f;
        Vector3 p2 = last.p3 + dir * 2.25f;
        Vector3 p3 = last.p3 + dir * 3f;

        curves.Add(new burningmime.curves.CubicBezier(p0, p1, p2, p3));
        createControlObj();
    }