Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么C#3D imgae笔刷在以编程方式应用于3D模型时无法工作?_C#_Wpf_3d_Brush - Fatal编程技术网

为什么C#3D imgae笔刷在以编程方式应用于3D模型时无法工作?

为什么C#3D imgae笔刷在以编程方式应用于3D模型时无法工作?,c#,wpf,3d,brush,C#,Wpf,3d,Brush,我有一个非常简单的C#方法,可以创建一个MeshGeometry3D元素并将其放置在模型中 3DGroup以编程方式: public static GeometryModel3D DrawElement(Model3DGroup group,string type, double x, double y) { MeshGeometry3D mesh = new MeshGeometry3D(); mesh.Posit

我有一个非常简单的C#方法,可以创建一个MeshGeometry3D元素并将其放置在模型中 3DGroup以编程方式:

  public static GeometryModel3D DrawElement(Model3DGroup group,string type, double x, double y)
          {
              MeshGeometry3D mesh = new MeshGeometry3D();
              mesh.Positions.Add(new Point3D(-0.5, -0.5, 0));
              mesh.Positions.Add(new Point3D(0.5, -0.5, 0));
              mesh.Positions.Add(new Point3D(0.5, 0.5, 0));
              mesh.Positions.Add(new Point3D(-0.5, 0.5, 0));

              mesh.TriangleIndices.Add(0);
              mesh.TriangleIndices.Add(1);
              mesh.TriangleIndices.Add(2);
              mesh.TriangleIndices.Add(2);
              mesh.TriangleIndices.Add(3);
              mesh.TriangleIndices.Add(0);                      


              if (type == "highlight")
              {                
                  ImageBrush imgBrush = new ImageBrush(new BitmapImage(new Uri(@"E:\2.jpg")));
                  element = new GeometryModel3D(mesh, new DiffuseMaterial(imgBrush));
              }

              element.Transform = new Transform3DGroup();
              group.Children.Add(element);
              return element;
          }
问题是,当我使用图像笔刷时,对象不会显示,就像它不可见一样,但当我使用这样的实心笔刷时,它工作得很好:

  element = new GeometryModel3D(mesh, new DiffuseMaterial(Brushes.Red));
我仔细检查后发现图像文件E:\2.jpg存在


你能帮帮我吗?

奇怪的检查,但试着反转斜杠
新Uri(@“E:/2.jpg”)
ie:@genu生气了,谢谢,但也没用。非常感谢。