Problem building mesh for BoxVisual3D

Dec 18, 2011 at 6:27 PM
Edited Dec 19, 2011 at 2:27 AM

Hi,

I'm trying to add edges to a BoxVisual3D by building a new class ShapeBox that inherit BoxVisual3D

In ShapeBox.Tessellate( ), I write like this:

 

        protected override MeshGeometry3D Tessellate()
        {
            var mesh = base.Tessellate();

            MeshBuilder builder = new MeshBuilder();
            
            List<Point3D> pts = new List<Point3D>();

            // some code lines to add points to pts

            // create an edges array
            int[] edges = { 0, 1, 1, 2, 2, 3, 3, 0, 
                            4, 5, 5, 6, 6, 7, 7, 4, 
                            0, 4, 1, 5, 2, 6, 3, 7 };

            builder.AddEdges(pts, new List<int>(edges), 0.04, 5);

            builder.Append(mesh); //exception comes from this

            return builder.ToMesh();
        }

 

The problem is mesh.Normal is null (also does the mesh.TextureCoordinates), because builder.AddCubeFace( ) in BoxVisual3D.Tessellate( ) does not construct those fields.

So I think AddCubeFace( ) should construct those fields.

Coordinator
Dec 19, 2011 at 8:27 AM

I will have a look at this later. Check the constructor arguments of the MeshBuilder - you can specify if normals should be generated or not - there might be a bug in the MeshBuilder.AddEdges method. It should not be neccessary to add normals to the mesh.