[vtkusers] vtkTexture -- only textures using a single color?
kplusplus at comcast.net
kplusplus at comcast.net
Mon Feb 21 16:30:21 EST 2005
I'm writing an app that allows the user to visualize heightmaps, and am
having problems with vtkTexture. For some reason, the correct texture
isn't applied; rather, the color that occurs in the upper leftmost pixel
of the texture map. The textures I'm using have the same dimensions as
the heightmaps.
Here's the code I'm testing with:
------
vtkPNGReader *hmReader = vtkPNGReader::New();
hmReader->SetFileName(filePath);
vtkPNGReader *tReader = vtkPNGReader::New();
tReader->SetFileName(texturePath);
vtkTexture *tex = vtkTexture::New();
tex->SetInput(tReader->GetOutput());
tex->RepeatOff();
tex->InterpolateOn();
vtkDataSetSurfaceFilter *geometry = vtkDataSetSurfaceFilter::New();
geometry->SetUseStrips(1);
geometry->SetInput(hmReader->GetOutput());
vtkQuadricClustering *cluster = vtkQuadricClustering::New();
cluster->SetUseInputPoints(1);
cluster->SetNumberOfXDivisions(128);
cluster->SetNumberOfYDivisions(128);
cluster->SetNumberOfZDivisions(128);
cluster->SetInput(geometry->GetOutput());
vtkWarpScalar *warp = vtkWarpScalar::New();
warp->SetScaleFactor(1.0);
warp->SetInput(cluster->GetOutput());
vtkDataSetMapper *mapper = vtkDataSetMapper::New();
mapper->ScalarVisibilityOff();
mapper->SetInput((vtkPolyData *)warp->GetOutput());
vtkActor *actor = vtkActor::New();
actor->SetTexture(tex);
actor->SetMapper(mapper);
ren->AddActor(actor);
------
What's going wrong here? How do I get my textures to work properly?
More information about the vtkusers
mailing list