Hey Olumide,

Well, this script works for taking two attribute arrays which contain the U and 
V coordinates for the texture maps and puts them together into a single 
two-component array, adds that array as a new vector attribute of the polydata, 
and then tells the system that this array should be used as texture coordinates 
(rather than just any old two-component array).

What you will need to do depends on what form your data is already in, and 
whether you already have texture coordinates. Do you already have them, or do 
you just have a mesh that you want to texture?

Once you have the texture coordinates generated and applied correctly, (you can 
try this in ParaView by creating a Sphere Source and then running the Texture 
Map To Sphere filter to generate texture coordinates for it), then in the 
Display tab of the Object Inspector, under the Color section, the Apply Texture 
combo box should be enabled and you can use this to pull down to Load... to 
read in your texture image and apply it to your surface. (If you also want the 
texture to be colored by a color map, the trick is to uncheck Interpolate 
Scalars after choosing an array in "Color by".)

So, if this doesn't answer your questions you'll have to let us know more 
specifically what you are starting with.

Talk to you later,
-Eric


On Apr 19, 2010, at 3:14 PM, Olumide wrote:

> Eric,
> 
> I too am interested in texture mapping a 3d mesh object (having texture 
> coordinates). How to I use the script you provided?
> 
> In addition, I know the mesh can be in PVD format, but how do I specify the 
> texture coordinates as well as the texture?
> 
> Thanks,
> 
> - Olumide
> 
> 
> # SCRIPT ....
> # =============
> pdi = self.GetPolyDataInput()
> pdo = self.GetPolyDataOutput()
> 
> numPts = pdi.GetPoints().GetNumberOfPoints()
> Uarray = pdi.GetPointData().GetArray('U')
> Varray = pdi.GetPointData().GetArray('V')
> 
> tc = vtk.vtkDoubleArray()
> tc.SetNumberOfComponents(2)
> tc.SetNumberOfTuples(numPts)
> tc.SetName('TCoords')
> 
> for ii in range(numPts):
>  Uval = Uarray.GetTuple1(ii)
>  Vval = Varray.GetTuple1(ii)
>  tc.SetTuple2(ii,Uval,Vval)
> 
> pdo.ShallowCopy(pdi)
> pdo.GetPointData().AddArray(tc)
> pdo.GetPointData().SetActiveTCoords('TCoords')
> # =============
> _______________________________________________
> 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 ParaView Wiki at: 
> http://paraview.org/Wiki/ParaView
> 
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview

_______________________________________________
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 ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to