[vtkusers] texture rendering on a sphere.

Kyung-Won Chun kwchun at kjist.ac.kr
Mon Dec 30 14:23:25 EST 2002


I modified the example, TPlane.py little bit.  The original source was
texture mapping on a plane.  It worked very well. I just changed the
plane generation to sphere generation.  But, I can't make texture mapped
sphere.  Just the color of the sphere was changed.  Do I have to set
more option? or I did wrong operation.  The following is the source
script that I modified.

#!/usr/bin/env python
import os
try:
  VTK_DATA = os.environ['VTK_DATA']
except KeyError:
  VTK_DATA = '../../../vtkdata/'

from libVTKCommonPython import *
from libVTKGraphicsPython import *
from libVTKImagingPython import *

ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

sphereMapper = vtkPolyDataMapper()
sphereMapper.SetInput(sphere.GetOutput())
sphereActor = vtkActor()
sphereActor.SetMapper(sphereMapper)

atext = vtkTexture()
pnmReader = vtkPNMReader()
pnmReader.SetFileName(VTK_DATA + "/earth.ppm")
atext.SetInput(pnmReader.GetOutput())
atext.InterpolateOn()
sphereActor.SetTexture(atext)

ren.AddActor(sphereActor)
ren.SetBackground(0.1,0.2,0.4)
renWin.SetSize(500,500)

iren.Initialize()
renWin.Render()

iren.Start()






More information about the vtkusers mailing list