MeshVS_NodalColorPrsBuilder cannot set materials

Hello, I want to make the surface of MeshVS_Mesh shiny, as shown in picture1. In the picture left model is created using MeshVS_MeshPrsBuilder, it can set the material through:

meshvs_mesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, Graphic3d_NOM_SHINY_PLASTIC);

But when I use MeshVS_NodalColorPrsBuilder, I can't set the material with same function, and the display effect is on the right side of picture.

My test code is as follows,

Handle(MeshVS_Mesh) ais_mesh = new MeshVS_Mesh;
Handle(MeshDataSource) mesh_date = new MeshDataSource(mesh);
ais_mesh->SetDataSource(mesh_date);
// MeshVS_MeshPrsBuilder     Set material successfully
// Handle(MeshVS_MeshPrsBuilder) mesh_prs_builder = new MeshVS_MeshPrsBuilder(ais_mesh);
// MeshVS_NodalColorPrsBuilder   fail
Handle(MeshVS_NodalColorPrsBuilder) mesh_prs_builder = new MeshVS_NodalColorPrsBuilder(ais_mesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
for(int i = 1; i <= (mesh_date->GetEleNum()) * 3; i++)
{
    mesh_prs_builder->SetColor(i, Quantity_NOC_BISQUE);
}
ais_mesh->AddBuilder(mesh_prs_builder, true);
ais_mesh->UnsetMaterial();
ais_mesh->SetDisplayMode(MeshVS_DMF_Shading);
ais_mesh->SetMeshSelMethod(MeshVS_MSM_PRECISE);
ais_mesh->SetHilightMode(MeshVS_DMF_Shading);
ais_mesh->HilightAttributes()->SetColor(Quantity_NOC_YELLOW2);
ais_mesh->GetDrawer()->SetBoolean(MeshVS_DA_DisplayNodes, Standard_False);
ais_mesh->GetDrawer()->SetBoolean(MeshVS_DA_ShowEdges, Standard_False);
ais_mesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, Graphic3d_NOM_SHINY_PLASTIC);
ais_mesh->GetDrawer()->SetBoolean(MeshVS_DA_ColorReflection, Standard_True);
Attachments: 
gkv311 n's picture

MeshVS_NodalColorPrsBuilder configures material to make mapped colors clearly visible - shading make harm considerably mapped information. The only option you have is to enable MeshVS_DA_ColorReflection property. Otherwise, you may subclass MeshVS_NodalColorPrsBuilder or implement your own presentation builder taking code of existing builders as references.

Z Frank's picture

OK,thanks for your reply!

Z Frank's picture

Hello gkv,

When I use the AIS_Triangulation class, the gradient color seems to be combined with the color of the model's default material, how can I cancel the color of this material? Looking forward to your answer.

Attachments: 
q zx's picture

Hello Frank,
Did you solve the problem? I'm having the same problem right now

FrankZNL's picture

You can initialize the material in the constructor and then modify the parameters material.SetEmissiveColor(Quantity_NOC_BLACK)

q zx's picture

thanks for your reply! But I don't know how to solve it.
In your above code, my changes are as follows,
Graphic3d_MaterialAspect material(Graphic3d_NOM_SHINY_PLASTIC);
material.SetEmissiveColor(Quantity_NOC_BLACK);
ais_mesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, material);

FrankZNL's picture

sorry, I don't know MeshVS. Finally, I used AIS_Triangulation to solve my problem.

q zx's picture

OK,thanks for your reply!