[vtkusers] Getting color from vtk actor
Jesse Michael Chandler
jchandl1 at mix.wvu.edu
Mon Apr 5 17:52:11 EDT 2004
I'm writing a program using VTK to draw objects and render them in
OpenSG. Unfortunately, I'm having a problem exporting the color data
from the actor. Every example I've found uses MapScalars to get color
data, yet the call always returns null and I'm a bit puzzled. My block
of VTK code is as follows:
vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(3.0);
sphere->SetThetaResolution(5);
sphere->setPhiResolution(5);
sphere->Update();
vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
sphereMapper->SetInput(sphere->GetOutput());
vtkActor *sphereActor = vtkActor::New();
sphereActor->SetMapper(sphereMapper);
sphereActor->GetProperty()->SetColor(.5 , .5 , .5);
vtkUnsignedCharArray *colorArray =
sphereActor->GetMapper()->MapScalars(1.0);
if(!colorArray)
printf("Lacking in color.\n"); // this always evaluates...
More information about the vtkusers
mailing list