1

I'm working on a WPF project that displays a 2D city area. I have 2D polygons that represent buildings.

In order to have a 3D view, I need to transform these buildings into 3D polygons, by "extruding" them from the base area. I chose Helix Toolkit, that seemed appropriate for what I want.

Thanks to the large documentation of Helix Toolkit and its helpful examples (that's irony), I tried to "extrude" or triangulate my base polygons to make them 3D.

But the only results I get are some pieces of triangle, or incomplete 3D polygon. There are so many ways to make the same thing in Helix Toolkit that I can't identify what I really need.

Here's what I get | Here's what I want

I'm currently working this way, and I know it's bad :

// Create a model group
var modelGroup = new Model3DGroup();

// Create an example polygon 
HelixToolkit.Wpf.Polygon test = new HelixToolkit.Wpf.Polygon();
test.Points.Add(new Point(0, 0));
test.Points.Add(new Point(3, 0));
test.Points.Add(new Point(2, 1));
test.Points.Add(new Point(1, 4));
test.Points.Add(new Point(-2, 1));
test.Points.Add(new Point(0, 0));

// Create a meshbuilder and add the Polygon to it
var meshBuilder = new MeshBuilder(false, false);
meshBuilder.AddPolygon(test.Points);

// Create a mesh from the builder (and freeze it)
var mesh = meshBuilder.ToMesh(true);

// Then I add it to my model group and set the binding property
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(2, 0, 0), Material = redMaterial, BackMaterial = insideMaterial });

this.Model = modelGroup;

I also created a method to create 3D points from my 2D data :

public void createEdges(HelixToolkit.Wpf.Polygon leP)
    {

        for (int i=0; i<= leP.Points.Count-2; i++)
        {
            Point3D p1Sol = new Point3D(leP.Points[i].X, leP.Points[i].Y, 0);
            Point3D p2Sol = new Point3D(leP.Points[i+1].X, leP.Points[i].Y, 0);
            Point3D p1Ciel = new Point3D(leP.Points[i].X, leP.Points[i].Y, 5);
            Point3D p2Ciel = new Point3D(leP.Points[i + 1].X, leP.Points[i].Y, 5);

            Faace laFace = new Faace();

            laFace.LesPoints.Add(p1Sol);
            laFace.LesPoints.Add(p1Ciel);
            laFace.LesPoints.Add(p2Ciel);
            laFace.LesPoints.Add(p2Sol);
            laFace.LesPoints.Add(p1Sol);


            lesFaces.Add(laFace);
        }


    }

This method gives the first screenshot I linked.

I spent so many time trying to understand the toolkit, but I'm strongly stuck and would appreciate some help. Is there a way to do it correctly ?

Hoping I've been sufficiently clear.

Thanks by advance,

Martin

0 Answers0