Guest User

Untitled

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