I try to make a custom shape by a list of points so you can view this in WPF and the use of the HelixToolKit
. To make a start I try to make a simple cube, see code below. But nothing is shown in the WPF form. What is wrong about the code?
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>