private void CreateColorMapOnSurface(Color[][] colorMap, IRenderPackage package, TessellationParameters parameters) { const byte gray = 80; geometry.Tessellate(package, parameters); var colorBytes = new List <byte>(); foreach (var colorArr in colorMap) { foreach (var c in colorArr) { colorBytes.Add(c.Blue); colorBytes.Add(c.Green); colorBytes.Add(c.Red); colorBytes.Add(c.Alpha); } } package.SetColors(colorBytes.ToArray()); package.ColorsStride = colorMap.First().Length * 4; TessellateEdges(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, gray, gray, gray, 255)); } }
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 new void Tessellate(IRenderPackage package, TessellationParameters parameters) { //Ensure that the object is still alive if (!IsAlive) { return; } //Location Point DB.LocationPoint locPoint = InternalElement.Location as DB.LocationPoint; GeometryPrimitiveConverter.ToPoint(InternalTransform.OfPoint(locPoint.Point)).Tessellate(package, parameters); package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, 255, 0, 0, 0)); //Boundaries foreach (DB.BoundarySegment segment in InternalBoundarySegments) { Curve crv = RevitToProtoCurve.ToProtoType(segment.GetCurve().CreateTransformed(InternalTransform)); crv.Tessellate(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, 255, 0, 0, 0)); } } }
public new void Tessellate(IRenderPackage package, TessellationParameters parameters) { using (var crv = GetDynCurve()) { crv.Tessellate(package, parameters); package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA)); } }
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 new void Tessellate(IRenderPackage package, TessellationParameters parameters) { // Offset for text adjustments double horizontalOffset = 0; // Get Conversion factor according to the documents units double factor = Revit.GeometryConversion.UnitConverter.DynamoToHostFactor(UnitType.UT_Length); // Get Text outline path at 0,0 PathGeometry path = CreateText(this.Value, this.Bold, this.Italic, new FontFamily(this.FontFamilyName), this.FontSize * Scale / factor, new System.Windows.Point(0, 0)); // Apply horizontal Text offset if (Alignment == HorizontalTextAlignment.Center) { horizontalOffset = path.Bounds.Width / 2; } if (Alignment == HorizontalTextAlignment.Right) { horizontalOffset = path.Bounds.Width; } // Walk thorugh all figures and draw lines foreach (PathFigure figure in path.Figures) { // Rotate the start point and apply offsets var startPoint = RotatePoint(new System.Windows.Point(figure.StartPoint.X - horizontalOffset, figure.StartPoint.Y * -1), this.Rotation); package.AddLineStripVertex(startPoint.X + Location.X, startPoint.Y + Location.Y, this.Location.Z); foreach (PathSegment segment in figure.Segments) { if (segment is System.Windows.Media.PolyLineSegment) { System.Windows.Media.PolyLineSegment pline = segment as System.Windows.Media.PolyLineSegment; for (int i = 0; i < pline.Points.Count; i++) { System.Windows.Point point = pline.Points[i]; // rotate point and apply offsets var pLinePoint = RotatePoint(new System.Windows.Point(point.X - horizontalOffset, point.Y * -1), this.Rotation); package.AddLineStripVertex(pLinePoint.X + Location.X, pLinePoint.Y + Location.Y, this.Location.Z); // send the same point again to continue drawing if (i < pline.Points.Count - 1) { package.AddLineStripVertex(pLinePoint.X + Location.X, pLinePoint.Y + Location.Y, this.Location.Z); } } } } } if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA)); } }
public new void Tessellate(IRenderPackage package, TessellationParameters parameters) { //Ensure that the object is still alive if (!IsAlive) { return; } this.Curve.Tessellate(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA)); } }
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, 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)); } }
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)); } }
private void CreateColorMapOnSurface(Color[][] colorMap , IRenderPackage package, TessellationParameters parameters) { const byte gray = 80; geometry.Tessellate(package, parameters); var colorBytes = new List<byte>(); foreach (var colorArr in colorMap) { foreach (var c in colorArr) { colorBytes.Add(c.Blue); colorBytes.Add(c.Green); colorBytes.Add(c.Red); colorBytes.Add(c.Alpha); } } package.SetColors(colorBytes.ToArray()); package.ColorsStride = colorMap.First().Length * 4; TessellateEdges(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, gray, gray, gray, 255)); } }
public new void Tessellate(IRenderPackage package, TessellationParameters parameters) { //Ensure that the object is still alive if (!IsAlive) return; //Location Point DB.LocationPoint locPoint = InternalElement.Location as DB.LocationPoint; GeometryPrimitiveConverter.ToPoint(InternalTransform.OfPoint(locPoint.Point)).Tessellate(package, parameters); package.ApplyPointVertexColors(CreateColorByteArrayOfSize(package.PointVertexCount, 255, 0, 0, 0)); //Boundaries foreach (DB.BoundarySegment segment in InternalBoundarySegments) { Curve crv = RevitToProtoCurve.ToProtoType(segment.GetCurve().CreateTransformed(InternalTransform)); crv.Tessellate(package, parameters); if (package.LineVertexCount > 0) { package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, 255, 0, 0, 0)); } } }
public new void Tessellate(IRenderPackage package, TessellationParameters parameters) { this.Curve.Tessellate(package, parameters); package.ApplyLineVertexColors(CreateColorByteArrayOfSize(package.LineVertexCount, DefR, DefG, DefB, DefA)); }