[vtkusers] Textures on polydata.

Randall Hand randall.hand at gmail.com
Mon Feb 7 09:43:40 EST 2005


STL's have no stored texture data, so all the texture coordinates are
missing.  In order to generate texture coordinates, you'll need to use
something like vtkTextureMapToPlane .  There's also MapToSphere and
MapToCylinder which will generate coordinates in a slightly differen
fashion.




On Mon, 7 Feb 2005 13:49:29 +0100, Thomas Sundgaard Pedersen
<sundgaard at inropa.com> wrote:
>  
>  
> 
> Hi, 
> 
>   
> 
> I am new to visualization, and was trying to add textures to some stl-files,
> that I imported. It worked fine with a vtkPlaneSource as input to the
> vtkPolyDataMapper, but didn't work with vtkSTLReader as input. The actor is
> showen in the vtk window and represents the stl-file as it should, but if I
> set the texture, I only get the whole actor colored in the color of the
> bmp's first pixel, it seems? 
> 
> This code shows how I implemented it: 
> 
>   
> 
>             vtkWin32OpenGLRenderWindow *renWin =
> vtkWin32OpenGLRenderWindow::New(); 
> 
>             vtkRenderer *ren = vtkRenderer::New(); 
> 
>             vtkSTLReader  *STLReader = vtkSTLReader::New(); 
> 
>             vtkPolyDataMapper  *mapper = vtkPolyDataMapper::New(); 
> 
>             vtkActor  *actor = vtkActor::New(); 
> 
>             vtkBMPReader* bmpReader = vtkBMPReader::New(); 
> 
> vtkTexture* atext = vtkTexture::New(); 
> 
>   
> 
> renWin->AddRenderer(ren); 
> 
>   
> 
>             STLReader->SetFileName("..\\parts\\bumper.stl"); 
> 
>             mapper->SetInput(this->m_pSTLReader->GetOutput()); 
> 
>             actor->SetMapper(this->m_pMapper); 
> 
>   
> 
>             ren->AddActor(actor);     
> 
>   
> 
>             bmpReader->SetFileName("..\\res\\rawmetal_160x160.bmp"); // 160
> x 160 pixles. 
> 
>             atext->SetInput(bmpReader->GetOutput()); 
> 
>             atext->InterpolateOn(); 
> 
>   
> 
> actor->SetTexture(atext); //Works fine with vtkPlaneSource, but not with
> vtkSTLReader? 
> 
>   
> 
> renWin->render(); 
> 
>   
> 
> If I want to use textures on stl-files what do I do, or isn't it possible at
> all? 
> 
>   
> 
> greets 
> 
>    Thomas 
> 
>   
> 
>   
> 
>   
> _______________________________________________
> 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
> 
> 
> 


-- 
Randall Hand
http://www.yeraze.com



More information about the vtkusers mailing list