Use VTK 9.0 to quickly and easily write a Python script to create your own 3D scene and visualize it on a Looking Glass holographic display!
Kitware has partnered with Looking Glass Factory to bring the power of VTK to their innovative holographic displays. This partnership enables you to see your data in 3D without the need for special glasses or headgear! Furthermore, with VTK 9.0, creating custom scenes and rendering them onto a Looking Glass holographic display can be accomplished in Python, with only a few lines of code!
Here is an example of VTK Python code for rendering text and a cone onto a holographic display, as shown in the video.
import vtk # Declare a VTK rendering process ren = vtk.vtkRenderer() # Use the following line to render to a standard display: # renWin = vtk.vtkRenderWindow() # Use the following line to render to a Looking Glass display: renWin = vtk.vtkLookingGlassInterface.CreateLookingGlassRenderWindow() # Add the rendering process to the window renWin.AddRenderer(ren) # The mouse controls the position of the camera iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) # Add some text to the display text = vtk.vtkVectorText() text.SetText("Hello VTK!") textMapper = vtk.vtkPolyDataMapper() textMapper.SetInputConnection(text.GetOutputPort()) textActor = vtk.vtkActor() textActor.SetMapper(textMapper) ren.AddActor(textActor) # Position a cone above the text cone = vtk.vtkConeSource() cone.SetRadius(2) cone.SetHeight(4) cone.SetCenter(4,4,2) cone.SetDirection(0,0,1) coneMapper = vtk.vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) coneActor = vtk.vtkActor() coneActor.SetMapper(coneMapper) ren.AddActor(coneActor) # Initialize the window renWin.Initialize() ren.ResetCamera() ren.GetActiveCamera().SetViewAngle(30) # The mouse controls the camera until "q" is pressed to exit iren.Start()
This code is also available as a Python Jupyter Notebook on Github.
To use this Python code with VTK 9.0, you will need to compiled VTK with the “VTK_WRAP_PYTHON” and the “VTK_MODULE_ENABLE_VTK_RenderingLookingGlass” modules enabled during CMake configuration. Future versions of VTK will provide a pip installable version of VTK with the Looking Glass module already enabled.
Beyond Python: if you are looking to visualize your data on a Looking Glass display without having to write any code, ParaView or 3D Slicer may be exactly what you need. Otherwise, you can contact us at email@example.com to have us create a custom solution for you.