self.window.resize(800,600) # Get OpenGL 4.1 context glformat = QGLFormat() glformat.setVersion(4, 1) glformat.setProfile(QGLFormat.CoreProfile) glformat.setDoubleBuffer(False) self.glwidget = MyGlWidget(renderer, glformat, self) self.window.setCentralWidget(self.glwidget) self.window.show() def __enter__(self): "setup for RAII using 'with' keyword" return self def __exit__(self, type_arg, value, traceback): "cleanup for RAII using 'with' keyword" self.glwidget.disposeGL() def run_loop(self): retval = self.exec_() sys.exit(retval) if __name__ == "__main__": from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor actor = ColorCubeActor() renderer = OpenVrGlRenderer(actor) with QtPysideApp(renderer, "PySide OpenVR color cube") as qtPysideApp: qtPysideApp.run_loop()
#!/bin/env python # file hello_glfw.py from openvr.glframework.glfw_app import GlfwApp from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from openvr.tracked_devices_actor import TrackedDevicesActor """ Minimal glfw programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": renderer = OpenVrGlRenderer(multisample=2) renderer.append(ColorCubeActor()) controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = False renderer.append(controllers) with GlfwApp(renderer, "glfw OpenVR color cube") as glfwApp: glfwApp.run_loop()
#!/bin/env python # file qt_pyside_app.py import sys from openvr.glframework.qt_pyside_app import QtPysideApp """ Toy PySide application for use with "hello world" examples demonstrating pyopenvr """ if __name__ == "__main__": from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from openvr.tracked_devices_actor import TrackedDevicesActor renderer = OpenVrGlRenderer() renderer.append(ColorCubeActor()) renderer.append(TrackedDevicesActor(renderer.poses)) with QtPysideApp(renderer, "PySide OpenVR color cube") as qtPysideApp: qtPysideApp.run_loop()
#!/bin/env python # file hello_glfw.py from openvr.glframework.glfw_app import GlfwApp from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from openvr.tracked_devices_actor import TrackedDevicesActor """ Minimal glfw programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": renderer = OpenVrGlRenderer(multisample=2) renderer.do_mirror = True renderer.append(ColorCubeActor()) controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = False renderer.append(controllers) with GlfwApp(renderer, "glfw OpenVR color cube") as glfwApp: glfwApp.run_loop()
#!/bin/env python # file hello_cyglfw3.py import OpenGL OpenGL.ERROR_CHECKING = False OpenGL.ERROR_LOGGING = False OpenGL.ERROR_ON_COPY = True from openvr.glframework.cyglfw3_app import CyGLFW3App from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor """ Minimal glfw programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": actor = ColorCubeActor() renderer = OpenVrGlRenderer(actor) renderer.do_mirror = True with CyGLFW3App(renderer, "glfw OpenVR color cube") as app: app.run_loop()
self.translation_history.popleft() return result if __name__ == "__main__": obj = ObjMesh(open("root_997.obj", 'r')) # invert up/down, so brain is dorsal-up obj.model_matrix *= ( (1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0), (-0.5, 1.5, 0.5, 1), ) # obj = ObjMesh(open("AIv6b_699.obj", 'r')) renderer = OpenVrGlRenderer(multisample=2) renderer.append(SkyActor()) # renderer.append(ColorCubeActor()) controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = True renderer.append(controllers) renderer.append(obj) renderer.append(FloorActor()) interactor = SpatialInteractor() with GlfwApp(renderer, "mouse brain") as glfwApp: while not glfw.window_should_close(glfwApp.window): glfwApp.render_scene() # Update controller drag state when buttons are pushed interactor.update_controller_states() # update_scene_geometry(interactor)
#!/bin/env python # file hello_glut_controllers.py from openvr.glframework.glut_app import GlutApp from openvr.gl_renderer import OpenVrGlRenderer from openvr.tracked_devices_actor import TrackedDevicesActor from openvr.color_cube_actor import ColorCubeActor """ Minimal glut programming example showing a colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": renderer = OpenVrGlRenderer(multisample=4) renderer.append(ColorCubeActor()) controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = False renderer.append(controllers) with GlutApp(renderer, "Controller test") as glutApp: glutApp.run_loop()
#!/bin/env python # file hello_glfw.py import OpenGL OpenGL.ERROR_CHECKING = False OpenGL.ERROR_LOGGING = False OpenGL.ERROR_ON_COPY = True from openvr.glframework.cyglfw3_app import CyGLFW3App from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from openvr.tracked_devices_actor import TrackedDevicesActor """ Minimal glfw programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": renderer = OpenVrGlRenderer(multisample=2) renderer.do_mirror = True renderer.append(ColorCubeActor()) controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = False renderer.append(controllers) with CyGLFW3App(renderer, "glfw OpenVR color cube") as app: app.run_loop()
self.program = 0 glDeleteVertexArrays(1, (self.vao,)) self.vao = 0 ################################################################################################################################ # Main Code # ################################################################################################################################ if __name__ == "__main__": # Create a socket and have it listening at the following port context = zmq.Context() socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") # Wait for data from client - in this case the vertex data needed to render the models onto the Vive message = socket.recv() # Set up the Blender scene needed to be rendered on the display actor = Actor([float(a) for a in message.decode("utf-8").split()]) renderer = OpenVrGlRenderer(actor) # Show the positions of the Vive controllers within the headset controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = False renderer.append(controllers) # Render glutApp = GlutApp(renderer, b"glut OpenVR color cube") glutApp.run_loop()
#!/bin/env python # file hello_sdl2.py from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from openvr.glframework.sdl_app import SdlApp """ Minimal sdl programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": renderer = OpenVrGlRenderer(multisample=2) renderer.append(ColorCubeActor()) with SdlApp(renderer, "sdl2 OpenVR color cube") as app: app.run_loop()
#!/bin/env python # file hello_wx.py from openvr.gl_renderer import OpenVrGlRenderer from openvr.color_cube_actor import ColorCubeActor from openvr.glframework.wx_app import WxApp """ Minimal wxPython programming example which colored OpenGL cube scene that can be closed by pressing ESCAPE. """ if __name__ == "__main__": # Show a blue OpenGL window actor = ColorCubeActor() renderer0 = OpenVrGlRenderer(actor, (800,600)) with WxApp(renderer0, "wx OpenVR color cube") as app: app.run_loop()
self.translation_history.append( (translation, time_stamp,) ) while len(self.translation_history) > self.max_history_size: self.translation_history.popleft() return result if __name__ == "__main__": obj = ObjMesh(open("root_997.obj", 'r')) # invert up/down, so brain is dorsal-up obj.model_matrix *= ((1,0,0,0), (0,-1,0,0), (0,0,-1,0), (-0.5,1.5,0.5,1), ) # obj = ObjMesh(open("AIv6b_699.obj", 'r')) renderer = OpenVrGlRenderer(multisample=2) renderer.append(SkyActor()) # renderer.append(ColorCubeActor()) controllers = TrackedDevicesActor(renderer.poses) controllers.show_controllers_only = True renderer.append(controllers) renderer.append(obj) renderer.append(FloorActor()) interactor = SpatialInteractor() with GlfwApp(renderer, "mouse brain") as glfwApp: while not glfw.window_should_close(glfwApp.window): glfwApp.render_scene() # Update controller drag state when buttons are pushed interactor.update_controller_states() # update_scene_geometry(interactor)