[vtkusers] How to apply a transparent texture?

Philipp Hartl philipp.hartl at bkf.at
Tue Jun 3 05:54:05 EDT 2008


Hello,

I've a vtkPolyData with scalars and a vtkLookupTable to map the scalars 
to colors. Now I want to apply a transparent texture on the hull of the 
polygonal data structure.

std::string filename = "square.jpg";
vtkImageReader2Factory* imgfactory = vtkImageReader2Factory::New();
vtkImageReader2* imgreader = 
imgfactory->CreateImageReader2(filename.c_str());
imgreader->SetFileName(filename.c_str());
imgfactory->Delete();

vtkTexture* texture = vtkTexture::New();
texture->SetInputConnection(imgreader->GetOutputPort());
imgreader->Delete();
texture->InterpolateOn();
texture->RepeatOn();

vtkPolyData* pd = vtkPolyData::New();
pd->SetPoints(points);
pd->SetPolys(polys);
pd->GetPointData()->SetScalars(slr);

vtkLookupTable* lut = vtkLookupTable::New();
lut->SetNumberOfColors(10);
lut->SetHueRange(0.3, 0);
lut->SetSaturationRange(0.5, 1);
lut->SetValueRange(0.5, 1);
lut->SetTableRange(0, 100);
lut->Build();

vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
mapper->SetInput(pd);
mapper->SetScalarRange(0, 100);
mapper->SetLookupTable(lut);

vtkLODActor* a = vtkLODActor::New();
a->SetMapper(mapper);
a->SetTexture(texture);

My problem, the whole object is completely transparent. The colors of 
the polydata through the scalars are never seen. What I'm doing wrong?

Cheers,

Philipp



More information about the vtkusers mailing list