[vtkusers] How to create a polygon hole in a texture ?

De Boer Ingo I.deBoer at polytec.de
Tue Apr 8 03:40:07 EDT 2003


Hi,

this is really killing me! How can I create a simple hole in my plane texture?
I have something like:

float fAspectRatio  = (float)iImageWidth/(float)iImageHeight;

vtkBMPReader *bmpReader = vtkBMPReader::New();
bmpReader->SetFileName(cstrImageName);

vtkTexture *atext = vtkTexture::New();
atext->SetInput(bmpReader->GetOutput());

vtkPlaneSource *plane = vtkPlaneSource::New();
plane->SetOrigin( 0.0, 0.0, 0.0);
plane->SetPoint1( fAspectRatio*0.5, 0.0, 0.0);
plane->SetPoint2( 0.0, 0.5, 0.0);
plane->SetCenter( 0.0, 0.0, 0.0);

vtkPolyDataMapper *planeMapper = vtkPolyDataMapper::New();
planeMapper->SetInput(plane->GetOutput());

m_pvtkActor->SetMapper(planeMapper);
m_pvtkActor->SetTexture(atext);

m_pvtkRenderer->AddActor(m_pvtkActor);

Now, I want to put two holes in my texture, one triangle and one quad.
But I don't see how this works. I tried to use vtkClipDataSet in combination
with vtkImplicitDataSet. But that didn't work out. I didn't get any hole.
Then I tried something like:

vtkSphere *sphere = vtkSphere::New();
sphere->SetRadius(.5);
sphere->SetCenter(0,0,0);
vtkClipPolyData *clipper = vtkClipPolyData::New();
clipper->SetInput(plane->GetOutput());
clipper->SetClipFunction(sphere);
clipper->GenerateClipScalarsOn();
clipper->GenerateClippedOutputOn();
clipper->SetValue(0);
..
planeMapper->SetInput(clipper->GetOutput());
..

Didn't work either.

any hints ? thanks...

greets
  Ingo



More information about the vtkusers mailing list