Hi Experts:
I use vtkClipPolyData with a sphere as clip function to clip a polydata surface. And then add a texture to the clip area. See picture and detailed code snippets below. Here comes my question: how to remove the background(in yellow color) of the texture? The texture itself has no backgound. The yellow actually comes from the actor but can’t be set with opactiy zero, otherwise the texture will be invisible.
vtkActor actor = vtkActor.New();
actor.PickableOff();
//actor.GetProperty().SetColor(1.0, 1.0, 0.0); //set actor color, if not set, will use default color
vtkSphere clipSphere = vtkSphere.New();
clipSphere.SetRadius(1);
clipSphere.SetCenter(coordX, coordY, coordZ);
vtkClipPolyData clipper = vtkClipPolyData.New();
clipper.GenerateClipScalarsOn();
clipper.SetClipFunction(clipSphere);
clipper.SetInputData(polydata);
clipper.InsideOutOn();
vtkTextureMapToPlane texToSphere = vtkTextureMapToPlane.New();
texToSphere.SetInputConnection(clipper.GetOutputPort());
vtkPolyDataMapper newMapper = vtkPolyDataMapper.New();
newMapper.ScalarVisibilityOff();
newMapper.SetInputConnection(texToSphere.GetOutputPort());
newMapper.Update();
actor.SetMapper(newMapper);
vtkJPEGReader pngReader = vtkJPEGReader.New();
pngReader.SetFileName(AimImgFilePath);
pngReader.Update();
vtkTexture texture = vtkTexture.New();
texture.SetInputConnection(pngReader.GetOutputPort());
texture.InterpolateOn();
texture.RepeatOff();
//texture.EdgeClampOff();
texture.MipmapOn();
actor.SetTexture(texture);