繁体   English   中英

如何在 WPF 中使用 Helix 工具包 MeshBuilder 创建挤压几何?

[英]How to create an extruded geometry using Helix toolkit MeshBuilder in WPF?

我尝试通过点列表制作自定义形状,以便您可以在 WPF 中查看它并使用HelixToolKit 首先,我尝试制作一个简单的立方体,请参阅下面的代码。 但是 WPF 表单中没有显示任何内容。 代码有什么问题?

MeshBuilder builder = new MeshBuilder();
// points
IList<Point> points = new List<Point>();
points.Add(new Point(0, 0));
points.Add(new Point(0, 100));
points.Add(new Point(100, 100));
points.Add(new Point(100, 0));

Vector3D extrusionVector = new Vector3D(0, 0, 1);
Point3D p0 = new Point3D(0, 0, 0);
Point3D p1 = new Point3D(0, 0, 1);

builder.AddExtrudedGeometry(points, extrusionVector, p0, p1);

GeometryModel3D geomModel = new GeometryModel3D { Geometry = builder.ToMesh(), Material = Materials.Red, BackMaterial = Materials.Gray };
ModelVisual3D cube = new ModelVisual3D();
cube.Content = geomModel;
viewPort3d.Children.Add(cube);
<Window x:Class="HelixWpfAppOne.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:helix="http://helix-toolkit.org/wpf"
    xmlns:local="clr-namespace:HelixWpfAppOne"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
<Grid>
    <helix:HelixViewport3D x:Name="viewPort3d" ZoomExtentsWhenLoaded="true" Grid.RowSpan="2" >
        <!-- Remember to add light to the scene -->
        <helix:DefaultLights/>
        <helix:GridLinesVisual3D Width="200" Length="200" Thickness="0.1" MinorDistance="5" MajorDistance="10" Fill="#FFB2B2B2"/>
    </helix:HelixViewport3D>

</Grid>

请检查 AddExtrudedGeometry 的定义,我更改了参数,然后它可以显示 3d 模型。 当我更改参数时,我发现有一些连接。 如果您想构建一个挤压模型,请参阅 ExtrudedVisual3D()。 这工作正常。

        var render = new ExtrudedVisual3D();
        render.Section = contour;
        render.Path.Add(new Point3D(0, 0, 0));
        render.Path.Add(new Point3D(0, 0, bimWall.Thickness));
        render.SectionXAxis = axis;
        render.Fill = Brushes.WhiteSmoke;
        render.IsPathClosed = true;
        render.IsSectionClosed = true;                                     
        var wallModel = new ModelVisual3D();   
        wallModel.Children.Add(render);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM