I can't make openvr and vtk python work together. Currentrly i'm using spyder ide for this.
I have done some code in C++ with vtk and openvr just changing vtkRenderer to vtkOpenVRRenderer and so on. But it doesn't work in spyder.
import vtk
import openvr
class vtk:
colors = vtk.vtkNamedColors()
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName("D:\\UNAM\\MultiBlockDataSet\\Dist\\Distancias_00_0.vtp")
reader.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(reader.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(colors.GetColor3d('Tan'))
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
ren.SetBackground(colors.GetColor3d('AliceBlue'))
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(actor)
iren.Initialize()
renWin.Render()
ren.GetActiveCamera().SetPosition(-0.5, 0.1, 0.0)
ren.GetActiveCamera().SetViewUp(0.1, 0.0, 1.0)
renWin.Render()
iren.Start()
if __name__ == "__main__":
vtk()
Check out this post and maybe follow up on the VTK Discourse: https://discourse.vtk.org/t/python-rendering-scene-to-vr/340
EDIT: Here is some more info because linked answers are considered lame.
You'll need to replace the following classes:
If you have further VTK-related questions, I would highly recommend joining the VTK discourse as it is the most active community around VTK
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.