Introduction: Mobile Virtual Reality Using Processing for Android (TfCD)

Virtual Reality (VR) is one of the new technologies that could be interesting is future products. It has a lot of opportunities and you don't even need expensive VR glasses (Oculus Rift). It may seem very difficult to do yourself, but the basics are easier than it looks. If you have basic programming and modeling skills you can do it. We used Processing and Blender. This instructable is a step by step guide to program a simple VR environment on your phone. All you need is your Android phone, (cardboard) VR phone glasses and software (processing and 3D modeling software). At the end of this instructable, you will have a room with multiple (moving) objects.

Step 1: Before Starting

Before starting there are 3 things you need to do:
1. Download processing, from

2. Make sure your phone is set to developer mode:
This can be different per phone, below a couple of options are given:
Android: Settings > About phone > Build number
Samsung Galaxy: Settings > About device > Build number
LG: Settings > About phone > Software information > Build number
HTC One: Settings > About > Software information > More > Build number

When you find the Build number section of the settings, tap on the section 7 times. After the 7th tap, the phone will be in developer mode.

After this go to: setting > option for developers > enable USB debugging
Also, make sure that your phone accepts apps from unknown sources.

3. Download and extract the files from this tutorial. A zip file is included in which all the files are included as well as the files which include the 3D file data from the program we used (Blender). Download and unzip this folder and place it somewhere on your computer where you can find it. In Step 4 you will be asked to open the folder again.

Step 2: Setting Up Processing

Before you can begin you will have to set up processing to support android developing. The first step is to enable the processing android mode by clicking the java button in the upper right part of the sketch window. (image 1)

This will prompt you with a message. Click on the “download SDK automatically” and processing will start downloading all the files necessary to create Android apps. (image 2)

When this process is finished you will be able to create apps for android, which includes VR apps which we will be focussing on. In order to make this work you will have to select one more option. Go to Android and select the VR tab, this will make sure that the app includes all the necessary libraries when it is exported. (image 3)

Now you are ready to start working on your sketch

Step 3: Writing the Code

This tutorial is not about writing the code itself. But using the comments included in the code you will be able to understand what is happening.

Now you can open the .pde file which is included in the extracted folder which you have downloaded before. You will see the code open up and can take a good look at it.

Step 4: The 3D Model

We used Blender to make our model, this is a free modeling program ( or use a different modeling program. If you have no experience with modeling you can also find 3D models online ( folder with 3D models and code have already been created for you, but if you want to make your own project you will have to follow the following instructions.

- Create a data folder (called “data”) in the processing sketch folder. (Your sketch has to be saved first, make sure that you know where it is saved. By default in windows it is inside you documents/processing/name_of_sketch)

- Exporting: save your 3D model as a .obj file - Including the .mtl file which references to the textures (if you have any)

- In case you have textures, place them in the data folder as well and make sure the .mtl file references to them correctly. (.mtl files can be opened with notepad for example and contain plain text)

- note: A phone cannot handle very complex models or many textures so make sure the model is low poly and you include as few textures as possible. I tiled a texture on a plane and it made the sketch unbearably slow.

Step 5: Run on Device

Now you are ready to run the example on your mobile phone.

First, check under the tab android and devices if your device is showing up. If this is not the case make sure that you followed the steps in step 1 of this tutorial.

If the device shows up you are ready to hit the run on device button or use the shortcut ctrl+R.
Processing will start compiling the sketch and installing it on your mobile phone. If processing throws an error, check step one of this tutorial or check your code.

Step 6: Playing VR Simulation

Now you are done, the google cardboard app will launch and you can enjoy the glorious experience of mobile VR.

Step 7: Our Sources

The main set up of the app has been based on information from the following links. These contain great information about creating apps for Android using processing, including VR.

A great help in writing your processing code is the official site of processing, which includes a list of references.

If you need VR glasses you can buy them for very little money on for example:

Want to make a screen capture of your phone, you can use: