现在我正在使用 Viewport3D,我在其中绘制所有 3D 形状,但我还想在 Viewport3D 中绘制弧线、点和线。谁能帮我这个?
private Viewport2DVisual3D ArcModel;
private Model3DGroup group;
MeshGeometry3D testGeometry = new MeshGeometry3D();
PathFigure pthFigure = new PathFigure();
pthFigure.StartPoint = new Point(1, 1);
ArcSegment arcSeg = new ArcSegment();
arcSeg.Point = new Point(30, 30);
arcSeg.Size = new Size(20, 20);
arcSeg.IsLargeArc = true;
arcSeg.SweepDirection = SweepDirection.Counterclockwise;
//arcSeg.RotationAngle = 30;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(arcSeg);
pthFigure.Segments = myPathSegmentCollection;
PathFigureCollection pthFigureCollection = new PathFigureCollection();
pthFigureCollection.Add(pthFigure);
PathGeometry pthGeometry = new PathGeometry();
pthGeometry.Figures = pthFigureCollection;
Path arcPath = new Path();
arcPath.Stroke = new SolidColorBrush(Colors.Violet);
arcPath.StrokeThickness = 1;
arcPath.Data = pthGeometry;
//arcPath.Fill = new SolidColorBrush(Colors.Yellow);
//Children.Add(arcPath);
Point3DCollection myPoint3DCollection = new Point3DCollection();
myPoint3DCollection.Add(new Point3D(0, 0, 0));
myPoint3DCollection.Add(new Point3D(0, 0, 2));
myPoint3DCollection.Add(new Point3D(0, 2, 0));
myPoint3DCollection.Add(new Point3D(0, 2, 2));
testGeometry.Positions = myPoint3DCollection;
PointCollection myPointCollection = new PointCollection();
myPointCollection.Add(new Point(0, 1));
myPointCollection.Add(new Point(1, 1));
myPointCollection.Add(new Point(0, 0));
myPointCollection.Add(new Point(1, 0));
testGeometry.TextureCoordinates = myPointCollection;
Int32Collection triangleIndicesCollection = new Int32Collection();
triangleIndicesCollection.Add(0);
triangleIndicesCollection.Add(1);
triangleIndicesCollection.Add(2);
triangleIndicesCollection.Add(2);
triangleIndicesCollection.Add(1);
triangleIndicesCollection.Add(3);
testGeometry.TriangleIndices = triangleIndicesCollection;
DiffuseMaterial myDiffuseMaterial = new DiffuseMaterial(Brushes.White);
Viewport2DVisual3D.SetIsVisualHostMaterial(myDiffuseMaterial, true);
ArcModel = new Viewport2DVisual3D();
ArcModel.Material = myDiffuseMaterial;
ArcModel.Geometry = testGeometry;
//group.Children.Add(ArcModel.Geometry);
ArcModel.Visual = arcPath;
ArcGeomodel = new GeometryModel3D(ArcModel.Geometry, myDiffuseMaterial);
ArcGeomodel.Transform = new Transform3DGroup();
group.Children.Add(ArcGeomodel);
viewport.Children.Add(ArcModel);
我正在使用路径几何绘制这条弧线并将其添加到 Viewport2DVisual3D 中,但它没有显示出来......我在这里缺少什么......请提出任何解决方案