[vtkusers] Associate texture with polydata

David Gobbi david.gobbi at gmail.com
Sun Nov 15 18:15:00 EST 2009


On Sun, Nov 15, 2009 at 3:52 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> If I save a plane source as a vtp file, I can open it in paraview and then
> set "apply texture" in the "display" tab of the object inspector to a bitmap
> image. Is there anyway to associate this image with the geometry in c++
> code, so that when I open the vtp file the texture will already be applied?
> Or even better, somehow save the texture data in the same vtp file?
>
> Thanks,
>
> David

The vtkActor has a SetTexture method that allows you to associate a vtkTexture
object with polydata.  The vtkTexture is essentially a mapper that takes a
vtkImageData and turns it into an OpenGL texture.

The vtkPlaneSource should produce a polydata that already has the proper
texture coordinates to map the points of the plane to the corners of the image.
There is also a vtkTextureMapToPlane filter that can be used to add texture
coordinates to a polydata.

AFAIK none of the VTK file formats allow textures to be stored with polydata,
but they will at least save the texture coordinates.

    David



More information about the vtkusers mailing list