Chapter 6. MiddleVR for Unity3D

Table of Contents

Unity coordinate system
Adding MiddleVR to your Unity3D application
Import the MiddleVR package
Add the VR manager to your project
The VR manager
VR Manager properties
Force Player Quality
Running your application in the Unity editor
Exporting to a standalone player
Additionnal parameters for active stereo (OpenGL Quad-Buffer)
Running your application as a standalone application
How to attach your nodes in the VR hierarchy ?
Grab existing nodes
Attach to node
Wand interactions
Navigation Collision
VR First Person Controller
Programming interaction
Creating an interaction script
Input devices
Accessing wand data
The display manager
Converting data from MiddleVR to Unity3D
Debugging with MonoDevelop



The core of MiddleVR has no knowledge of a particular 3D engine.

This means that for each 3D engine, a small interface has to be created. This interface will make the bridge between MiddleVR on one side, and the 3D engine on the other side. It will configure 3D nodes, viewports, and give access to devices.

Typically, this bridge is based both on the MiddleVR API and the host 3D engine API. It will gather information from MiddleVR and use that to configure the 3D engine.

For example, the interface will load a particular configuration file, ask MiddleVR for the number of nodes, their properties, and create those nodes as 3D nodes from the 3D engine. In Unity3D, this will translate MiddleVR 3D Nodes as GameObjects.

The interface will also read information about viewports, cameras, and everything needed to create a VR experience.

Each frame, MiddleVR will then update all the nodes and camera it has created inside Unity with the values from the devices and the computations of the camera's projection matrix.

Note: By default MiddleVR will disable all your cameras and only work with the cameras you've defined in MiddleVR.

Note: Before exporting your application to a standalone player, make sure to read the "Exporting to a standalone player" section below.

Unity coordinate system

As said previously, MiddleVR uses a right-handed coordinate system, where X is pointing to the right, Y is pointing away from the user towards the screen and Z pointing up :

Unity's coordinate system is left-handed, with X pointing to the right, Y pointing up, and Z pointing away from the user, towards the screen :

When updating Unity's nodes and cameras, MiddleVR will automatically convert the 3D information from one coordinate system to the other.

But when you read the information of a MiddleVR node or of a 3D tracker directly from MiddleVR from a Unity script, it will be in MiddleVR's coordinate system. You then have to convert this 3D information into Unity's coordinate system. MiddleVR provides methods to do exactly that. See section "Input devices".