【问题标题】:How to Redraw 3D content in WPF如何在 WPF 中重绘 3D 内容
【发布时间】:2013-08-12 16:05:46
【问题描述】:

所以我用http://3dtools.codeplex.com/提供的ScreenSpaceLines3D类绘制了一堆线条

我可以通过像这样定义它们来在我的视口中画线

Point3D point0 = new Point3D(0, 0, 0);    
Point3D point1 = new Point3D(5, 5, 0);    
Point3D point2 = new Point3D(5, 5.5, 0);

在button_click方法里面,基本上画了一堆像

ScreenSpaceLines3D wireframe = new ScreenSpaceLines3D();    
wireframe.Points.Add(point0);    
wireframe.Points.Add(point1);    
wireframe.Points.Add(point2);    
wireframe.Color = Colors.LightBlue;    
wireframe.Thickness = 5;    
this.mainViewport.Children.Add(wireframe);

我还添加了point1.Z += 2; 以查看每次点击后行的变化。

我只想看到同一组线条移动,但每次点击后都会绘制新的线条组。我只需要用一组更新的点刷新/重绘同一组。我尝试使用InvalidateVisual();InvalidateArrange();,但没有成功。

请指教!!

【问题讨论】:

    标签: wpf visual-studio-2010 c#-4.0 3d drawing


    【解决方案1】:

    没有无效功能。您必须清除 ScreenSpaceLine3d 点,然后更新这些点。

    public MainWindow()  
    {  
        ScreenSpaceLines3D wireframe = new ScreenSpaceLines3D();  
        wireframe.Color = Colors.LightBlue;  
        wireframe.Thickness = 5;   
        this.mainViewport.Children.Add(wireframe);  
    }
    
    public void CustomInvalidate( Point3DCollection point)  
    {  
        if (wireframe!= null)  
                {  
                    wireframe.Points.Clear();  
                }  
        wireframe.Points.Add(point[0]);    
        wireframe.Points.Add(point[1]);    
        wireframe.Points.Add(point[2]);  
    }
    

    【讨论】:

      猜你喜欢
      • 2011-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多