OK, so the culprit is clean polydata.<br><br><div class="gmail_quote">On Fri, Jul 6, 2012 at 9:56 AM, Mika Fischer <span dir="ltr"><<a href="mailto:mika.fischer@zoopnet.de" target="_blank">mika.fischer@zoopnet.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If I leave out the normals filter, I get flat shading *and* broken textures.<br>
<br>
So:<br>
vtkPolyDataMapper: flat shading, good texture<br>
vtkPolyDataNormals -> vtkPolyDataMapper: flat shading, good texture<br>
vtkCleanPolyData -> vtkPolyDataMapper: flat shading, broken texture<br>
vtkCleanPolyData -> vtkPolyDataNormals -> vtkPolyDataMapper: smooth<br>
shading, broken texture<br>
<br>
Best,<br>
Mika<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, Jul 6, 2012 at 3:50 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br>
> Leave out the normals filter. Let's see you is messing with the texture<br>
> coordinates.<br>
><br>
><br>
> On Fri, Jul 6, 2012 at 9:38 AM, Mika Fischer <<a href="mailto:mika.fischer@zoopnet.de">mika.fischer@zoopnet.de</a>><br>
> wrote:<br>
>><br>
>> Unfortnuately, that yields exactly the same results...<br>
>><br>
>> On Fri, Jul 6, 2012 at 3:33 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
>> wrote:<br>
>> > on the normals filter try<br>
>> > ->SplittingOff();<br>
>> ><br>
>> > On Fri, Jul 6, 2012 at 9:22 AM, Mika Fischer <<a href="mailto:mika.fischer@zoopnet.de">mika.fischer@zoopnet.de</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Ok, unfortunately now I get a problem when mapping the texture on the<br>
>> >> surface. There are strage "seams" in some places:<br>
>> >> <a href="http://zoopnet.de/vrml2.png" target="_blank">http://zoopnet.de/vrml2.png</a><br>
>> >><br>
>> >> Without vtkCleanPolyData the texture mapping worked fine. I think the<br>
>> >> problem might be caused by the vertices of the polygons being changed<br>
>> >> by vtkCleanPolyData. Is there something I can do to transform the<br>
>> >> texture in the same way?<br>
>> >><br>
>> >> The code used for texturing is below.<br>
>> >><br>
>> >> Thanks a lot in advance!<br>
>> >><br>
>> >> Best,<br>
>> >> Mika<br>
>> >><br>
>> >> ------------------------------------------------------------<br>
>> >> vtkSmartPointer<vtkBMPReader> bmpReader =<br>
>> >> vtkSmartPointer<vtkBMPReader>::New();<br>
>> >> bmpReader->SetFileName(fileBmp.c_str());<br>
>> >> bmpReader->Update();<br>
>> >><br>
>> >> vtkImageData* image = bmpReader->GetOutput();<br>
>> >> vtkTexture *texture = vtkTexture::New();<br>
>> >> texture->SetInputConnection(bmpReader->GetOutputPort());<br>
>> >> texture->InterpolateOn();<br>
>> >><br>
>> >> [...]<br>
>> >><br>
>> >> solidActor->SetTexture(texture);<br>
>> >><br>
>> >><br>
>> >> On Fri, Jul 6, 2012 at 3:06 PM, Mika Fischer <<a href="mailto:mika.fischer@zoopnet.de">mika.fischer@zoopnet.de</a>><br>
>> >> wrote:<br>
>> >> > Yes, that fixed it! Thanks a lot!<br>
>> >> ><br>
>> >> > Best,<br>
>> >> > Mika<br>
>> >> ><br>
>> >> > On Fri, Jul 6, 2012 at 3:01 PM, Bill Lorensen<br>
>> >> > <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
>> >> > wrote:<br>
>> >> >> Try running vtkCleanPolyData before the normals calculation. The<br>
>> >> >> data<br>
>> >> >> may<br>
>> >> >> duplicate the points for each triangle. clean polydata will remove<br>
>> >> >> duplicate<br>
>> >> >> points.<br>
>> >> >><br>
>> >> >> On Fri, Jul 6, 2012 at 5:21 AM, Mika Fischer<br>
>> >> >> <<a href="mailto:mika.fischer@zoopnet.de">mika.fischer@zoopnet.de</a>><br>
>> >> >> wrote:<br>
>> >> >>><br>
>> >> >>> Hi,<br>
>> >> >>><br>
>> >> >>> first of all I have to say that is the first time that I use vtk<br>
>> >> >>> and I<br>
>> >> >>> don't have much experience with 3D graphics.<br>
>> >> >>><br>
>> >> >>> I have a 3d triangle mesh of a face in wrl format. I also managed<br>
>> >> >>> to<br>
>> >> >>> display it. However the shading of the triangles seems to be flat.<br>
>> >> >>> Calling SetInterpolationToGouraud() or SetInterpolationToFlat()<br>
>> >> >>> seems<br>
>> >> >>> to make no difference.<br>
>> >> >>><br>
>> >> >>> The code used to load the data and display it is below. Am I<br>
>> >> >>> missing<br>
>> >> >>> an important step here?<br>
>> >> >>><br>
>> >> >>> Also, if I load the file in ParaView, it has the same issue and<br>
>> >> >>> switching from Flat to Gouraud makes no visible difference. However<br>
>> >> >>> if<br>
>> >> >>> I use a CylinderSource, the shading is smooth as I would expect it<br>
>> >> >>> (and switching to flat makes a huge difference).<br>
>> >> >>><br>
>> >> >>> Here's a screenshot of the data in paraview:<br>
>> >> >>> <a href="http://zoopnet.de/vrml.png" target="_blank">http://zoopnet.de/vrml.png</a><br>
>> >> >>><br>
>> >> >>> Any tips would be very much appreciated!<br>
>> >> >>><br>
>> >> >>> Best,<br>
>> >> >>> Mika<br>
>> >> >>><br>
>> >> >>> -------------------------------------<br>
>> >> >>> vtkSmartPointer<vtkVRMLImporter> importer =<br>
>> >> >>> vtkSmartPointer<vtkVRMLImporter>::New();<br>
>> >> >>> importer->SetFileName(fileWrl.c_str());<br>
>> >> >>> importer->Read();<br>
>> >> >>> importer->Update();<br>
>> >> >>><br>
>> >> >>> vtkActorCollection* actors = importer->GetRenderer()->GetActors();<br>
>> >> >>> actors->InitTraversal();<br>
>> >> >>> vtkDataSet* pDataset =<br>
>> >> >>> actors->GetNextActor()->GetMapper()->GetInput();<br>
>> >> >>><br>
>> >> >>> vtkPolyData* polyData = vtkPolyData::SafeDownCast(pDataset);<br>
>> >> >>> polyData->Update();<br>
>> >> >>><br>
>> >> >>> vtkSmartPointer<vtkPolyDataNormals> skinNormals =<br>
>> >> >>> vtkSmartPointer<vtkPolyDataNormals>::New();<br>
>> >> >>> skinNormals->SetFeatureAngle(90.0);<br>
>> >> >>> skinNormals->SetInput(polyData);<br>
>> >> >>> skinNormals->Update();<br>
>> >> >>><br>
>> >> >>> vtkSmartPointer<vtkPolyDataMapper> solidMapper =<br>
>> >> >>> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
>> >> >>> solidMapper->SetInputConnection(skinNormals->GetOutputPort());<br>
>> >> >>> solidMapper->ScalarVisibilityOff();<br>
>> >> >>><br>
>> >> >>> vtkSmartPointer<vtkActor> solidActor =<br>
>> >> >>> vtkSmartPointer<vtkActor>::New();<br>
>> >> >>> solidActor->SetMapper(solidMapper);<br>
>> >> >>> solidActor->GetProperty()->SetInterpolationToGouraud();<br>
>> >> >>><br>
>> >> >>> -------------------------------------<br>
>> >> >>> _______________________________________________<br>
>> >> >>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> >> >>><br>
>> >> >>> Visit other Kitware open-source projects at<br>
>> >> >>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> >> >>><br>
>> >> >>> Please keep messages on-topic and check the VTK FAQ at:<br>
>> >> >>> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
>> >> >>><br>
>> >> >>> Follow this link to subscribe/unsubscribe:<br>
>> >> >>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >> --<br>
>> >> >> Unpaid intern in BillsBasement at noware dot com<br>
>> >> >><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > Unpaid intern in BillsBasement at noware dot com<br>
>> ><br>
><br>
><br>
><br>
><br>
> --<br>
> Unpaid intern in BillsBasement at noware dot com<br>
><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>