Tue, 11/22/2022 - 17:39
With Graphic3d_ArrayOfPrimitives I visualize measurement data coming from a 3D photogrammetry system.
Some sections of the data can be invisible (in the measurement data invisible parts are coded as NAN). To handle these invisible sections, I want make the vertex from the last visible point to the next visible point transparant.
The function Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt & theVertex,const Standard_Integer theColor32) suggest that transparancy can be set by the highest byte from theColor32, but setting the highest byte by adding 0xff << 24 does not result in transparant sections.
Am I missing something?
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Quantity_Color theColor(1.0, 0.0, .0, Quantity_TOC_RGB);
Standard_Integer theColor32;
Standard_Integer theColor32Invisible;
Quantity_Color::Color2argb(theColor, theColor32);
theColor32Invisible = (0xff << 24) + theColor32;
if (!m_PrsLines)
{
gp_Pnt gpPoint;
const int theNbPoints = hInput3D.Rows();
m_PrsLines = Graphic3d_ArrayOfPrimitives::CreateArray(Graphic3d_TOPA_POLYLINES, theNbPoints, 0, Graphic3d_ArrayFlags_VertexColor);
bool bVisibleBefore = true, bVisible = true;
for (ChartIndex I = 0; I < theNbPoints; I++)
{
bVisible = IsVisible(I);
if (hInput3D.IsVisible(I))
{
hInput3D.GetT4x4(T4x4, I);
gpPoint.SetX(GetX(I));
gpPoint.SetY(GetY(I));
gpPoint.SetZ(GetZ(I));
}
if (bVisibleBefore && bVisible)
m_PrsLines->AddVertex(gpPoint, theColor);
if (bVisibleBefore && !bVisible)
bVisibleBefore = false;
if (!bVisibleBefore && bVisible)
{
m_PrsLines->AddVertex(gpPoint, theColor32Invisible);
bVisibleBefore = true;
}
}
}
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Wed, 11/23/2022 - 07:45
Make sure you indicated that your arrays should be drawn with transparency Graphic3d_Aspects::SetAlphaMode(Graphic3d_AlphaMode_Blend, x) or Graphic3d_AlphaMode_MaskBlend. The result might look poor though, without enabling OIT in Graphic3d_RenderingParams
Wed, 11/23/2022 - 12:41
Thank's for the pointers, if a section is invisible then it will be completely transparant, as if it is not drawn, so I would guess the OIT would not matter to much in this particular case. Correct?
I have been searching where the apply the Graphic3d_Aspects::SetAlphaMode, but can't find it. Any pointers for this?
Tnx
Luc
Wed, 11/23/2022 - 13:05
If section will be completely invisible, then why putting it into array at all? Just skip it.
Wed, 11/23/2022 - 14:39
Ok, fixed it by skipping invisible sections as suggested
Tnx