Get mesh color from a colored mesh c# dotnet


#1

I have a colored mesh from ladybug. now I want to read color from each face and assign same color to face of another mesh.

in short I need, get color and set color method for mesh vertex and faces.

I am creating c# dot net plugin. Please help.


(Menno Deij - van Rijswijk) #2

In Rhino, it is only possible to set vertex colors; face colors are interpolated from vertex colors.

Mesh m = new Mesh();
List<Point3d> vertices; // from your ladybug mesh
List<Color> vertexColors; // from your ladybug mesh

// resize the vertices and vertexcolors lists 
m.Vertices.Count = vertices.Count; 
m.VertexColors.Count = vertices.Count;

// set the vertex locations and colors
for(int i = 0; i < vertices.Count; ++i)
{
    m.Vertices[i] = vertices[i];
    m.VertexColors[i] = vertexColors[i];
}