AddPolygon wrong number of normals

Anonymous 9 years ago 0
This discussion was imported from CodePlex

murray_b wrote at 2012-01-30 05:07:


I am trying to display a mesh created from a polygon.

But when I run the toMesh I am getting the message "Wrong number of normals" And I am not sure what that message is referring to.


List<Point3D> vrt = new List<Point3D>();
                // Create a list of Points
                for (int i = 0; i < set.Count(); i++)
                     new Point3D


                var surface = new MeshBuilder();
                var mesh = surface.ToMesh();

Any help will be greatly appreciated. I am very new to WPF 3D and am finding the learning curve quite steep.

Thanks a lot


objo wrote at 2012-01-30 08:41:

hi Murray, 

I see this can be a bit confusing, it should be improved..

The parameterless MeshBuilder constructor will create a mesh with both normals and texture coordinates. The AddPolygon will currently only add vertices, not normals and texture coordinates.

I think changing the constructor to

new MeshBuilder(false,false)

should work.

I think there are two possible improvements here

a. Let AddPolygon calculate normals and texture coordinates if this is requested

b. Remove the parameterless constructor of MeshBuilder - so you _have to_ specify if normals/texture coordinates should be generated 

murray_b wrote at 2012-01-31 09:07:

Thanks for the quick reply Objo

That fixed the error I was getting.

Great work!

murray_b wrote at 2012-01-31 09:34:


When the meshbuilder now creates the mesh I can only see it from one side.

How do I get the meshbuilder to generate a mesh that I can rotate around and see from both sides?



objo wrote at 2012-01-31 10:01:

Remember to set the BackMaterial, it can be the same as the (front) Material.