XbimEssentials icon indicating copy to clipboard operation
XbimEssentials copied to clipboard

Vertex Normals

Open KonstutivniyKritik opened this issue 2 years ago • 0 comments

Hello. I work on file convertation to IFC format using xbim. From non converted format i get mesh consist of vertices, indices, vertex normals.

if(mesh.IsLoad)
    {
        //mesh.Triangles;   //indices array
        //mesh.Normals;     //vertex normals array
        //mesh.Vertices;    //vertices array
        //Convertating
        IfcConverter.ConvertToIFC(mesh);
    }

Non Converted model: gitask

I create IfcTriangulatedFaceSet by CoordList, CoordIndex, Normals

private static IfcTriangulatedFaceSet CreateTriangulatedFaceSet(IModel model, MeshGeom mesh)
        {
            return model.Instances.New<IfcTriangulatedFaceSet>(tfs =>
            {
                tfs.Closed = true;
                tfs.Coordinates = model.Instances.New<IfcCartesianPointList3D>(pl =>
                {
                    for (int i = 0; i < (mesh.Vertices.Length / 3); i++)
                        pl.CoordList.GetAt(i).AddRange(new IfcLengthMeasure[] { mesh.Vertices[3 * i], mesh.Vertices[3 * i + 1], mesh.Vertices[3 * i + 2] });
                });

                // Indices are 1 based in IFC!
                for (int i = 0; i < mesh.Triangles.Length / 3; i++)
                    tfs.CoordIndex.GetAt(i).AddRange(new IfcPositiveInteger[] { mesh.Triangles[3 * i] + 1, mesh.Triangles[3 * i + 1] + 1, mesh.Triangles[3 * i + 2] + 1 });

                for (int i = 0; i < mesh.Normals.Length / 3; i++)
                    tfs.Normals.GetAt(i).AddRange(new IfcParameterValue[] { mesh.Normals[3 * i], mesh.Normals[3 * i + 1], mesh.Normals[3 * i + 2] });

            });
        }

And get this non-smooth converted model: gitask2

What i need to do to get smooth surface?

KonstutivniyKritik avatar Aug 12 '22 08:08 KonstutivniyKritik