Ejemplo n.º 1
0
    static void Chevrons()
    {
        var curve = Selection.activeGameObject.GetComponent(typeof(ParametricCurve)) as ParametricCurve;

        if (curve == null)
        {
            return;
        }

        int count   = 100;
        var samples = new Vector3[count];

        curve.SampleValues(samples, 0f, 1f);

        var root = new GameObject().GetTransform();

        var head = Toolbelt.CreatePyramid();

        head.GetTransform().Rotate(90f, 0f, 0f);
        var mesh = head.GetFilter().FreezeTransformation();


        for (int i = 0; i < count; ++i)
        {
            var arrow = Toolbelt.CreatePrimitive("chevron");
            arrow.GetFilter().sharedMesh = mesh;
            var xform = arrow.GetTransform();

            xform.position   = samples[i];
            xform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            var u = i / (count - 1f);

            xform.rotation = Quaternion.LookRotation(curve.DerivAt(u).normalized);
            xform.parent   = root;
        }

        GameObject.DestroyImmediate(head);
    }