[vtkusers] Texture mapping

David Gobbi dgobbi at irus.rri.ca
Fri Jun 29 12:22:25 EDT 2001


Hi Remo,

It's about the same in VTK.  In a situation where you already have
the vertices & texture coords, you can build a vtkPolyData like this:

points = vtkPoints::New();
points->InsertNextPoint(x,y,z)  // repeat for all points
...

polys = vtkCellArray::New();
polys->InsertNextCell(n);       // n is number of points in polygon
polys->InsertCellPoint(i);      // i is index into above 'points' list
polys->InsertCellPoint(j);      // etc. for each point in polygon
...
polys->InsertNextCell(m);       // next polygon
...

tcoords = vtkTCoords::New();
tcoords.InsertNextTCoord(tx,ty,0.0); // one tcoord per point
...

data = vtkPolyData::New();
data->SetPoints(points);
data->SetPolys(polys);
data->GetPointData()->SetTCoords(tcoords);

Done!  If you want to set normals for the points, you do it
the same way as for the TCoords.

 - David

--
  David Gobbi, MSc                       dgobbi at irus.rri.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Fri, 29 Jun 2001, Remo Ziegler wrote:

> Hi,
>
> I have a vtkPolyData object describing the polygonal  model and a
> bmp-File to describe the texture for it. Since the texture file has a
> certain structure, I want to map every triangle of vtkPolyData to a
> triangle in the bmp-file describing the texture.
> In OpenGL I would use the glTextCoord2f(..., ....); glVertex3f(...,
> ...., ....); construction ... is there any similar stuff in vtk?
>
> Thanks for your help! Have a nice weekend !!
>
> Greets .... Remo
>
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
>





More information about the vtkusers mailing list