I have been working with creating a converter for OpenFlight models for sometime. I know its not the model of choice for those outside of the military arena. However, I was hoping for some help. OpenFlight models can have nested polygons or subface in them.

Description  from MultiGen:

Nested polygon: A nested polygon (or subface) is a bead describing a face that lies

within, and is drawn on top of, another “super” polygon. Nested faces can them-

selves be nested. This construct is used to determine z buffer priority.

As I am parsing through the flt file I can tell which faces are subfaces so I am trying to apply the appropriate code to jMonkey.

Here is what I have:


            renderer.setPolygonOffset(-10.0f, -40.0f);







Now I have a problem with setting the zbuffer here and I'm not sure the polygonOffest is even having any effect.

There is a moire pattern that shows up where the subfaces are. Such as the doors of the bus and the wheel well of the jeep. Setting the zBuffer setEnabled to false works for some models but not others. The bus looks fine but the jeep sets the subfaces to the front.

Any suggestions as to the proper way to code for nested polygons?

ahhh multigen - that brings back memories of the days I had a small fortune worth of SGI-Onyx Infinite Reality kit sat under my desk  :slight_smile:

Sorry I have nothing else to add - just got caught up in a wave of nostalgia  :smiley:

Some ideas (nothing guaranteed):
1. Sort the polygons, so that nested polygons triangles are at the start of the mesh. They will be drawn first, and if CF_LESS is set, then triangles drawn later wont affect the area of the nested polygon

2. Sort the polygons, so that nested polygons are at the end of mesh data, use CF_LEQUAL and hope nested polygons will always overdraw previously drawn ones

Both of these are prone to produce moire patters, because floating point calculations are not guaranteed to produce the exact same result, and the depth buffer is inprecise.

3. Make an algorithm, which subdivides polygons based on nested polygons. Cutting out the nested polygons from the polygons they are in, then triangulating the result. The result is a mesh with holes at the places where nested polygons are. I would prefer this, cause the nested polygons are drawing over already drawn areas, which is a waste. This method is only valid if polygons cant be transparent.

Btw, what properties these nested poligons can have? Different texture, different color?

I think the intended way of doing it is to render the owning face to the stencil buffer and then do a stencil test so that the subfaces are only rendered where their owning face is. Of course my guess could be wrong but I don't see any other way of doing this without getting artifacts. vear, your idea would probably work better as it's much faster but it is sort of a hack. If you render the primary faces first while writing to stencil, then render the subfaces with stencil test on, it would be cheap enough but won't work if certain subfaces are not supposed to draw on faces other than their owner. #3 is a bit expensive and could probably generate a lot of faces depending on the model, it might not be worth to save that fill-rate if your triangle count triples… Anyway, so far I think the best idea would be to contact the one who designed this format and ask him the best way to handle those subfaces because I don't think I really understand what they are for.