private void Awake()
    {
        if (!latk)
        {
            latk = GetComponent <LightningArtist>();
        }
        if (latk)
        {
            if (latkSettings == LatkSettings.COPY_TO_LATK)
            {
                latk.brushPrefab = brushPrefab;
                latk.mainColor   = color;
                latk.brushSize   = brushSize;
                latk.minDistance = minDistance;
                latk.strokeLife  = strokeLife;
            }
            else if (latkSettings == LatkSettings.COPY_FROM_LATK)
            {
                brushPrefab = latk.brushPrefab;
                color       = latk.mainColor;
                brushSize   = latk.brushSize;
                minDistance = latk.minDistance;
                strokeLife  = latk.strokeLife;
            }
        }

        updateTransformMatrix();
    }
    public LatkStroke makeLine(List <Vector3> points)
    {
        LatkStroke brush = makeLineCore(points[0], points[points.Count - 1]);

        strokes.Add(brush);
        return(brush);
    }
    public LatkStroke makeCurve(List <Vector3> points)
    {
        LatkStroke brush = makeCurveCore(points);

        strokes.Add(brush);
        return(brush);
    }
    public LatkStroke makeLine(Vector3 v1, Vector3 v2)
    {
        LatkStroke brush = makeLineCore(v1, v2);

        strokes.Add(brush);
        return(brush);
    }
    public LatkStroke makeEmpty()
    {
        LatkStroke brush = makeEmptyCore();

        strokes.Add(brush);
        return(brush);
    }
    // ~ ~ ~ ~ ~
    // II. LINE

    public LatkStroke makeLineCore(Vector3 v1, Vector3 v2)
    {
        LatkStroke brush = makeEmptyCore();

        brush.points.Add(v1);
        brush.points.Add(v2);
        return(brush);
    }
    public LatkStroke makeCurve(List <Vector3> points, bool selfDestruct, float lifeTime)
    {
        LatkStroke brush = makeCurveCore(points);

        brush.selfDestruct = selfDestruct;
        brush.lifeTime     = lifeTime;

        strokes.Add(brush);
        return(brush);
    }
    public LatkStroke makeLine(Vector3 v1, Vector3 v2, bool selfDestruct, float lifeTime)
    {
        LatkStroke brush = makeLineCore(v1, v2);

        brush.selfDestruct = selfDestruct;
        brush.lifeTime     = lifeTime;

        strokes.Add(brush);
        return(brush);
    }
    // ~ ~ ~ ~ ~
    // III. CURVE

    public LatkStroke makeCurveCore(List <Vector3> points)
    {
        LatkStroke brush = makeEmptyCore();

        if (minDistance > 0f)
        {
            points = filterMinDistance(points);
        }
        brush.points = points;
        return(brush);
    }
    public LatkStroke makeCurve(List <Vector3> points, bool closed)
    {
        if (closed && points.Count > 10)
        {
            points.Add(points[1]);
        }
        LatkStroke brush = makeCurveCore(points);


        strokes.Add(brush);
        return(brush);
    }
Beispiel #11
0
    public void makeMeshEdge()
    {
        List <Vector3> points = getVertices.getSource();

        Debug.Log(points.Count);
        LatkStroke b = makeCurve(points);

        //b.refine();
        for (int i = 0; i < smoothReps; i++)
        {
            //b.smoothStroke(b.points);
        }
        //b.reduceStroke(b.points);
        strokes.Add(b);
    }
    // ~ ~ ~ ~ ~
    // I. EMPTY

    public LatkStroke makeEmptyCore()
    {
        LatkStroke brush = Instantiate(brushPrefab);

        if (brushMat[(int)brushMode])
        {
            brush.mat = brushMat[(int)brushMode];
        }
        brush.transform.SetParent(transform);
        brush.brushColor   = color;
        brush.brushSize    = brushSize;
        brush.selfDestruct = checkSelfDestruct;
        brush.lifeTime     = strokeLife;

        return(brush);
    }
Beispiel #13
0
    public void makeMeshFill()
    {
        List <Vector3> points = getVertices.getSource();

        Debug.Log(points.Count);
        for (int h = 0; h < fillLines; h++)
        {
            Vector3    p1      = points[(int)Random.Range(0f, points.Count)];
            Vector3    p2      = points[(int)Random.Range(0f, points.Count)];
            Vector3    p3      = (p1 + p2) / 2f;
            Vector3[]  newLine = { p1, p2, p3 };
            LatkStroke b       = makeLine(newLine.ToList());
            b.refine();
            b.randomize(randomize);
            b.refine();
            for (int i = 0; i < smoothReps / 10; i++)
            {
                b.smoothStroke(b.points);
            }
            //b.reduceStroke(b.points);
            strokes.Add(b);
        }
    }