Graphic3d_ArrayOfPrimitives having transparant sections

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;
}
}
}

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

gkv311 n's picture

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

Luc Wens's picture

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

gkv311 n's picture

If section will be completely invisible, then why putting it into array at all? Just skip it.

Luc Wens's picture

Ok, fixed it by skipping invisible sections as suggested

		m_PrsLines = Graphic3d_ArrayOfPrimitives::CreateArray(Graphic3d_TOPA_SEGMENTS, theNbPoints*2, 0, Graphic3d_ArrayFlags_VertexColor);

		for (int I = 0; I < theNbPoints; I++)
		{
			if (IsVisible(I))
			{
				X = GetX(I);
				Y = GetY(I);
				Z = GetZ(I);
			}
			else
			{
				X = Y = Z = NAN;
			}

			if (!_isnan(X) && !_isnan(X_prev))
			{
				if (UseColorChannel)
					m_AISColorScale->FindColor(hMatrixColor(I), theColor);
				m_PrsLines->AddVertex(gp_Pnt(X_prev, Y_prev, Z_prev), theColor);
				m_PrsLines->AddVertex(gp_Pnt(X, Y, Z), theColor);
			}

			X_prev = X;
			Y_prev = Y;
			Z_prev = Z;		
			theColor_prev = theColor;
		}

Tnx