I’m working on a ZeroTouch node library which generates custom objects. Those objects have their own Tessellate
method implemented, where I usually draw the polygons and line previews myself. So far so good.
In a recent example I wanted to reuse the existing .Tessellate()
method which any Dynamo geometry type supports (in this case it’s a Surface
). That also works, the preview shows fine. What I would like to do however is to change the color of the output to a custom one.
This is the method at the moment:
[R.IsVisibleInDynamoLibrary(false)]
public void Tessellate(I.IRenderPackage package, I.TessellationParameters parameters)
{
Color col = new Color();
parameters.Tolerance = 0.1;
parameters.MaxTessellationDivisions = 8;
this.Patch().Tessellate(package, parameters);
for (int i = 0; i < package.MeshVertexCount; i++)
{
package.AddTriangleVertexColor(col.R, col.G, col.B, col.A);
}
if (parameters.ShowEdges)
{
this.PerimeterCurve().Tessellate(package, parameters);
}
}
However, it provides random results, as by calling package.AddTriangleVertexColor()
I indeed only append color definitions instead of replacing the ones already in there, which were created by calling .Tessellate(package, parameters)
earlier.
How can I completely replace the color array?
(note that in the code example, Color
is a custom class, and PerimeterCurve()
and Patch()
are custom functions. They should be irrelevant here, they just provide a Surface and a Curve, and the Color is a dictionary providing the bytes)