diff --git a/src/Cxx.md b/src/Cxx.md index a3850bac3590992b6ec3c330bb3ec5defe594b29..e21ba471dc2b9a522b531b3bf128a786f242de1e 100644 --- a/src/Cxx.md +++ b/src/Cxx.md @@ -182,6 +182,7 @@ If you are new to VTK then these [tutorials](#tutorial) will help to get you sta [OpenVROrientedCylinder](/Cxx/GeometricObjects/OpenVROrientedCylinder) | Show an oriented cylinder in VR using OpenVR. [OpenVRSphere](/Cxx/GeometricObjects/OpenVRSphere) | Show a sphere in VR using OpenVR. [OpenVRTessellatedBoxSource](/Cxx/GeometricObjects/OpenVRTessellatedBoxSource) | Show a tesselated box in VR using OpenVR. +[OpenXRCone](/Cxx/GeometricObjects/OpenXRCone) | Show a cone in VR using OpenXR. [PlaneSourceDemo](/Cxx/GeometricObjects/PlaneSourceDemo) | Display the instance variables that define a vtkPlaneSource. [Planes](/Cxx/GeometricObjects/Planes) | [PlanesIntersection](/Cxx/GeometricObjects/PlanesIntersection) | diff --git a/src/Cxx/GeometricObjects/CMakeLists.txt b/src/Cxx/GeometricObjects/CMakeLists.txt index 3d2123cb8f5065c3bd8dff877979724e2822a5f0..5830518603457f9e0d5582c85aa424bfefaddda7 100644 --- a/src/Cxx/GeometricObjects/CMakeLists.txt +++ b/src/Cxx/GeometricObjects/CMakeLists.txt @@ -50,6 +50,7 @@ Requires_Module(OpenVROrientedArrow RenderingOpenVR) Requires_Module(OpenVROrientedCylinder RenderingOpenVR) Requires_Module(OpenVRSphere RenderingOpenVR) Requires_Module(OpenVRTessellatedBoxSource RenderingOpenVR) +Requires_Module(OpenXRCone RenderingOpenXR) Requires_Module(ParametricObjectsDemo cli11) Requires_Module(ParametricObjectsDemo fmt) diff --git a/src/Cxx/GeometricObjects/OpenXRCone.cxx b/src/Cxx/GeometricObjects/OpenXRCone.cxx new file mode 100644 index 0000000000000000000000000000000000000000..92721be9e4a56bacfc02d96c51940efcd9fbea8b --- /dev/null +++ b/src/Cxx/GeometricObjects/OpenXRCone.cxx @@ -0,0 +1,38 @@ +#include <vtkActor.h> +#include <vtkConeSource.h> +#include <vtkNamedColors.h> +#include <vtkNew.h> +#include <vtkOpenXRRenderWindow.h> +#include <vtkOpenXRRenderWindowInteractor.h> +#include <vtkOpenXRRenderer.h> +#include <vtkPolyDataMapper.h> + +int main(int argc, char* argv[]) +{ + // Create a cone along with a mapper and actor for it + vtkNew<vtkConeSource> coneSource; + coneSource->Update(); + vtkNew<vtkNamedColors> colors; + vtkNew<vtkPolyDataMapper> mapper; + mapper->SetInputConnection(coneSource->GetOutputPort()); + vtkNew<vtkActor> actor; + actor->SetMapper(mapper); + + // Create OpenXR renderer, render window, and interactor + vtkNew<vtkOpenXRRenderer> renderer; + vtkNew<vtkOpenXRRenderWindow> renderWindow; + renderWindow->Initialize(); + renderWindow->AddRenderer(renderer); + vtkNew<vtkOpenXRRenderWindowInteractor> renderWindowInteractor; + renderWindowInteractor->SetRenderWindow(renderWindow); + + // Add the actors to the scene + renderer->AddActor(actor); + renderer->SetBackground(colors->GetColor3d("ForestGreen").GetData()); + + // Render and interact + renderWindow->Render(); + renderWindowInteractor->Start(); + + return EXIT_SUCCESS; +} diff --git a/src/Cxx/GeometricObjects/OpenXRCone.md b/src/Cxx/GeometricObjects/OpenXRCone.md new file mode 100644 index 0000000000000000000000000000000000000000..402b8676dec5cfbe675a222a7bef38b42f9eda81 --- /dev/null +++ b/src/Cxx/GeometricObjects/OpenXRCone.md @@ -0,0 +1,6 @@ +### Description + +This example demonstrates rendering of a Cone in OpenXR. + +!!! note "WINDOWS USERS" + For the interactions to work, you have to copy the `.json` manifest files from the subfolder Rendering/OpenXR in VTK's source to the working directory in which the example is run!