I’m working in C# with Rhino.Net SDK building commands for a plug-in.
I’m trying to color mesh faces by coloring the face vertices.
This sample code attempts to draw a simple three face mesh with the “middle” face in red orange and the other two in green. The three face mesh appears fine, but the faces have no color:
On3dmObjectAttributes obatts = new On3dmObjectAttributes();
obatts.SetColorSource(IOn.object_color_source.color_from_object);
rusted = OnColor.FromColor(Color.OrangeRed);
OnMesh threeFaceMesh = new OnMesh(3, 12, false, false);
for (int ii = 0; ii < 12; ii++) xw = threeFaceMesh.SetVertex(ii, vertx[ii]);
for (int ii = 0; ii < 12; ii++) threeFaceMesh.m_C[ii] = OnColor.FromColor(Color.Green);
threeFaceMesh.m_C[2] = rusted;
threeFaceMesh.m_C[3] = rusted;
threeFaceMesh.m_C[5] = rusted;
threeFaceMesh.m_C[4] = rusted;
threeFaceMesh.SetQuad(0, 0, 1, 3, 2);
threeFaceMesh.SetQuad(1, 2, 3, 6, 7);
threeFaceMesh.SetQuad(2, 9, 8, 5, 4);
context.m_doc.AddMeshObject(threeFaceMesh, obatts);
context.m_doc.Redraw();
Any hints?
Thank you,
Peter Schwenn
by the way, the vertices are from a preamble
On3dPoint[] vertx = new On3dPoint[12];
vertx[0] = new On3dPoint(0,0,0);
vertx[1] = new On3dPoint(0,1,0);
vertx[2] = new On3dPoint(1,0,0);
vertx[3] = new On3dPoint(1,1,0);
vertx[4] = new On3dPoint(1,0,1);
vertx[5] = new On3dPoint(1,1,1);
vertx[6] = new On3dPoint(2,1,0);
vertx[7] = new On3dPoint(2,0,0);
vertx[8] = new On3dPoint(1,1,.001);
vertx[9] = new On3dPoint(1,0,.001);
vertx[10] = new On3dPoint(1,0,0);
vertx[11] = new On3dPoint(1,1,0);