How to display MeshElement3D as wireframe?

梦想的初衷 提交于 2019-12-07 02:23:54

问题


I would like to display any MeshElement3D (for example BoxVisual3d) in helix-toolkit as wireframe. How can this be accomplished?

EDIT:

Thanks to Erno de Weerd's answer I was able to write the following code

  1. Class that extends BoxVisual3D

    public class GeometryBoxVisual3D : BoxVisual3D
    {
    
      public MeshGeometry3D Geometry()
      {
        return Tessellate();
      }
    }
    
  2. Add the instance of box to the Viewport:

        GeometryBoxVisual3D box = new GeometryBoxVisual3D();
        box.Fill = new SolidColorBrush(Colors.Red);
        Viewport3D.Children.Add(box);
        MeshGeometry3D geometry3 = box.Geometry();
        LinesVisual3D lines = new LinesVisual3D();
        lines.Thickness = 3;
        lines.Points = geometry3.Positions;
        lines.Transform = new TranslateTransform3D(3,1,1);
        Viewport3D.Children.Add(lines);
    

This results in the following display:

If I hide the original box and place LinesVisual3D on top of the box, I can get the wirefrime displayed as if it was original object, but it is still missing the edges on the side.


回答1:


By calling MeshElement3D.Tesselate() you can get the MeshGeometry3D (mesh).

Next create a LinesVisual3D object.

Copy the Points of the mesh to the Points of the LinesVisual3D.

This will create the internal mesh (see the sources: LinesVisual3D.cs in helix toolkit)

Finally, make sure you set the thickness of the LinesVisual3D and add it to the scene.



来源:https://stackoverflow.com/questions/28596130/how-to-display-meshelement3d-as-wireframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!