Skip to content

Commit

Permalink
Add Oculus Quest tutorial to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
skyace65 committed Jan 5, 2020
1 parent cba5770 commit 6a8656e
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 0 deletions.
163 changes: 163 additions & 0 deletions tutorials/vr/developing_for_oculus_quest.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
.. _doc_developing_for_oculus_quest:

Introduction
------------

This tutorial goes over how to get started developing for the
Oculus Quest with an official plugin.

First there are two things you need to do.

First you need to go through the steps on the :ref:`doc_exporting_for_android`
page. This leads you through installing the toolset that Godot
needs to export to Android devices.

Next you need the Quest Plugin. You can download it from the Asset
Library or manually download it from `here <https://github.com/GodotVR/godot-oculus-mobile-asset>`__.

Setting Up Godot
----------------

To get started Open up Godot and create a new project

.. image:: img/quest_new_project.png

Make sure to chose the GLES2 renderer. Due to optimisations in the
Quest's GPU this backend is far better suited for the Quest.

Copy the addons folder from the Oculus Mobile asset into your Godot
project. Your project tree should looks something like this:

.. image:: img/quest_project_tree.png

Now we can start building our main scene. To keep things simple
we'll stick to the bare minimum.

- We add an ARVROrigin node first.
- Then we add three child nodes to the origin node, one ARVRCamera and two ARVRControllers.
- Assign controller id 1 to the first ARVRController and rename that to LeftHand.
- Assign controller id 2 to the second ARVRController and rename that to RightHand.
- Finally we'll add a MeshInstance as a child node to our first ARVRController and create a box shape, resize the box so each side is set to 0.1. Now duplicate the MeshInstance and move it to the second ARVRController node. These will stand in for our controllers, we're keeping things really simple.

.. image:: img/quest_scene_tree.png

Now add a script to the main node and add the following code:

.. tabs::
.. code-tab:: gdscript GDScript

extends Spatial

onready var ovr_init_config = preload("res://addons/godot_ovrmobile/OvrInitConfig.gdns").new()
onready var ovr_performance = preload("res://addons/godot_ovrmobile/OvrPerformance.gdns").new()

var perform_runtime_config = false

func _ready():
var interface = ARVRServer.find_interface("OVRMobile")
if interface:
ovr_init_config.set_render_target_size_multiplier(1)

if interface.initialize():
get_viewport().arvr = true

func _process(_delta):
if !perform_runtime_config:
ovr_performance.set_clock_levels(1, 1)
ovr_performance.set_extra_latency_mode(1)
perform_runtime_config = true

.. code-tab:: csharp

using Godot;
using System;

public class Main : Spatial
{
private PackedScene ovr_init_config;
private PackedScene ovr_performance;

bool perform_runtime_config = false;

public override void _Ready()
{
var ovr_init_config = (PackedScene)ResourceLoader.Load("res://addons/godot_ovrmobile/OvrInitConfig.gdns");
var ovr_performance = (PackedScene)ResourceLoader.Load("res://addons/godot_ovrmobile/OvrPerformance.gdns");
var _interface = ARVRServer.FindInterface("OVRMobile");
if (_interface != null)
{
ovr_init_config.set_render_target_size_multiplier(1);
if (_interface.Initialize())
{
GetViewport().Arvr = true;
}
}
}
public override void _Process(float delta)
{
if (perform_runtime_config == false)
{
ovr_performance.set_clock_levels(1, 1);
ovr_performance.set_extra_latency_mode(1);
perform_runtime_config = true;
}
}
}

Before we can export our project to our Quest we need to do three
more things.

First go into the project settings for our project and make sure that
our main scene is the scene we run. Godot does not ask you to set
this on export.

..image:: img/quest_project_settings.png

Then go into the export menu and configure a new Android export. Now
I'm assuming you followed the instructions in the "Exporting for
Android" page I refered to at the start. If you didn't you'll have
some red messages on this screen and I highly recommend you revisit
that page.

If you did we can forge ahead and make a few small changes to the
export settings. First we change the XR Mode to "Oculus Mobile VR".
Then we change our Degrees of Freedom mode to "6DOF".

..image:: img/quest_export_settings.png

Now save and close the export window.

Setting Up Your Quest
---------------------

Finally wip out your phone, when you got your Quest you needed to
install an Oculus app on it and link it up to your Quest. Start the
Oculus app. Press the settings cogwheel on the bottom right hand side.
Select your Quest:

.. image:: img/quest_phone_settings.png

Select "More Settings", and select "Developer Mode":

.. image:: img/quest_phone_settings_2.png

Now turn developer mode on:

.. image:: img/quest_developer_mode.png

This allows us to deploy our games to the Quest.

Connect the Quest to your PC with the provided USB cable. Put the Quest
on, it may give a few dialogs to give the PC permission to deploy apps.
Now hit the little Android button that should be visible in the top right
hand side of your Godot window. It should build your game and export it
to the Quest.

The above does the bare minimum to get your project running on the Quest,
it's not very exciting. Holger Dammertz has made a great toolkit for the
quest that contains a lot of scenes to get help you on your way including
really nice controller meshes.

You can find the toolkit `here <https://github.com/NeoSpark314/godot_oculus_quest_toolkit>`__.

If you want to help out with improving the plugin please join us `here <https://github.com/GodotVR/godot_oculus_mobile>`__.
Binary file added tutorials/vr/img/quest_developer_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_export_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_new_project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_phone_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_phone_settings_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_project_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_project_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/vr/img/quest_scene_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tutorials/vr/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ VR
:name: toc-tutorials-vr

vr_primer
developing_for_oculus_quest
vr_starter_tutorial/index

0 comments on commit 6a8656e

Please sign in to comment.