0

Problem building mesh for BoxVisual3D

Anonymous 10 years ago 0
This discussion was imported from CodePlex

viettp wrote at 2011-12-18 19:27:

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.


objo wrote at 2011-12-19 09:27:

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.