[vtkusers] surface texture problem

WolfgangZ wollez at gmx.net
Tue May 4 05:14:43 EDT 2010


Hello all,

I have a problem getting a texture on my surface (vtkPolyData) generated 
from image data. The surface itself shows up correctly, but the texture 
is wrong. What I want to achieve is to have the texture once on the 
surface so that it fits from left to right and top to bottom.

Any help is welcome.

Best regards
Wolfgang

PS I'm running vtk 5.4.2 from python (installation from pythonxy 
http://code.google.com/p/pythonxy/ )

here my code:


#######
import vtk
heightFactor=0.1

# Texture
tex_reader = vtk.vtkBMPReader()
tex_reader.SetFileName("./masonry.bmp")

tex = vtk.vtkTexture()
tex.SetInputConnection(tex_reader.GetOutputPort())
tex.InterpolateOn()
tex.RepeatOff()

# Height field
reader = vtk.vtkImageReader2()
reader.SetFileName("./dem30.raw")
reader.SetDataByteOrderToBigEndian()
reader.SetDataScalarTypeToFloat()
reader.SetDataExtent(0, 266, 0, 266, 0,0)

geom = vtk.vtkImageDataGeometryFilter()
geom.SetInputConnection(reader.GetOutputPort())

warp = vtk.vtkWarpScalar()
warp.SetInputConnection(geom.GetOutputPort())
warp.SetScaleFactor(heightFactor)

normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(warp.GetOutputPort())
normals.SetFeatureAngle(80)

# mapper, actor and rendering
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(normals.GetOutputPort())
mapper.ScalarVisibilityOff()

actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.SetTexture(tex)

ren = vtk.vtkRenderer()
ren.AddActor(actor)
ren.SetBackground(1, 1, 1)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(300, 300)

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
iren.Render()
iren.Start()

-------------- next part --------------
A non-text attachment was scrubbed...
Name: data.zip
Type: application/x-zip-compressed
Size: 138411 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100504/9042e7f0/attachment.bin>


More information about the vtkusers mailing list