Mixing Text and Triangles in Graphic3d_ZLayerId_TopOSD


I would like to display some shaded box (opaque) with text inside it.

I have a custom AIS_InteractiveObject for this task.

The problem is that when I set the layer of the object to Graphic3d_ZLayerId_TopOSD, all the primitive I use to compose this object seems to be on the same depth.  I tried playing with Graphic3d_Structure::SetDisplayPriority() (putting the text in it's own group as well as the triangles), with Graphic3d_Aspects::SetPolygonOffsets() and with Graphic3d_Text::SetPosition() by trying to put the Graphic3d_Text in front of the Graphic3d_ArrayOfTriangles but it's not working if I put the object on Graphic3d_ZLayerId_TopOSD layer.

The same custom object works fine if I use the Graphic3d_ZLayerId_Topmost layer.  Currently, the onl;y way I got it working on the Graphic3d_ZLayerId_TopOSD layer was to put some transparency on the triangles, but the text part is not as clear as I want in that case and in some case the text get lost in the 3D model.

Is there a way to get what I want?

Best regards,


Francois Lauzon's picture

The problem exist also with AIS_ColorScale, if we set the label position to center using AIS_ColorScale::SetLabelPosition(Aspect_TOCSP_CENTER), the text is not visible.

Kirill Gavrilov's picture

This behavior is by design - Graphic3d_ZLayerId_TopOSD layer is rendered with Depth test disabled (Graphic3d_ZLayerSettings::ToEnableDepthTest/ToEnableDepthWrite), so that overlapping objects should be strictly ordered to appear correctly.
You can change Layer properties via V3d_Viewer::SetZLayerSettings() method or create a new Layer with desired behavior and placement V3d_Viewer::InsertLayerBefore().

Francois Lauzon's picture

Thank you Kirill, that's exactly what I needed, work just fine now!