Beispiel #1
0
    public void ColorBy(string fieldname, VtkColorType type)
    {
        colorFieldName = fieldname;
        colorDataType  = type;

        if (colorFieldName != "")
        {
            triangleFilter.Update();
            Kitware.VTK.vtkPolyData pd = triangleFilter.GetOutput();

            if (colorDataType == VtkColorType.POINT_DATA)
            {
                colorArray = pd.GetPointData().GetScalars(colorFieldName);
            }
            else if (colorDataType == VtkColorType.CELL_DATA)
            {
                colorArray = pd.GetCellData().GetScalars(colorFieldName);
            }

            go.GetComponent <Renderer>().materials = new Material[2] {
                new Material(Shader.Find("UFZ/Vertex Color Front")),
                new Material(Shader.Find("UFZ/Vertex Color Back"))
            };
        }
        else
        {
            colorArray = null;
            mat        = new Material(Shader.Find("Diffuse"));
            mat.color  = Color.magenta;
            go.GetComponent <Renderer>().material = mat;
            Debug.Log("Color array " + fieldname + " not found!");
        }
    }