[vtkusers] Actor color gradient

joaoroberto88 joaorobertojr88 at gmail.com
Tue Jun 9 10:18:57 EDT 2015


Hi VTK Users,

I would like to apply a color gradient on a vtkActor. I've defined scalar
values to each vtkCell (by following this example 
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ColorCellsWithRGB
<http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ColorCellsWithRGB>  ).
However, the color transition isn't as I want. Please take a look in the
attached screenshot. Also below is a piece of code responsible for rendering
the image. What can I do to have it done?

Thanks,

Joao.

// Mesh rendering
vtkSmartPointer<vtkPolyData> gridPolyData = mesh->getGrid();
vtkSmartPointer<vtkPolyDataMapper> gridMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
// gridMapper->InterpolateScalarsBeforeMappingOff(); // Didn't take effect
on color gradient
gridMapper->SetInputData(gridPolyData);

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(gridMapper);
//    actor->GetProperty()->SetColor(1, 1, 1);
actor->GetProperty()->EdgeVisibilityOff();

renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(1, 1, 1); // White
renderer->AddActor(actor);

renderWindow->AddRenderer(renderer);

// QVTKWidget class method
this->SetRenderWindow(renderWindow);
renderWindow->Render();

<http://vtk.1045678.n5.nabble.com/file/n5732214/Screen_Shot_2015-06-09_at_10.png> 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Actor-color-gradient-tp5732214.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list