I want to create a 3D scene with a football. The following example creates a sphere and applies a football texture (currently just a checkerboard) to it, which is transformed by some spherical projection as shown in the image below.
import vtk
# create a rendering window
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
# create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# create source
sphereSource = vtk.vtkSphereSource()
sphereSource.SetCenter(-10.0, 0.0, 0.0)
sphereSource.SetRadius(1)
sphereSource.SetPhiResolution(50)
sphereSource.SetThetaResolution(50)
# fancy football texture
reader = vtk.vtkJPEGReader()
reader.SetFileName('football.jpg') # currently a checkerboard pattern
texture = vtk.vtkTexture()
texture.SetInputConnection(reader.GetOutputPort())
map_to_sphere = vtk.vtkTextureMapToSphere()
map_to_sphere.SetInputConnection(sphereSource.GetOutputPort())
map_to_sphere.PreventSeamOn()
# create mapper
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInputConnection(map_to_sphere.GetOutputPort())
# create actor
sphereActor = vtk.vtkActor()
sphereActor.SetMapper(sphereMapper)
sphereActor.SetTexture(texture)
# assign actor to the renderer
ren.AddActor(sphereActor)
# enable user interface interactor
iren.Initialize()
renWin.Render()
iren.Start()
How can I either apply the texture with another projection method or precondition the 2D texture, such that it compensates the transformation? Or is there another solution? The goal is a distribution of equally sized and shaped patches like on a football.
