[vtkusers] vtkTextureMapToSphere and PreventSeamOff not working as expected
Alexander Pletzer
pletzer at txcorp.com
Wed Aug 6 18:57:36 EDT 2014
Hi,
I'm trying to wrap the simple attached image around a sphere using
vtkTextureMapToSphere and got some unexpected result -- the word
"center" appears twice. Also the blue line is completely absent. There
also appears to be a small gap at longitude 0 (see testOne.png). It
looks as if the texture file was used twice.
Does anyone know hoe to fix this? After some googling I found that some
people had to write a custom vtkTextureMapToSphere class to deal with
this problem. I'd like the texture to completely cover the sphere, each
of the "nw", "sw", "se", "ne", and "center" texts should only appear
once, each of the red, blue, white, and green should also appear only once.
Thanks in advance.
--Alex
import vtk
import sys
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.vtkSphereSource()
sphere1.SetThetaResolution(12)
sphere1.SetPhiResolution(12)
sphere1.SetStartTheta(0)
sphere1.SetEndTheta(360)
# Read the image data from file
reader1 = vtk.vtkPNGReader()
reader1.SetFileName(filename1)
# Create texture object
texture1 = vtk.vtkTexture()
texture1.SetInputConnection(reader1.GetOutputPort())
# Map texture coordinates
map_to_sphere1 = vtk.vtkTextureMapToSphere()
map_to_sphere1.SetInputConnection(sphere1.GetOutputPort())
map_to_sphere1.PreventSeamOff()
# Create mapper and set the mapped texture as input
mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInputConnection(map_to_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()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: one.png
Type: image/png
Size: 5570 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140806/6a6b151c/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testOne.png
Type: image/png
Size: 52857 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140806/6a6b151c/attachment-0003.png>
More information about the vtkusers
mailing list