Tango’s hardware and software provide motion tracking and the cordless design allows you to physically walk around in VR instead of using WASD or a game controller to move about. You can walk forward, backward, jump up or crouch down low and the Tango will figure out your position and rotation within the 3D model. (Good luck not bumping into walls though!)
The lenses and divider panel within the Dive headset work to compartmentalize the 3D view into the two separate images your eyes are already used to seeing. However, the virtual camera viewing the 3D scene must be set up to work with this paradigm. The rendering engine of choice will likely provide a way to set up stereoscopic viewports with a little work. Durovis has developed a simple example setup for Unity 3D which you can download from item 2 in the list below.
To take your Tango for a spin
in VR you’ll need:
- A 3D scene (Don't have one? Use one of ours!)
Prep: Get the Android SDK
To avoid the confusion of “go here and install this, oh but first do this, and oh wait, that also needs this, but do this first”—make sure you have the latest stable JDK (Java SE Development Kit). Unless you are familiar with SDK development, I recommend the standalone Android Developer SDK, listed under SDK Tools Only.
Once that it installed, you will have access to the SDK Manager for Android. Be sure to run it as administrator if you are on Windows, or some of the required packages and updates will not install. Follow these instructions for updating and installing the required packages. You probably don’t want to close the manager until the end of the tutorial, as you may have to go back to it.
Select the Google USB Drivers and install those from the SDK Manager as well. These don’t actually install the drivers for your device, however. You have to do that manually. I had trouble doing this through all of the usual ways, for whatever reason. I was able to get my co-worker’s android phone to recognize and build rather easily, but the Tango refused to be noticed properly. This tutorial has a slightly circuitous method that can help with the more difficult devices.
Step 1: Get Unity and Setup for Android Development
If you don’t already have Unity, you can get it here. Make sure to download the 64-bit version. Once Unity is installed, you need to set up external tools for Android Development (Item 4) through Unity > Edit > Preferences. Also, take a minute to make sure the JDK is installed as well.
At this point, you should test building to your device to be sure that everything is working as expected. I would simply add a cube to the middle of the bank scene, and go to file > Build Settings. Then, double click on the android option, go to “player settings” and set Minimum API Level to 17. Select build and run, and pray to Google it works! (Obviously, have your device plugged in at this point.)
If it doesn’t run, take a minute to make sure your Tango Tablet Debugging Options are on and that you are using your Tango admin account.
Step 2: Download Dive Example Project and Open Scene
You’ll need to set up your stereoscopic view so when you put the Dive on, the scene looks like it’s in 3D. The easiest way to set up two cameras for 3D is to download Durovis’ Unity example game, Dive Unity Demo Project 2.1. Another way is to add two cameras to the scene and set them up for stereoscopy.
We’re going to use the Dive code so download the project and open it up in Unity. Go into the Assets > DiveUnityDemo folder and open up the DiveUnityDemo scene. Alternatively, you can download and import the Dive Unity Package 2.1 into your own project instead. You won’t find a demo scene, or FPS Player, but there will be a Dive_Camera prefab that you can import into your own scene.
There are two important Game Objects in the scene: the DiveFPSPlayer, which has a Dive_Camera which sets up the stereoscopic view mode, and a Cubeworld 3D scene, which we can replace with our own 3D scene later.
In the Dive FPS Player GameObject Inspector, disable the Dive FPSController script by unchecking the checkbox next to the component script name.
In the Dive_Camera, disable the OpenDiveSensor script and Mouse Look scripts by unchecking the checkboxes next to the component script name.
Step 3: Setup Project Tango Plugin
Download the Project Tango Unity plugin. Follow the Tango motion tracking tutorial to set up the Tango Manager and build settings for Android. Once it starts talking about the SampleController.cs, it is out of date -- return to this tutorial.
SampleController.cs is sample code for figuring out where a camera is in 3D space - its pose. As of Tango 1.10 Leibniz, the SampleController.cs script mentioned in the guide is available on Github as PoseController.cs.
Create a script called PoseController.cs, copy and paste the code inside, and attach it to the Dive_Camera GameObject, which is a child object of Dive FPS Player.
Step 4: Setup 3D model
Now you can import your own models and program your own game functionality! Here's an example package of our scan results. Import the package.
Disable CubeWorld and drag the KidsRoom_Pieces Prefab from the Prefabs directory into the scene. Place the DiveFPSPlayer at 0,0,0. Move the prefab around in the scene until the camera seems to be at eye height. Tango Pose Controller forces a 0,0,0 start position so keep that in mind when placing your scene geometry.
Connect the Dive_Camera object (not the Dive FPS Player) to the Player Object node in the Kids Room prefab's ResetDivePosition script by dragging the object from the scene hierarchy to the empty field in the inspector.
Add a Box Collider and a Rigidbody Controller to the Dive_Camera object. Uncheck Use Gravity in the Rigidbody controller. Check Is Kinematic.
If you have your own 3D model (or if you're using the one we provided), you can disable the existing Cubeworld model by unchecking the check box and use your own model instead! You may want to add a rigidbody and box collider to this model and add our ResetDivePosition script and copy our prefab setup in order to keep the dive player inside the bounds of your scene, but this is not required.
Lastly, our prefab has included a ProjectionOffset.cs script, which you can find the original code for here. This script needs to be added to each of the left and right cameras that are children of the Dive_Camera asset in your scene. For the Left camera, adjust the “Right” projection value to 0.1, and for the Right camera, adjust the “Left” projection value to -0.1. This script adjusts the center of the camera projection. The values we chose most closely mimic that of your eyes. You may adjust these values and the offset values in the Dive SDK’s own Offset Center script to see if you can find values that suit you specifically. The individual nature of what makes these values work is a part of why the Oculus has a user calibration feature. However, the superior mobility of the Dive lenses account for some of this individual need.
Step 5: Build
Set the Player Platform to Android, then Build And Run.
Step 6: Take it For a Spin!
Secure the tablet inside the headset and start walking around! (Be sure to start the application with the tablet facing forward and not toward the ground or it may drop you through the virtual floor!)
This tutorial was written in part by Andrew Silver, a former intern, who loves using his hacking skills for exploration.