Hi every one.
I have a mesh file in Rhino and just want to change the color of some specific mesh faces to red. First I tried to see what is the color of the mesh with:
foreach (Color color in mesh.VertexColors)
{
Debug.WriteLine(“Color is :”);
Debug.WriteLine(color);
}
It shows nothing as if the mesh is colorless. Then I tried to color the whole mesh with:
System.Drawing.Color colors = new System.Drawing.Color[mesh.Vertices.Count];
System.Drawing.Color colors = new System.Drawing.Color[mesh.Vertices.Count];
for (int i = 0; i < mesh.Vertices.Count; i++)
{
colors[i] = System.Drawing.Color.Red;
}
mesh.VertexColors.SetColors(colors);
And then again tried to see if the colors are set with:
foreach (Color color in mesh.VertexColors)
{
Debug.WriteLine(“Color is :”);
Debug.WriteLine(color);
}
It prints the red color at the console but the color of the mesh won’t change in the Render. What should I do to change the color in the render?
Now that you have asked me I saw that I have made an instance of the object into my mesh and add the color to that but since I didn’t want to create another object to my doc, I didn’t add the instance to doc.
Now I just added the mesh to doc and redraw it. The color is applied to the mesh but can not see it in render. How should I create a material?
Thank you for your reply, since I wanted to make a constrain from multiple parts for mouse click, I appended all the objects to a mesh and used the mesh as a constrain. So I didn’t need any feature from it. Now I want to change the color of some mesh faces so I think I should delete the original objects and add the created mesh to the doc. Right?