[vtkusers] vtkTextureMapToSphere and PreventSeamOff not working as expected

Alex Pletzer pletzer at txcorp.com
Fri Aug 8 11:33:54 EDT 2014


Below is the corrected code...

import vtk
"""
How to add texture to a sphere
"""

filename1 = "one.png"
 
# Create a render window
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(480,480)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
 
# Generate a sphere polydata
sphere1 = vtk.vtkTexturedSphereSource()
sphere1.SetThetaResolution(12)
sphere1.SetPhiResolution(12) # co-latitude
 
# Read the image data from  file
reader1 = vtk.vtkPNGReader()
reader1.SetFileName(filename1)
 
# Create texture object
texture1 = vtk.vtkTexture()
texture1.SetInputConnection(reader1.GetOutputPort())
 
# Create mapper and set the mapped texture as input
mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInputConnection(sphere1.GetOutputPort())
 
# Create actor and set the mapper and the texture
actor1 = vtk.vtkActor()
actor1.SetMapper(mapper1)
actor1.SetTexture(texture1)
 
ren.AddActor(actor1)
 
iren.Initialize()
renWin.Render()
iren.Start()




--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkTextureMapToSphere-and-PreventSeamOff-not-working-as-expected-tp5728125p5728148.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list