public virtual void DrawLine(PenX3D pen, IPolylineD3D path) { var asStraightLine = path as StraightLineAsPolylineD3D; if (null != asStraightLine) { DrawLine(pen, asStraightLine.GetPoint(0), asStraightLine.GetPoint(1)); return; } else if (path.Count == 2) { DrawLine(pen, path.GetPoint(0), path.GetPoint(1)); return; } //var line = new SolidPolyline(pen.CrossSection, asSweepPath.Points); var buffers = GetPositionNormalIndexedTriangleBuffer(pen.Material); var offset = buffers.IndexedTriangleBuffer.VertexCount; if (null != buffers.PositionNormalIndexedTriangleBuffer) { var buf = buffers.PositionNormalIndexedTriangleBuffer; var solidPolyline = new SolidPolyline(); solidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z), (i0, i1, i2, isLeftCos) => buf.AddTriangleIndices(i0, i1, i2, isLeftCos), ref offset, pen, path.Points); } else if (null != buffers.PositionNormalColorIndexedTriangleBuffer) { var buf = buffers.PositionNormalColorIndexedTriangleBuffer; var color = pen.Color.Color; var r = color.ScR; var g = color.ScG; var b = color.ScB; var a = color.ScA; var solidPolyline = new SolidPolyline(); solidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z, r, g, b, a), (i0, i1, i2, isLeftCos) => buf.AddTriangleIndices(i0, i1, i2, isLeftCos), ref offset, pen, path.Points); } else if (null != buffers.PositionNormalUVIndexedTriangleBuffer) { throw new NotImplementedException("Texture on a line is not supported yet"); } else { throw new NotImplementedException("Unexpected type of buffer: " + buffers.IndexedTriangleBuffer.GetType().ToString()); } return; }
public static void DrawLine(PositionNormalIndexedTriangleBuffers buffers, PenX3D pen, PointD3D p0, PointD3D p1) { var vertexIndexOffset = buffers.IndexedTriangleBuffer.VertexCount; if (null != buffers.PositionNormalIndexedTriangleBuffer) { var buf = buffers.PositionNormalIndexedTriangleBuffer; /* if (pen.Color.Name == "Beige") { */ var solid = new SolidStraightLine(); solid.AddGeometry( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z), (i0, i1, i2, isLeft) => buf.AddTriangleIndices(i0, i1, i2, isLeft), ref vertexIndexOffset, pen, new LineD3D(p0, p1)); /* } else { var polylinePoints = new[] { p0, p1 }; SolidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z), (i0, i1, i2) => buf.AddTriangleIndices(i0, i1, i2), ref vertexIndexOffset, pen, polylinePoints); } */ } else if (null != buffers.PositionNormalColorIndexedTriangleBuffer) { var polylinePoints = new[] { p0, p1 }; var buf = buffers.PositionNormalColorIndexedTriangleBuffer; var color = pen.Color.Color; var r = color.ScR; var g = color.ScG; var b = color.ScB; var a = color.ScA; var solidPolyline = new SolidPolyline(); solidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z, r, g, b, a), (i0, i1, i2, isLeftCOS) => buf.AddTriangleIndices(i0, i1, i2, isLeftCOS), ref vertexIndexOffset, pen, polylinePoints); } else if (null != buffers.PositionNormalUVIndexedTriangleBuffer) { throw new NotImplementedException("Texture on a line is not supported yet"); } else { throw new NotImplementedException("Unexpected type of buffer: " + buffers.IndexedTriangleBuffer.GetType().ToString()); } }
public virtual void DrawLine(PenX3D pen, IPolylineD3D path) { var asStraightLine = path as StraightLineAsPolylineD3D; if (null != asStraightLine) { DrawLine(pen, asStraightLine.GetPoint(0), asStraightLine.GetPoint(1)); return; } else if (path.Count == 2) { DrawLine(pen, path.GetPoint(0), path.GetPoint(1)); return; } //var line = new SolidPolyline(pen.CrossSection, asSweepPath.Points); var buffers = GetPositionNormalIndexedTriangleBuffer(pen.Material); var offset = buffers.IndexedTriangleBuffer.VertexCount; if (null != buffers.PositionNormalIndexedTriangleBuffer) { var buf = buffers.PositionNormalIndexedTriangleBuffer; var solidPolyline = new SolidPolyline(); solidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z), (i0, i1, i2, isLeftCos) => buf.AddTriangleIndices(i0, i1, i2, isLeftCos), ref offset, pen, path.Points); } else if (null != buffers.PositionNormalColorIndexedTriangleBuffer) { var buf = buffers.PositionNormalColorIndexedTriangleBuffer; var color = pen.Color.Color; var r = color.ScR; var g = color.ScG; var b = color.ScB; var a = color.ScA; var solidPolyline = new SolidPolyline(); solidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z, r, g, b, a), (i0, i1, i2, isLeftCos) => buf.AddTriangleIndices(i0, i1, i2, isLeftCos), ref offset, pen, path.Points); } else if (null != buffers.PositionNormalUVIndexedTriangleBuffer) { throw new NotImplementedException("Texture on a line is not supported yet"); } else { throw new NotImplementedException("Unexpected type of buffer: " + buffers.IndexedTriangleBuffer.GetType().ToString()); } return; }
public static void DrawLine(PositionNormalIndexedTriangleBuffers buffers, PenX3D pen, PointD3D p0, PointD3D p1) { var vertexIndexOffset = buffers.IndexedTriangleBuffer.VertexCount; if (null != buffers.PositionNormalIndexedTriangleBuffer) { var buf = buffers.PositionNormalIndexedTriangleBuffer; /* * if (pen.Color.Name == "Beige") * { */ var solid = new SolidStraightLine(); solid.AddGeometry( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z), (i0, i1, i2, isLeft) => buf.AddTriangleIndices(i0, i1, i2, isLeft), ref vertexIndexOffset, pen, new LineD3D(p0, p1)); /* * } * else * { * var polylinePoints = new[] { p0, p1 }; * SolidPolyline.AddWithNormals( * (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z), * (i0, i1, i2) => buf.AddTriangleIndices(i0, i1, i2), * ref vertexIndexOffset, * pen, * polylinePoints); * } */ } else if (null != buffers.PositionNormalColorIndexedTriangleBuffer) { var polylinePoints = new[] { p0, p1 }; var buf = buffers.PositionNormalColorIndexedTriangleBuffer; var color = pen.Color.Color; var r = color.ScR; var g = color.ScG; var b = color.ScB; var a = color.ScA; var solidPolyline = new SolidPolyline(); solidPolyline.AddWithNormals( (position, normal) => buf.AddTriangleVertex(position.X, position.Y, position.Z, normal.X, normal.Y, normal.Z, r, g, b, a), (i0, i1, i2, isLeftCOS) => buf.AddTriangleIndices(i0, i1, i2, isLeftCOS), ref vertexIndexOffset, pen, polylinePoints); } else if (null != buffers.PositionNormalUVIndexedTriangleBuffer) { throw new NotImplementedException("Texture on a line is not supported yet"); } else { throw new NotImplementedException("Unexpected type of buffer: " + buffers.IndexedTriangleBuffer.GetType().ToString()); } }