[vtkusers] Smooth shading
Simon ESNEAULT
simon.esneault at gmail.com
Thu May 15 05:56:32 EDT 2014
Hi,
I think you need to generate the normals in order to have a proper shading.
If you add a vtkPolyDataNormals filter to your pipeline right after the
reader, it should look better (If i understand the problem properly !)
This example should help :
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataExtractNormals
Good luck
Simon
2014-05-15 11:10 GMT+02:00 Yoshinori KONISHI <ykoni at ari.ncl.omron.co.jp>:
> Hello all,
>
> Though I am trying to get a smooth shaded CAD object (.stl),
> the rendered image looks like that of flat shading (not smooth).
> Could anyone tell me how to correct my code ?
>
> --------------------------- (VTK 6.1.0 on Win7 64bit)
> vtkSmartPointer<vtkSTLReader> reader =
> vtkSmartPointer<vtkSTLReader>::New();
> reader->SetFileName(inputFilename.c_str());
> reader->Update();
>
> vtkSmartPointer<vtkPolyDataMapper> cadMapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> cadMapper->SetInputConnection(reader->GetOutputPort());
>
> vtkSmartPointer<vtkActor> cadActor =
> vtkSmartPointer<vtkActor>::New();
> cadActor->SetMapper(cadMapper);
> cadActor->GetProperty()->SetInterpolation(VTK_GOURAUD);
>
> vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New();
> ren1->AddActor(cadActor);
> ren1->SetBackground(0.1, 0.2, 0.4);
>
> vtkSmartPointer<vtkRenderWindow> renWin =
> vtkSmartPointer<vtkRenderWindow>::New();
> renWin->AddRenderer(ren1);
> renWin->SetSize(640, 480);
> --------------------------------------
>
> Thank you.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
------------------------------------------------------------------
Simon Esneault
13 rue Vasselot
35000 Rennes, France
Tel : 06 64 61 30 94
Mail : simon.esneault at gmail.com
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140515/ef0f2b90/attachment.html>
More information about the vtkusers
mailing list