[vtkusers] vtkTextureMapToPlane plane definition

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Wed Oct 22 16:36:17 EDT 2003


Salut Christophe,

With vtkPlaneSource you can specify a plane (facing in the z direction)
with three points, then change location and orientation with SetNormal(),
SetCenter() and Push(). vtkTextureMapToPlane seems to combine
vtkPlaneSource and vtkTexture but the documentation is not very clear.



You might have more control using vtlPlaneSource,  I have used the
following:


vtkTIFFReader -> vtkTexture
--------------------------------------------------------v
vtkPlaneSource -> vtkTransformPolyDataFilter -> vtkPolyDataMapper ->
vtkActor

I set the 3 points for vtkPlaneSource by getting the image height and width
using vtkTIFFReader->Update followed by vtkTIFFReader->GetDataExtent,
then
vtkPlaneSource->SetPoint0( 0, 0, 0 );
vtkPlaneSource->SetPoint1( width, 0,  0 );
vtkPlaneSource->SetPoint2( 0, height, 0 );

I use vtkPlaneSource->SetNormal(), SetCenter() and Push() to control
location and orientation. I use a vtkTransform with the
vtkTransformPolyDataFilter to control global scaling, you may not need
this.

   regards
      Dave P



|---------+---------------------------->
|         |           Christophe Franco|
|         |           <cfranco at amsatec.|
|         |           fr>              |
|         |           Sent by:         |
|         |           vtkusers-admin at vt|
|         |           k.org            |
|         |                            |
|         |                            |
|         |           22/10/2003 21:26 |
|         |                            |
|---------+---------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                |
  |       To:       vtkusers <vtkusers at vtk.org>                                                                                    |
  |       cc:                                                                                                                      |
  |       Subject:  [vtkusers] vtkTextureMapToPlane plane definition                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------|




I'm trying to display an image as a texture on a plane, using
vtkTextureMapToPlane class. I'm using the following code :


vtkPNGReader* reader = vtkPNGReader::New();
reader->SetFileName("test.png"); // File in AmsaView directory
reader->Update();

vtkTextureMapToPlane* imageTexture = vtkTextureMapToPlane::New();
imageTexture->AutomaticPlaneGenerationOff();
imageTexture->SetInput(reader->GetOutput());
imageTexture->SetOrigin(0, 0, 0);
imageTexture->SetPoint1(0, 1, 0);
imageTexture->SetPoint2(0, 0, 1);

vtkDataSetMapper* imageMapper = vtkDataSetMapper::New();
imageMapper->SetInput(imageTexture->GetOutput());

vtkActor* actor = vtkActor::New();
actor->SetMapper(imageMapper);
actor->SetPosition(-110, -338, 785);



The result is, the image is displayed at the wanted position, but the
plane is always along X-Y axes. No matter what values I use in the
SetOrigin, SetPoint1 and SetPoint2 methods, the result is always exactly
the same.

A also tried using the alternate method to define the plane with its
origin and normal, and I still got the same result.

Is there something I am doing wrong ?

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers








More information about the vtkusers mailing list