Advertisement
Guest User

Untitled

a guest
Oct 4th, 2018
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <vtkCylinderSource.h>
  3. #include <vtkPolyDataMapper.h>
  4. #include <vtkActor.h>
  5. #include <vtkRenderer.h>
  6. #include <vtkRenderWindow.h>
  7. #include <vtkRenderWindowInteractor.h>
  8. #include <vtkProperty.h>
  9. #include <vtkCamera.h>
  10. #include <vtkSmartPointer.h>
  11. #include <vtkNew.h>
  12. #include <vtkOpenVRRenderWindow.h>
  13. #include <vtkOpenVRRenderer.h>
  14. #include <vtkOpenVRRenderWindowInteractor.h>
  15. #include <vtkOpenVRCamera.h>
  16.  
  17. int main(int, char *[])
  18. {
  19.   // This creates a polygonal cylinder model with eight circumferential facets
  20.   // (i.e, in practice an octagonal prism).
  21.   vtkNew<vtkCylinderSource> cylinder;
  22.   cylinder->SetResolution(8);
  23.  
  24.   // The mapper is responsible for pushing the geometry into the graphics library.
  25.   // It may also do color mapping, if scalars or other attributes are defined.
  26.   vtkNew<vtkPolyDataMapper> cylinderMapper;
  27.   cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
  28.  
  29.   // The actor is a grouping mechanism: besides the geometry (mapper), it
  30.   // also has a property, transformation matrix, and/or texture map.
  31.   // Here we set its color and rotate it around the X and Y axes.
  32.   vtkNew<vtkActor> cylinderActor;
  33.   cylinderActor->SetMapper(cylinderMapper);
  34.   cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
  35.   auto interpolation = cylinderActor->GetProperty()->GetInterpolation();
  36.   std::cout << "The default Interpolation mode is " << interpolation << std::endl;
  37.   cylinderActor->GetProperty()->SetInterpolationToFlat();
  38.   cylinderActor->RotateX(30.0);
  39.   cylinderActor->RotateY(-45.0);
  40.  
  41.   // The renderer generates the image
  42.   // which is then displayed on the render window.
  43.   // It can be thought of as a scene to which the actor is added
  44.   vtkNew<vtkOpenVRRenderer> renderer;
  45.   renderer->AddActor(cylinderActor);
  46.   renderer->SetBackground(0.1, 0.2, 0.4);
  47.   // Zoom in a little by accessing the camera and invoking its "Zoom" method.
  48.   renderer->ResetCamera();
  49.   renderer->GetActiveCamera()->Zoom(1.5);
  50.  
  51.   // The render window is the actual GUI window
  52.   // that appears on the computer screen
  53.   vtkNew<vtkOpenVRRenderWindow> renderWindow;
  54.   renderWindow->SetSize(200, 200);
  55.   renderWindow->AddRenderer(renderer);
  56.  
  57.   // The render window interactor captures mouse events
  58.   // and will perform appropriate camera or actor manipulation
  59.   // depending on the nature of the events.
  60.   vtkNew<vtkOpenVRRenderWindowInteractor> renderWindowInteractor;
  61.   renderWindowInteractor->SetRenderWindow(renderWindow);
  62.  
  63.   // This starts the event loop and as a side effect causes an initial render.
  64.   renderWindowInteractor->Start();
  65.  
  66.   return EXIT_SUCCESS;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement