Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertex Normals #437

Closed
KonstruktivniyKritik opened this issue Aug 12, 2022 · 1 comment
Closed

Vertex Normals #437

KonstruktivniyKritik opened this issue Aug 12, 2022 · 1 comment

Comments

@KonstruktivniyKritik
Copy link

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?

@KonstruktivniyKritik
Copy link
Author

I found solution. Different ifc visualisation program read ifc files differently. Open Ifc Viewer dont whow vertex normals but XbimExplorer do it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant