Beispiel #1
0
    void PaintVertexColor()
    {
        if (currMesh)
        {
            Vector3[] verts  = currMesh.vertices;
            Color[]   colors = new Color[0];
            if (currMesh.colors.Length > 0)
            {
                colors = currMesh.colors;
            }
            else
            {
                colors = new Color[verts.Length];
            }
            for (int i = 0; i < verts.Length; i++)
            {
                Vector3 vertPosition = currObj.transform.TransformPoint(verts[i]);
                float   sqrMag       = (vertPosition - hit.point).sqrMagnitude;
                if (sqrMag > brushSize)
                {
                    continue;
                }
                float falloff = PainterUtils.LinearFalloff(sqrMag, brushSize);
                falloff   = Mathf.Pow(falloff, brushFalloff * 3f) * brushOpacity;
                colors[i] = PainterUtils.VertexColorLerp(colors[i], foregroundColor, falloff);
            }

            currMesh.colors = colors;
        }
        else
        {
            Debug.LogWarning("No mesh available to paint");
        }
    }
Beispiel #2
0
    void Update()
    {
        if (canPaint)
        {
            Selection.activeGameObject = null;
            if (currObj != null && currMesh != null)
            {
            }
        }
        else
        {
            currMesh = null;
            currObj  = null;
        }

        if (hit.transform != null)
        {
            if (hit.transform.gameObject != lastObj)
            {
                currObj  = hit.transform.gameObject;
                currMesh = PainterUtils.GetMesh(currObj);
                lastObj  = currObj;
            }
        }
    }