Adding Mesh to RhinoDocument

Hello all,

I am trying to add a mesh generated from scretch in C# to a rhino Document. The generated Mesh has Normals and Face Normals set to the correct direction, however when I add it to Rhino Document, the displays shows me that some faces look in the correct direction, where as some faces look in the wrong direction (pink -> backface). Funny enough Vertex normals are displayed in the correct direction…

(see attached image, backward mesh is the mesh added to the rhino document, front mesh shows the vertex / face normals of the computed mesh before adding it to the document via GRasshopper. Black arrows are Vertex Normals, white arrows are Face Normals)

What happens when calling AddMesh command, why does that change face normal?

thx for the help

Hi @richard_schaffranek,

Can you provide some sample code so we can repeat what you are seeing here?

– Dale

Hello @Dale,

not really complex code, my guess is that it has something to do with face direction (a,b,c,d) vs (d,c,b,a) or maybe face-normal is not used for the computation / back-face display. Couldn’t you simply describe what is happening when adding the mesh, one would expect that it simply adds the mesh to the document but as I figured out with BREPS it runs e.g. splitKinkySurfaces before adding to the document. API Documentation is a bit cryptic:

Best

Richard

Hi @richard_schaffranek,

Before adding to the document, the mesh is validated - e.g. Mesh.IsValid. We then verify the mesh has vertex normals. There are also some additional validations for texture coordinates and ngons.

– Dale

If you are adding the mesh to Rhino using a .obj file then the face normal will not be contained in the .obj file which only supports vertex normal and textures (besides the vertices and faces). Could this be the problem? If so you can regenerate the face normals inside Rhino.

Regards,
Terry.

Hello @Dale,

okay so my mesh is valid, also with the more advanced checking options with string output.

But face normal of the mesh in grasshopper are different to face display in the rhino view-port. I have set my viewport so that it displays the back faces in pink.

So again question is what happens with those face normals when exporting to rhino document, or is it a question within the display pipline?

Best

Richard

Hello Terry,

no this is not the problem, Mesh is Valid and completly generated in Rhino.

There is a problem with the face normals, which I can’t really get. Either it is that:

  1. Face normals are recomputed when adding the mesh based on face orientation (a,b,c,d) or (d,c,b,a).
  2. Face normals are not used within display purpose and face direction is defined by face orientation (a,b,c,d) or (d,c,b,a)

However this seams to produce a problem when using commands like recompute normals, weld, … the resulting mesh is always ugly with adjacent faces looking in different direction.

My guess it is a problem with how I generate the mesh, but to find the problem I have to understand the “cause” of the display error…

Hi @richard_schaffranek,

We’re probably not going to get anywhere without a way to reproduce what you are seeing.

– Dale