Beispiel #1
0
    public static void paintSingleVertexOnHit(
        Transform transform,
        RaycastHit hit,
        Color color,
        float strength)
    {
        Vector3[] vertices      = ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().get_vertices();
        int[]     triangles     = ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().get_triangles();
        Color[]   colors        = ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().get_colors();
        int       triangleIndex = ((RaycastHit) ref hit).get_triangleIndex();
        float     num1          = float.PositiveInfinity;
        int       index1        = 0;

        for (int index2 = 0; index2 < 3; index2 += 3)
        {
            float num2 = Vector3.Distance(transform.TransformPoint(vertices[triangles[triangleIndex * 3 + index2]]), ((RaycastHit) ref hit).get_point());
            if ((double)num2 < (double)num1)
            {
                index1 = triangles[triangleIndex * 3 + index2];
                num1   = num2;
            }
        }
        Color color1 = VTP.VertexColorLerp(colors[index1], color, strength);

        colors[index1] = color1;
        ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().set_colors(colors);
    }
Beispiel #2
0
    public static void paintFaceVerticesOnHit(
        Transform transform,
        RaycastHit hit,
        Color color,
        float strength)
    {
        int[]   triangles     = ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().get_triangles();
        Color[] colors        = ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().get_colors();
        int     triangleIndex = ((RaycastHit) ref hit).get_triangleIndex();

        for (int index1 = 0; index1 < 3; ++index1)
        {
            int   index2 = triangles[triangleIndex * 3 + index1];
            Color color1 = VTP.VertexColorLerp(colors[index2], color, strength);
            colors[index2] = color1;
        }
        ((MeshFilter)((Component)transform).GetComponent <MeshFilter>()).get_sharedMesh().set_colors(colors);
    }