[vtkusers] diffuse lighting after scaling with negative values

Francois Bertel francois.bertel at kitware.com
Wed Sep 3 15:29:34 EDT 2008


Rotation about 180 degrees is not equivalent to flipping an axis with
a -1 scale. Proof of that is the determinant of a rotation matrix is
always 1. Determinant of the following scale matrix is -1.

The real problem is normals vectors are flipped. By scaling with
(1,1-1) you just switched from a right-handed coordinate system to a
left-handed one. Maybe you can try to apply the transformation on the
polydata first with a vtkTransformPolyDataFilter, then create the
normals with a vtkPolyDataNormals filter and finally connect its
output to the mapper.


On Wed, Sep 3, 2008 at 3:11 PM, Gerrick Bivins
<gbivins at objectreservoir.com> wrote:
>
>
> Hi Manuel,
> You should just rotate your actor 180 degrees rather than using the scale.
>  This would avoid these kinds of problems.
> Gerrick
>
>
> On 9/3/08 1:55 PM, "Manuel Feige" <manuelfeige at googlemail.com> wrote:
>
> Hello,
>
> my application needs to mirror the actors with respect to the x-y-plane. I
> can do this by vtkProp3D::SetScale(1, 1, -1). Unfortunately the diffuse
> lighting does not work after this transformation (the ambient lighting
> does). In this example the cone appears gray instead of white.
>
> int main()
> {
> vtkConeSource* cone = vtkConeSource::New();
> vtkDataSetMapper* mapper = vtkDataSetMapper::New();
> mapper->SetInput(cone->GetOutput());
>
> vtkActor* actor = vtkActor::New();
> actor->SetMapper(mapper);
> actor->GetProperty()->SetRepresentationToSurface();
> actor->GetProperty()->SetColor(1.0, 1.0, 1.0);
> actor->GetProperty()->SetAmbient(0.5);
> actor->SetScale(1,1,-1);
>
> vtkRenderer* renderer = vtkRenderer::New();
> renderer->AddActor(actor);
> vtkRenderWindow* renWin = vtkRenderWindow::New();
> renWin->AddRenderer(renderer);
> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
> iren->Initialize();
> iren->Start();
>
> //Delete...
> }
>
> Any suggestions how I can get the diffuse lighting running?
>
> Thanks in advance
> Manuel Feige
>
> ________________________________
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list