private void CreateGeometryRenderData(Color color, IRenderPackage package, TessellationParameters parameters) { package.RequiresPerVertexColoration = true; // As you add more data to the render package, you need // to keep track of the index where this coloration will // start from. geometry.Tessellate(package, parameters); TessellateEdges(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } if (package.PointVertexCount > 0) { package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } if (package.MeshVertexCount > 0) { package.ApplyMeshVertexColors(CreateColorByteArrayOfSize(package.MeshVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } }
public void Tessellate(IRenderPackage package, double tol = -1, int maxGridLines = 512) { package.RequiresPerVertexColoration = true; // As you add more data to the render package, you need // to keep track of the index where this coloration will // start from. geometry.Tessellate(package, tol, maxGridLines); if (renderEdges) { var surf = geometry as Surface; if (surf != null) { foreach (var curve in surf.PerimeterCurves()) { curve.Tessellate(package, tol, maxGridLines); curve.Dispose(); } } var solid = geometry as Solid; if (solid != null) { foreach (var geom in solid.Edges.Select(edge => edge.CurveGeometry)) { geom.Tessellate(package, tol, maxGridLines); geom.Dispose(); } } } if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } if (package.PointVertexCount > 0) { package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } if (package.MeshVertexCount > 0) { package.ApplyMeshVertexColors(CreateColorByteArrayOfSize(package.MeshVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } //var existingVerts = package.TriangleVertices; //var existingNormals = package.TriangleNormals; //var newVerts = new List<double>(); //for (var i = 0; i < existingVerts.Count; i += 3) //{ // newVerts.AddRange(NudgeVertexAlongVector(existingVerts, existingNormals, i, 0.001)); //} //package.TriangleVertices = newVerts; }
public void Tessellate(IRenderPackage package, TessellationParameters parameters) { package.RequiresPerVertexColoration = true; // As you add more data to the render package, you need // to keep track of the index where this coloration will // start from. geometry.Tessellate(package, parameters); if (parameters.ShowEdges) { var surf = geometry as Surface; if (surf != null) { foreach (var curve in surf.PerimeterCurves()) { curve.Tessellate(package, parameters); curve.Dispose(); } } var solid = geometry as Solid; if (solid != null) { foreach (var geom in solid.Edges.Select(edge => edge.CurveGeometry)) { geom.Tessellate(package, parameters); geom.Dispose(); } } } if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } if (package.PointVertexCount > 0) { package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } if (package.MeshVertexCount > 0) { package.ApplyMeshVertexColors(CreateColorByteArrayOfSize(package.MeshVertexCount, color.Red, color.Green, color.Blue, color.Alpha)); } }
public void Tessellate(IRenderPackage package, double tol = -1, int maxGridLines = 512) { package.RequiresPerVertexColoration = true; if (!Values.Any() || Values == null) { return; } var sw = new Stopwatch(); sw.Start(); DelaunayTesselate(Surface, package, 30, 30, ValueLocations); DebugTime(sw, "Ellapsed for tessellation."); var colorCount = 0; var uvCount = 0; var uvs = package.MeshTextureCoordinates.ToList(); var colors = package.MeshVertexColors.ToList(); var newColors = new byte[colors.Count]; for (var i = 0; i < colors.Count; i += 4) { var uvu = uvs[uvCount]; var uvv = uvs[uvCount + 1]; var uu = (int)(uvu * (COLOR_MAP_WIDTH - 1)); var vv = (int)(uvv * (COLOR_MAP_HEIGHT - 1)); var color = colorMap[uu, vv]; newColors[colorCount] = color.Red; newColors[colorCount + 1] = color.Green; newColors[colorCount + 2] = color.Blue; newColors[colorCount + 3] = color.Alpha; colorCount += 4; uvCount += 2; } package.ApplyMeshVertexColors(newColors); DebugTime(sw, "Ellapsed for setting colors on mesh."); sw.Stop(); }
public void Tessellate(IRenderPackage package, TessellationParameters parameters) { package.RequiresPerVertexColoration = true; Autodesk.DesignScript.Geometry.Geometry geometry = bbox.ToCuboid(); byte[] color = new byte[] { 0, 200, 200, 50 }; // As you add more data to the render package, you need // to keep track of the index where this coloration will // start from. geometry.Tessellate(package, parameters); if (package.MeshVertexCount > 0) { package.ApplyMeshVertexColors(CreateColorByteArrayOfSize(package.MeshVertexCount, color[0], color[1], color[2], color[3])); } geometry.Dispose(); }