AddPolygon wrong number of normals

Jan 30, 2012 at 5:07 AM

Hi 

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++)
                {
                    vrt.Add(
                     new Point3D
                    (
                        
                          (double)set[i].X,
                        (double)set[i].Y,
                        (double)set[i].Z
                    ));

                }

                var surface = new MeshBuilder();
                surface.AddPolygon(vrt);
                
                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

Murray

Jan 30, 2012 at 8:41 AM

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 

Jan 31, 2012 at 9:07 AM

Thanks for the quick reply Objo

That fixed the error I was getting.

Great work!

Jan 31, 2012 at 9:34 AM

Objo

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?

Regards

Murray

Jan 31, 2012 at 10:01 AM

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