[vtkusers] Applying a transform to polydata affects lighting... weirdly
Ignacio Fernández Galván
jellby at yahoo.com
Thu Feb 1 14:02:47 EST 2018
If I apply a nontrivial transformation to polydata, the resulting
lighting is completely different from the original. A python example is
worth a thousand words:
renderer = vtk.vtkRenderer()
render_window = vtk.vtkRenderWindow()
interactor = vtk.vtkRenderWindowInteractor()
sphere = vtk.vtkSphereSource()
transform = vtk.vtkTransform()
# invert x axis
# invert x and y axes
# 90-degree z rotation
t_sphere = vtk.vtkTransformFilter()
sphere_mapper = vtk.vtkPolyDataMapper()
sphere_actor = vtk.vtkActor()
Using the first (no-op) transform is fine, of course.
The second just inverts the x axis, and that results in a black sphere.
Fair enough, I'm "inverting" the object, so maybe it's inside out.
Then I try inverting the y axis too, that should put things back to
normal. And indeed it does, apparently.
Perhaps what's needed is a proper rotation/shearing, with no reflection
component. I try the fourth, which is a pretty innocent 90-degree
rotation around the z axis, no inversion, no deformation. But lo, now
the light moves with the object!
Am I missing something or doing something wrong? Any fix or workaround?
This is with with both VTK 5.8.0 and 8.1.0
More information about the vtkusers