如何将MeshElement3D显示为线框? [英] How to display MeshElement3D as wireframe?

查看:257
本文介绍了如何将MeshElement3D显示为线框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示任何 MeshElement3D (例如BoxVisual3d)作为线框.如何做到这一点?

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

感谢Erno de Weerd的回答,我能够编写以下代码

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

  1. 扩展BoxVisual3D的类

  1. Class that extends BoxVisual3D

public class GeometryBoxVisual3D : BoxVisual3D
{

  public MeshGeometry3D Geometry()
  {
    return Tessellate();
  }
}

  • 将box的实例添加到视口:

  • 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);
    

  • 这将显示以下内容:

    如果隐藏原始框并将LinesVisual3D放置在框的顶部,则可以使wirefrime看起来像是原始对象,但仍然缺少侧面的边缘.

    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.

    推荐答案

    通过调用MeshElement3D.Tesselate(),您可以获得MeshGeometry3D(网格).

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

    接下来创建一个LinesVisual3D对象.

    将网格的点复制到LinesVisual3D的点.

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

    这将创建内部网格(请参见来源: Helix工具包中的LinesVisual3D.cs )

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

    最后,确保设置LinesVisual3D的厚度并将其添加到场景中.

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

    这篇关于如何将MeshElement3D显示为线框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆