[vtkusers] How to read and render a 3D model (OBJ) with textures?
agerlach
agerlach at gmail.com
Mon Jan 23 14:52:05 EST 2012
Well, I'm going to be able to partially answer your question. I do not know
how to handle MTL files, but I can tell you how to load a texture image and
then map it to the surface you loaded.
Depending on what the file extension of the texture is use the appropriate
filter to load it (in this case jpeg):
vtkSmartPointer<vtkJPEGReader> jpgReader =
vtkSmartPointer<vtkJPEGReader>::New();
jpgReader->SetFileName(NAME_OF_TEXTURE);
jpgReader->Update();
Then create and set a vtkTexture
vtkSmartPointer<vtkTexture> colorTexture =
vtkSmartPointer<vtkTexture>::New();
colorTexture->SetInputConnection(jpgReader->GetOutputPort());
colorTexture->InterpolateOn();
Then when you set your actor add the following where actor is a vtkActor:
actor->SetTexture(colorTexture);
I hope this helps!
--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-read-and-render-a-3D-model-OBJ-with-textures-tp5155310p5168406.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list