[vtkusers] Only flat shading with VRML data

Mika Fischer mika.fischer at zoopnet.de
Fri Jul 6 09:22:42 EDT 2012


Ok, unfortunately now I get a problem when mapping the texture on the
surface. There are strage "seams" in some places:
http://zoopnet.de/vrml2.png

Without vtkCleanPolyData the texture mapping worked fine. I think the
problem might be caused by the vertices of the polygons being changed
by vtkCleanPolyData. Is there something I can do to transform the
texture in the same way?

The code used for texturing is below.

Thanks a lot in advance!

Best,
 Mika

------------------------------------------------------------
vtkSmartPointer<vtkBMPReader> bmpReader = vtkSmartPointer<vtkBMPReader>::New();
bmpReader->SetFileName(fileBmp.c_str());
bmpReader->Update();

vtkImageData* image = bmpReader->GetOutput();
vtkTexture *texture = vtkTexture::New();
texture->SetInputConnection(bmpReader->GetOutputPort());
texture->InterpolateOn();

[...]

solidActor->SetTexture(texture);


On Fri, Jul 6, 2012 at 3:06 PM, Mika Fischer <mika.fischer at zoopnet.de> wrote:
> Yes, that fixed it! Thanks a lot!
>
> Best,
>  Mika
>
> On Fri, Jul 6, 2012 at 3:01 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> Try running vtkCleanPolyData before the normals calculation. The data may
>> duplicate the points for each triangle. clean polydata will remove duplicate
>> points.
>>
>> On Fri, Jul 6, 2012 at 5:21 AM, Mika Fischer <mika.fischer at zoopnet.de>
>> wrote:
>>>
>>> Hi,
>>>
>>> first of all I have to say that is the first time that I use vtk and I
>>> don't have much experience with 3D graphics.
>>>
>>> I have a 3d triangle mesh of a face in wrl format. I also managed to
>>> display it. However the shading of the triangles seems to be flat.
>>> Calling SetInterpolationToGouraud() or SetInterpolationToFlat() seems
>>> to make no difference.
>>>
>>> The code used to load the data and display it is below. Am I missing
>>> an important step here?
>>>
>>> Also, if I load the file in ParaView, it has the same issue and
>>> switching from Flat to Gouraud makes no visible difference. However if
>>> I use a CylinderSource, the shading is smooth as I would expect it
>>> (and switching to flat makes a huge difference).
>>>
>>> Here's a screenshot of the data in paraview: http://zoopnet.de/vrml.png
>>>
>>> Any tips would be very much appreciated!
>>>
>>> Best,
>>>  Mika
>>>
>>> -------------------------------------
>>> vtkSmartPointer<vtkVRMLImporter> importer =
>>> vtkSmartPointer<vtkVRMLImporter>::New();
>>> importer->SetFileName(fileWrl.c_str());
>>> importer->Read();
>>> importer->Update();
>>>
>>> vtkActorCollection* actors = importer->GetRenderer()->GetActors();
>>> actors->InitTraversal();
>>> vtkDataSet* pDataset = actors->GetNextActor()->GetMapper()->GetInput();
>>>
>>> vtkPolyData* polyData = vtkPolyData::SafeDownCast(pDataset);
>>> polyData->Update();
>>>
>>> vtkSmartPointer<vtkPolyDataNormals> skinNormals =
>>> vtkSmartPointer<vtkPolyDataNormals>::New();
>>> skinNormals->SetFeatureAngle(90.0);
>>> skinNormals->SetInput(polyData);
>>> skinNormals->Update();
>>>
>>> vtkSmartPointer<vtkPolyDataMapper> solidMapper =
>>> vtkSmartPointer<vtkPolyDataMapper>::New();
>>> solidMapper->SetInputConnection(skinNormals->GetOutputPort());
>>> solidMapper->ScalarVisibilityOff();
>>>
>>> vtkSmartPointer<vtkActor> solidActor = vtkSmartPointer<vtkActor>::New();
>>> solidActor->SetMapper(solidMapper);
>>> solidActor->GetProperty()->SetInterpolationToGouraud();
>>>
>>> -------------------------------------
>>> _______________________________________________
>>> 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
>>
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>>



More information about the vtkusers mailing list