Changing Color on Glyphs with Scalar Array

Hi,

I am currently creating multiple cubes with vtkGlyph3D to ensure a good performance.
As i am doing this in VR multiple Actors are not possible. But now i want to color them independently. As they are one Actor i can’t do it by setting a color for the actor. Thats why i have to color them by setting scalars. But to highlight a certain cube i would need to color additionaly its edges or make a hatching pattern over the color, or even set a texture.

The creation and coloring works like this:

Generating multiple Cubes:

vtkSmartPointer cubeSource = vtkSmartPointer::New();

Adding them to the Glyph:

vtkSmartPointer glyph3D = vtkSmartPointer::New();
glyph3D->GeneratePointIdsOn();
glyph3D->SetSourceConnection(cubeSource->GetOutputPort());
glyph3D->SetInputData(m_cubePolyData);
glyph3D->SetColorModeToColorByScalar();
glyph3D->SetScaleModeToDataScalingOff();
glyph3D->Update();

Create a mapper and actor:

vtkSmartPointer glyphMapper = vtkSmartPointer::New();
glyphMapper->SetInputConnection(glyph3D->GetOutputPort());
m_actor->SetMapper(glyphMapper);
Now i color them:
currentColorArr = vtkSmartPointer::New();
currentColorArr->SetName(“colors”);
currentColorArr->SetNumberOfComponents(4);
currentColorArr->InsertNextTuple4(r,g,b,a); // Loop over all cubes to color

BUT how do i now set a edge coloring or some technique to highlight a selected cube?

I am glad about every help / idea!

In 3D Slicer, we solved this by creating a second actor that contains all the “active” glyphs. When the user grabs an object with a controller then we remove it from the normal glyphs actor and add it to the active glyphs actor.

1 Like