[vtkusers] vtkOBJReader example for C++
shayan moradkhani
shayan.moradkhani at gmail.com
Mon Jul 2 07:30:18 EDT 2018
int main(int, char *[])
{
std::string filename = "Part3.obj";
vtkSmartPointer<vtkOBJReader> reader =
vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(filename.c_str());
reader->Update();
// Visualize
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(.1, .3, .3); // Background color green
// Zoom in a little by accessing the camera and invoking its "Zoom" method.
renderer->ResetCamera();
//renderer->GetActiveCamera()->Zoom(1.5);
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(800, 600);
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
this is what i have. however, when i load in vtk, i have no idead where the
model is loaded (with respect to the global coordinate system). if i could
get its center, it would be easier i guess to apply transformation on the
object
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list