pyvista / pyvista

3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)
https://docs.pyvista.org
MIT License
2.74k stars 504 forks source link

OpenVR Support #196

Open banesullivan opened 5 years ago

banesullivan commented 5 years ago

We should implement a way to send scenes to OpenVR much like ParaView's "Send to Open VR" plugin.

This is totally doable. See this post for insight: https://discourse.vtk.org/t/python-rendering-scene-to-vr/340

and: https://blog.kitware.com/using-virtual-reality-devices-with-vtk/

This would be implemented in a separate project, perhaps called pyvista_vr

MBrandt-NASA commented 4 years ago

I would love to see a nice, simple OpenVR interface created for PyVista!! :)

banesullivan commented 4 years ago

To my knowledge, we'd just need a custom build of VTK with OpenVR enabled. Perhaps just a slight modification to https://github.com/conda-forge/vtk-feedstock to enable the RenderingOpenVR module or set up a custom build with labels similar to what is proposed in https://github.com/conda-forge/vtk-feedstock/issues/90

Once we have a built version of the VTK python bindings with OpenVR enabled, the rest should be easy. We'd just need to add a configuration option in PyVista to use the vtkOpenVRRenderWindow, vtkOpenVRRenderer, vtkOpenVRRenderWindowINteractor, and vtkOpenVRCamera classes in just few places in PyVista. I don't think we'd even need a separate module.

Unfortunately, I no longer have access to a Windows VR-ready PC, so I can't test this out 😞 by building VTK locally. @MBrandt-NASA, if you have a VR ready machine and are willing to build VTK locally from its master branch, then I should be able to push some code to a branch in PyVista that would make it work for you to test out; let me know.

MBrandt-NASA commented 4 years ago

Hi @banesullivan, yes I have a good Windows 10 VR-enabled PC and a Vive Pro. I could build VTK from source using CMake and VS 2019. I haven't built VTK before, but I suppose I should follow: https://vtk.org/Wiki/VTK/Building/Windows

It would be really cool to see the output from PyVista in VR. I'm particularly interested in the point cloud applications of PyVista and seeing them in VR... perhaps along the lines of: http://www.open3d.org

VTK of course has such a huge library of algorithms that it would be great to use for point cloud visualization in VR... particularly real-time interaction / live modification of data being visualized, assuming PyVista can do that. I just came across PyVista recently -- love the simplicity of the Python interface. 🙂

Also, being able to interact with PyQt displays / widgets in VR would be a killer feature. 😉

banesullivan commented 4 years ago

Just an FYI, you might be able to simplify things by cloning the vtk feedstock, editing the config to turn on RenderingOpenVR module, and using conda-build (conda build recipe) to build VTK.

The only thing I am unsure of is exactly where to turn on RenderingOpenVR... perhaps here... I just don't know what the actual option is called, so I asked here

MBrandt-NASA commented 4 years ago

Cool @banesullivan, thanks for those ideas, and for asking about turning on RenderingOpenVR. 🙂

banesullivan commented 4 years ago

update if you want to give it a try:

VTK_MODULE_ENABLE_VTK_RenderingOpenVR

banesullivan commented 4 years ago

FYI: with the new wheel generating process in VTK9 building with the OpenVR option should be as simple as:

$ cmake -GNinja -DVTK_BUILD_TESTING=OFF -DVTK_WHEEL_BUILD=ON -DVTK_PYTHON_VERSION=3 -DVTK_WRAP_PYTHON=ON -DVTK_MODULE_ENABLE_VTK_RenderingOpenVR=YES ../VTK
$ ninja

and of course, you will need OpenVR on your system