vtk中为平面贴纹理

关键代码:

  vtkSmartPointer<vtkTexture> atext =
    vtkSmartPointer<vtkTexture>::New();
  atext->SetInputConnection(textureFile->GetOutputPort());
  atext->InterpolateOn();
// Create a plane source and actor. The vtkPlanesSource generates
// texture coordinates.
//
  vtkSmartPointer<vtkPlaneSource> plane =
    vtkSmartPointer<vtkPlaneSource>::New();

  vtkSmartPointer<vtkPolyDataMapper>  planeMapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  planeMapper->SetInputConnection(plane->GetOutputPort());

  vtkSmartPointer<vtkActor> planeActor =
    vtkSmartPointer<vtkActor>::New();
  planeActor->SetMapper(planeMapper);
  planeActor->SetTexture(atext);

demo:https://lorensen.github.io/VTKExamples/site/Cxx/Texture/TexturePlane/

猜你喜欢

转载自blog.csdn.net/yuxing55555/article/details/80613285