[vtkusers] Texture map a polygon

Bill Lorensen bill.lorensen at gmail.com
Tue Nov 17 13:51:56 EST 2009


The exmaples is a bit confused. On the one hand, it defines texture
coordinates explicitly. Then is uses TextureMapToPlane to generate
texture coordinates.

Add this statement:
Mapper->SetInput(Quad);
instead of
Mapper->SetInputConnection(TextureMapToPlane->GetOutputPort());

and you will see the difference.

VTK has a number of texture map coordinate generators:
Graphics/vtkProjectedTexture.h
Graphics/vtkTexturedSphereSource.h
Graphics/vtkTextureMapToCylinder.h
Graphics/vtkTextureMapToPlane.h
Graphics/vtkTextureMapToSphere.h
 to name a few.

Projected texture is a neat one.

Bill

On Tue, Nov 17, 2009 at 1:37 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> I was wondering the VTK syntax to do this though. The VTK users guide only
> shows how to use vtkTextureMapToPlane (which I got to work successfully).
> Since I no longer have a plane, I didn't know how to apply the texture.
>
> I got it to work though - here is an example of how to add texture
> coordinates to a polydata and then texture map a quad:
>
> http://www.vtk.org/Wiki/Texture_map_a_quad
>
> Thanks,
>
> David
>
>
> On Tue, Nov 17, 2009 at 1:17 PM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
>>
>> You need to define texture coordinates for each point in the polydata.
>> Texture coordinates are part of a polydata's pointdata. Then you need
>> to assign a texture the actor that contains the polygon.
>>
>> Texture coordinate (0,0) corresponds to pixel (0,0) and coordinate
>> (1,1) corresponds to the last pixel in the texture.
>>
>>  I think the vtk textbook explains all of this. Actually, any computer
>> graphics book will do the same. Generating texture coordinates for
>> arbitrary shapes is still a research problem.
>>
>> Bill
>>
>> On Tue, Nov 17, 2009 at 1:06 PM, David Doria <daviddoria+vtk at gmail.com>
>> wrote:
>> > I can texture map a plane:
>> > http://www.vtk.org/Wiki/Texture_map_a_plane
>> >
>> > But how would I texture map a polygon? Say I have 4 points that define a
>> > quad (lets say a rectangle) - how would I map an image onto this
>> > polygon?
>> >
>> > Thanks,
>> >
>> > David
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the VTK FAQ at:
>> > http://www.vtk.org/Wiki/VTK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.vtk.org/mailman/listinfo/vtkusers
>> >
>> >
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list