MeshVS Transparency Setting

Hello, I load my STL file via MeshVS, I can give color configs but I can't set transparency even If set "aMesh->SetTransparency(0.9);" value it still doesn't effect it.

Kirill Gavrilov's picture

MeshVS_Mesh doesn't implement these methods of AIS_InteractiveObject interface (SetColor()/SetTransparency/SetMaterial etc.) - you have to use MeshVS_Drawer interface instead.

Basing on meshmat Draw Harness command implementation, it might look like this:

Graphic3d_MaterialAspect aMatAsp (Graphic3d_NOM_GLASS);
aMatAsp.SetTransparency (0.5f);

Handle(MeshVS_Mesh) theMesh = ...;
theMesh->GetDrawer()->SetMaterial (MeshVS_DA_FrontMaterial, aMatAsp);
theMesh->GetDrawer()->SetMaterial (MeshVS_DA_BackMaterial,  aMatAsp);

Handle(AIS_InteractiveContext) theCtx = ...;
theCtx->Redisplay (aMesh, true);
o s's picture

It works perfectly, thank you so much!