2

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>

Corentin Pane
  • 4,794
  • 1
  • 12
  • 29
vanlion
  • 111
  • 8

1 Answers1

0

pls check the definition of AddExtrudedGeometry, I changed the parameters then it can show the 3d model. I find there are something wired when I change the parameters. If you want to build an extrued model, pls see ExtrudedVisual3D(). that works fine.

        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);
John Li
  • 1
  • 1
  • 1
    Here we like to see the code :) Can you provide what is working for you? Also you might benefit from reading this guide "How to write a good answer" :https://stackoverflow.com/help/how-to-answer – Guillaume Raymond Jan 08 '20 at 09:16
  • @John, Thank You for the lines of code. I get the Extruded Visual, but the section is always open. How do i close the extruded object to be a solid rather than the side faces built by the extruded section lines? – DrMarbuse Apr 02 '22 at 16:10