[vtk] flipped normals question
Randy Heiland
heiland at ncsa.uiuc.edu
Tue Oct 5 18:05:13 EDT 1999
When I apply a vtkTransform with a negative Scale component to an Actor, it
seems to "lose its normals" (ever have days like that?) -- at least the
transformed actor isn't lit (but you can see it by going into wireframe).
Included is a simple Python script; below it, a similar Tcl script where I've
tried introducing flipped normals, etc.. What am I missing?
thanks,
--Randy
----------------------------------------------------------
#!/usr/local/bin/python
from libVTKCommonPython import *
from libVTKGraphicsPython import *
ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(300,300)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
cone = vtkConeSource()
cone.SetResolution(8)
coneMapper = vtkPolyDataMapper()
coneMapper.SetInput(cone.GetOutput())
coneActor = vtkActor()
coneActor.SetMapper(coneMapper)
xform=vtkTransform()
xform.Identity()
xform.Translate(2,0,0)
xform.Scale(1,1,-1)
coneFlipActor = vtkActor()
coneFlipActor.SetMapper(coneMapper)
coneFlipActor.GetProperty().SetColor(1,0,0)
coneFlipActor.SetUserMatrix(xform.GetMatrix())
ren.AddActor(coneActor)
ren.AddActor(coneFlipActor)
# enable user interface interactor
iren.Initialize()
iren.Start()
----------------------------------------------------------
catch {load vtktcl}
# user interface command widget
source ../../examplesTcl/vtkInt.tcl
# create a rendering window and renderer
vtkRenderer ren1
ren1 TwoSidedLightingOn
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# create an actor and give it cone geometry
vtkConeSource cone
cone SetResolution 8
vtkPolyDataMapper coneMapper
coneMapper SetInput [cone GetOutput]
vtkActor coneActor
coneActor SetMapper coneMapper
vtkTransform xform
xform Identity
xform Translate 2 0 0
xform Scale 1 1 -1
vtkCleanPolyData cleaner
cleaner SetInput [cone GetOutput]
# coneFlipActor SetMapper coneMapper
coneFlipActor SetMapper flipMapper
[coneFlipActor GetProperty] SetColor 1 0 0
coneFlipActor SetUserMatrix [xform GetMatrix]
[coneFlipActor GetProperty] BackfaceCullingOff
# assign actors to the renderer
ren1 AddActor coneActor
ren1 AddActor coneFlipActor
# enable user interface interactor
iren SetUserMethod {wm deiconify .vtkInteract}
iren Initialize
# prevent the tk window from showing up then start the event loop
wm withdraw .
vtkPolyDataNormals normals
# normals SetInput [cone GetOutput]
normals SetInput [cleaner GetOutput]
normals FlipNormalsOn
vtkPolyDataMapper flipMapper
flipMapper SetInput [normals GetOutput]
vtkActor coneFlipActor
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list