Beispiel #1
0
    public void AddColor(Mesh mesh, List <float> errors, List <int> surfaceIndices, int[] surfaceValues)
    {
        float[] errorsArray = errors.ToArray();
        float   maxError    = Mathf.Max(errorsArray);
        float   minError    = Mathf.Min(errorsArray);

        Vector3[] vertices = mesh.vertices;
        Color[]   colors   = new Color[vertices.Length];
        float     interval = (maxError - minError) / (ColorCode.colorCode.Length - 1);

        for (int i = 0; i < surfaceIndices.Count; i++)
        {
            int vertexIndex = surfaceValues[surfaceIndices[i]];
            colors[vertexIndex] = ColorCode.CalculateColor(errors[i], minError, interval);
        }

        mesh.colors = colors;
    }