Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
- reader->SetFileName(filename.c_str());
- reader->Update();
- vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
- mapper->SetInputConnection(reader->GetOutputPort());
- // Read the image data from a file
- vtkSmartPointer<vtkJPEGReader> imgReader = vtkSmartPointer<vtkJPEGReader>::New();
- imgReader->SetFileName(texturePath.c_str());
- imgReader->Update();
- // Create texture object
- vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
- texture->SetInputConnection(imgReader->GetOutputPort());
- texture->InterpolateOn();
- vtkSmartPointer<vtkQuadricLODActor> actor = vtkSmartPointer<vtkQuadricLODActor>::New();
- actor->SetMapper(mapper);
- actor->GetProperty()->SetInterpolationToFlat();
- actor->SetTexture(texture);
- // A renderer and render window
- vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
- renderer->SetBackground(0.2, 0.3, 0.4);
- vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
- renderWindow->AddRenderer(renderer);
- // An interactor
- vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<
- vtkRenderWindowInteractor>::New();
- renderWindowInteractor->SetRenderWindow(renderWindow);
- renderWindowInteractor->SetDesiredUpdateRate(15);
- renderer->AddActor(actor);
- renderWindow->Render();
- renderWindowInteractor->Start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement