All Projects → harfang3d → vr-python-quickstart-hg1

harfang3d / vr-python-quickstart-hg1

Licence: MIT license
VR Headset Controller Tutorial, get started with virtual reality in Python

Programming Languages

python
139335 projects - #7 most used programming language
Inno Setup
370 projects

Projects that are alternatives of or similar to vr-python-quickstart-hg1

hobo vr
SteamVR driver prototyping tool
Stars: ✭ 44 (+51.72%)
Mutual labels:  vr, openvr, virtual-reality
Viro
ViroReact: AR and VR using React Native
Stars: ✭ 1,735 (+5882.76%)
Mutual labels:  vr, virtualreality, virtual-reality
Simple-OpenVR-Driver-Tutorial
A sample OpenVR Driver for you to learn from
Stars: ✭ 157 (+441.38%)
Mutual labels:  vr, openvr, virtual-reality
Aframe
🅰️ web framework for building virtual reality experiences.
Stars: ✭ 13,428 (+46203.45%)
Mutual labels:  vr, virtualreality, virtual-reality
aframe-registry
[DISCONTINUED] Curated collection of community A-Frame components.
Stars: ✭ 76 (+162.07%)
Mutual labels:  vr, virtualreality, virtual-reality
a-blast
💥 Save the World From the Cutest Creatures in the Universe!
Stars: ✭ 116 (+300%)
Mutual labels:  vr, virtualreality, virtual-reality
HadesVR
The "DIY" SteamVR compatible VR setup made for tinkerers.
Stars: ✭ 88 (+203.45%)
Mutual labels:  vr, virtual-reality
AnotherBadBeatSaberClone
This is a discontinued but perhaps helpful VR project created during my Master's degree at FH Wedel.
Stars: ✭ 22 (-24.14%)
Mutual labels:  vr, virtual-reality
daydream-node
Quick Node.js module to connect to the Daydream controller and receive all the data
Stars: ✭ 17 (-41.38%)
Mutual labels:  vr, virtual-reality
island-viz
IslandViz: A Tool for Visualizing Modular Software Systems in Virtual Reality
Stars: ✭ 17 (-41.38%)
Mutual labels:  vr, virtual-reality
UnityPlugin
Ultraleap SDK for Unity.
Stars: ✭ 447 (+1441.38%)
Mutual labels:  vr, virtual-reality
OpenXR-Hpp
Open-Source OpenXR C++ language projection
Stars: ✭ 25 (-13.79%)
Mutual labels:  vr, virtual-reality
vrtist
Virtual Reality tool for storytelling
Stars: ✭ 43 (+48.28%)
Mutual labels:  vr, virtual-reality
SlimeVR-Server
Server app for SlimeVR ecosystem
Stars: ✭ 361 (+1144.83%)
Mutual labels:  vr, virtual-reality
LifeBrush
A toolkit for painting agent-based mesoscale molecular simulations and illustrations.
Stars: ✭ 38 (+31.03%)
Mutual labels:  vr, virtual-reality
zephyr
Mirror Android notifications to VR
Stars: ✭ 78 (+168.97%)
Mutual labels:  vr, openvr
TurnSignal
An anti-cable-twisting management utility for SteamVR.
Stars: ✭ 73 (+151.72%)
Mutual labels:  vr, openvr
janusweb
An in-browser implementation of JanusVR
Stars: ✭ 145 (+400%)
Mutual labels:  vr, virtual-reality
g3r
3D, VR and AR Maps in R
Stars: ✭ 19 (-34.48%)
Mutual labels:  vr, virtual-reality
webvrrocks
Your guide to Virtual Reality in the browser.
Stars: ✭ 116 (+300%)
Mutual labels:  vr, virtual-reality

OpenVR HARFANG® 3D

WARNING

This project is aimed at HARFANG® 3D engine version 1.x.x. It is now superseded by HARFANG® 3D 2.0. Please check the updated tutorials/code snippets.

OpenVR VR Headset Controller Tutorial

VR_setup

Requirements

HARFANG® 3D >= 1.2.0

On Windows, retrieve HARFANG® 3D using PIP

pip install -r requirements.txt

On others systems, retrieve the last wheel on HARFANG® 3D website.

pip install harfang.whl

Setup

To enable the VR in HARFANG we need to switch to a specific FrameRenderer.
First, we ask if the frame renderer plugin called "VR" is available.

openvr_frame_renderer = hg.CreateFrameRenderer("VR")

Then we initialize the renderer to setup OpenVR system. It can return true or false.

if openvr_frame_renderer.Initialize(plus.GetRenderSystem()):

Once initialized, we add the system in the scene which will take care of the update of the head/controllers matrices and the rendering with the correct transformation.

scn.GetRenderableSystem().SetFrameRenderer(openvr_frame_renderer)

Update controllers matrices

HARFANG® gives the controllers' matrices in the real world. The matrices relate to the VR calibration position.
To set the controllers' matrices in the virtual world, we need to multiply them by the position that represent the calibration center in the scene. From our point of view, this is the camera matrix.

In real world

Controller_position

In virtual world

Controller_position

Example:

To get the controller

  • "VR Controller 0" : Right handheld controller
  • "VR Controller 1" : Left handheld controller
  • "HMD" : headset controller
controller = hg.GetInputSystem().GetDevice("VR Controller 0")

To get the controller's matrix

controller_mat = controller.GetMatrix(hg.InputDeviceMatrixHead)

To set the controller's matrix to the geometry in the virtual world

virtual_controller_mat = cam_matrix * controller_mat
controller_node.GetTransform().SetWorld(virtual_controller_mat)

About headset matrix

If you need to get the matrix of the head, multiply the camera matrix by the headset matrix.

controller = hg.GetInputSystem().GetDevice("HMD")
controller_mat = controller.GetMatrix(hg.InputDeviceMatrixHead)
cam_matrix = scene.GetCurrentCamera().GetTransform().GetWorld()
head_mat = cam_matrix * controller_mat

Conclusion

That's it, you are now VR-enabled right within Python!
This tutorial using the HARFANG® engine was tested so far on the HTC Vive, the Oculus Rift and the Lenovo Mixer Reality headsets.
The same should apply to every OpenVR-compatible headset.

(Tutorial created by Eric Kernin, VR Teleporter by Thomas Simonnet).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].