Archicad C++ API
About Archicad add-on development using the C++ API.

Incorrect polygon winding order for Objects

drjustice
Newcomer
Has anyone ever noticed that quite a few objects from the library of objects in Archicad are made of parts with polygons with the wrong winding order?

In theory, front-facing polygons should have vertices in counter-clockwise order, but some objects seems to specify them in clockwise order.

I'm showing an example of a bathtub here (from the Hillside House found here:
https://helpcenter.graphisoft.com/knowledgebase/103415/ )

You can see in the archicad 3D view that there's some sort of shading discontinuity in the corners of the tub. And when I export these sections, the polygons are in the wrong winding order, which makes the viewer cull the polygons that I should see, and draws the polygons that should be hidden.

These objects are GDL objects, and procedurally defined (eg: sections made of panels, cylinders, etc) and to say that the GDL language is opaque would be an understatement.

Anyway, I really, really want to avoid making all objects in the scene double-sided geometry (eg: disable backface culling) as this would really kill performance.

If I could somehow detect which polygons are in the wrong winding order, I could simply reverse the vertex order and everything would be fine.

So far, I've detected this issue with the clock (digits and arrows), toilets (the base), the bathtub (corners), and a couple of others objects. Seems like every other object has such a problem -- don't have to search far to find such polygon ordering issues.

Any ideas how I can either detect and/or fix this at export time?

The classical way of detecting this is to check if shared edges (sharing two vertices) are in the same order (eg: poly #1 has an edge from vertex A-B, and the neighbor polygon should have an edge from B-A, but if both have a shared edge from A-B, then one of the two polys is in the wrong order. However, I still can't know which polygon has the incorrect order.

BTW I use the modeler API to parse the geometry
4 REPLIES 4
Viktor Kovacs
Graphisoft
Graphisoft
I don't think that there is a way to detect incorrect winding order. Generally if the model is solid than the winding order is set properly. I think that the best you can do is to use double-sided polygons for surface bodies. You can detect it by the IsSurfaceBody call on the MeshBody.
drjustice
Newcomer
Well, that worked, but not only did I have to duplicate all triangles, but also vertices, since I've had to invert the normals as well. Talk about yuck and doubling the weight of the geometry in the 3D engine...
Viktor Kovacs
Graphisoft
Graphisoft
You don't have to duplicate all triangles, just set your rendering engine to show them as double-sided. Usually all rendering engines has this capability.
drjustice
Newcomer
Yes, that is the first thing I tried but unfortunately the rendering engine I use has a bug which makes double-sided polygons not work property. So I had to hack it this way.

I guess I should have mentioned it..

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!