[vtkusers] Need point position on texture

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Mon May 17 08:32:10 EDT 2004


Aha. I assumed you had the drawn points in the form of a polydata object. In
which case, you just stuff it through the TMTP filter.
If they're in some prorietary form, then you could copy them to polydata (in
world coordinate system), pass it through and get the tex coords out.

One possibly easier way is just taking the width height of the texture, and
mapping your coords to 0,1 depending on position along each axis from the
left corner of the texture (assuming its just a flat square poly).

JB


----- Original Message ----- 
From: "de Boer Ingo" <I.deBoer at polytec.de>
To: "John Biddiscombe" <jbiddiscombe at skippingmouse.co.uk>;
<vtkusers at vtk.org>
Sent: Monday, May 17, 2004 12:43 PM
Subject: RE: [vtkusers] Need point position on texture



Hi,

> Why not pass the points through TextureMapToPlane? Points->Plane
> definition->Tex coords output.
Okay... But where does the part with the points come in ?

I have the following now:

[snip]
// Read bitmap from file
int idim[3];
vtkBMPReader *bmpReader = vtkBMPReader::New();
bmpReader->SetFileName("example.bmp");
bmpReader->Update();
bmpReader->GetOutput()->GetDimensions(idim);
float fAspectRatio  = (float)idim[0]/(float)idim[1];
// Create texture
vtkTexture *atext = vtkTexture::New();
atext->SetInput(bmpReader->GetOutput());
atext->InterpolateOn();
// Create a plane source. The vtkPlaneSource generates texture coordinates.
vtkPlaneSource *pvtkPlaneSource = vtkPlaneSource::New();
pvtkPlaneSource->SetOrigin( 0.0, 0.0, 0.0);
pvtkPlaneSource->SetPoint1( fAspectRatio*0.5, 0.0, 0.0);
pvtkPlaneSource->SetPoint2( 0.0, 0.5, 0.0);
pvtkPlaneSource->SetCenter( 0.0, 0.0, 0.0);
// make texture to plane
vtkTextureMapToPlane *texturePlane = vtkTextureMapToPlane::New();
texturePlane->SetInput(pvtkPlaneSource->GetOutput());
texturePlane->AutomaticPlaneGenerationOn();
// Create a plane mapper
vtkPolyDataMapper* pvtkPolyDataMapper = vtkPolyDataMapper::New();
pvtkPolyDataMapper->SetInput((vtkPolyData *)texturePlane->GetOutput());
// make actor
vtkActor *at = vtkActor::New();
at->SetMapper(pvtkPolyDataMapper);
at->SetTexture(atext);
[snap]

eg, I have a polygon line with 4 points and I have
these 4 points in Display/World-Coordinates.
In vtkTextureMapToPlane I can set/get axes, ranges, normals...
But where is the function for something like
float* GetTextureCoords(float WorldX, float WorldY, float WorldZ);

Where or how do I get my s/t texture coordinates ?

greets
  Ingo

---
Dr.-Ing. Ingo H. de Boer

Polytec GmbH
Polytec-Platz 1-7, 76337 Waldbronn, Germany
phone: ++49 7243 604 106
fax  : ++49 7243 604 255


_______________________________________________
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