Skip to content
Snippets Groups Projects
Commit ba4a6e01 authored by florian.hassler's avatar florian.hassler
Browse files

add test vr with goddot

parent 8b8c6c8f
No related branches found
No related tags found
No related merge requests found
Showing
with 595 additions and 0 deletions
*.gd eol=lf
*.tscn eol=lf
*.cfg eol=lf
*.godot eol=lf
*.tres eol=lf
*.import eol=lf
*.o
*.os
.import/
*.dblite
*.exp
*.lib
*.obj
*.TMP
logs
Thumbs.db
extends ARVROrigin
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
var VR = ARVRServer.find_interface("OpenVR")
if VR and VR.initialize():
get_viewport().arvr = true
get_viewport().hdr = false
OS.vsync_enabled = false
Engine.target_fps = 90
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
Changes to the Godot OpenVR asset
=================================
Note, version numbers listed here are the version number assigned to the asset. Each time a new version is uploaded to the asset store we will increase the version number.
More frequent updates may be available on the source repository.
1.0.4 - 27 March 2019
---------------------
- Build for Godot 3.1
- Now using OpenVR 1.2.10
- Added Mac binaries (untested)
1.0.3 - 23 June 2018
--------------------
- Now using OpenVR 1.0.15
- Fixed crash issue related to new reloadable property in GDNative
1.0.2 - 4 May 2018
------------------
Changes were not tracked
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
var VR = ARVRServer.find_interface("Oculus")
if VR and VR.initialize():
get_viewport().arvr = true
get_viewport().hdr = false
# OS.vsync_enabled = false
# Engine.target_fps = 90
# Also, the physics FPS in the project settings is also 90 FPS. This makes the physics
# run at the same frame rate as the display, which makes things look smoother in VR!
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
[gd_scene load_steps=15 format=2]
[ext_resource path="res://Game.gd" type="Script" id=1]
[ext_resource path="res://Player.gd" type="Script" id=2]
[sub_resource type="SphereShape" id=1]
[sub_resource type="SphereMesh" id=2]
[sub_resource type="SpatialMaterial" id=3]
params_diffuse_mode = 1
albedo_color = Color( 0.882353, 0, 0, 1 )
metallic = 0.49
metallic_specular = 0.0
roughness = 0.0
[sub_resource type="CubeMesh" id=4]
[sub_resource type="SpatialMaterial" id=5]
albedo_color = Color( 0, 0.12549, 0.25098, 1 )
[sub_resource type="BoxShape" id=6]
[sub_resource type="PhysicsMaterial" id=7]
bounce = 0.5
[sub_resource type="BoxShape" id=8]
[sub_resource type="CubeMesh" id=9]
[sub_resource type="PhysicsMaterial" id=10]
bounce = 0.5
[sub_resource type="PhysicsMaterial" id=11]
bounce = 0.5
[sub_resource type="PhysicsMaterial" id=12]
bounce = 0.5
[node name="Game" type="Spatial"]
script = ExtResource( 1 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.5, 0.663414, -0.55667, 0, 0.642788, 0.766044, 0.866025, -0.383022, 0.321394, 0, 20, 0 )
shadow_enabled = true
shadow_bias = 0.44
[node name="Player" type="RigidBody" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0 )
mode = 2
script = ExtResource( 2 )
[node name="Camera" type="Camera" parent="Player"]
transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 10.7425, 10.738 )
visible = false
[node name="CollisionShape" type="CollisionShape" parent="Player"]
shape = SubResource( 1 )
[node name="mesh" type="MeshInstance" parent="Player"]
mesh = SubResource( 2 )
material/0 = SubResource( 3 )
[node name="ARVROrigin" type="ARVROrigin" parent="Player"]
editor/display_folded = true
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.4796, 11 )
[node name="ARVRCamera" type="ARVRCamera" parent="Player/ARVROrigin"]
[node name="StaticBody" type="StaticBody" parent="."]
editor/display_folded = true
transform = Transform( 10, 0, 0, 0, 0.01, 0, 0, 0, 10, 0, 0, 0 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.07057, 0 )
mesh = SubResource( 4 )
material/0 = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
shape = SubResource( 6 )
[node name="walls" type="Node" parent="."]
editor/display_folded = true
[node name="northWall" type="StaticBody" parent="walls"]
editor/display_folded = true
transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 0.3, 0, 1, -10 )
physics_material_override = SubResource( 7 )
[node name="CollisionShape" type="CollisionShape" parent="walls/northWall"]
shape = SubResource( 8 )
[node name="MeshInstance" type="MeshInstance" parent="walls/northWall"]
mesh = SubResource( 9 )
material/0 = null
[node name="eatWall" type="StaticBody" parent="walls"]
editor/display_folded = true
transform = Transform( -4.37114e-007, 0, 0.3, 0, 1, 0, -10, 0, -1.31134e-008, -10, 1, 0 )
physics_material_override = SubResource( 10 )
[node name="CollisionShape" type="CollisionShape" parent="walls/eatWall"]
shape = SubResource( 8 )
[node name="MeshInstance" type="MeshInstance" parent="walls/eatWall"]
mesh = SubResource( 9 )
material/0 = null
[node name="westWall" type="StaticBody" parent="walls"]
editor/display_folded = true
transform = Transform( -4.37114e-007, 0, 0.3, 0, 1, 0, -10, 0, -1.31134e-008, 10, 1, 0 )
physics_material_override = SubResource( 11 )
[node name="CollisionShape" type="CollisionShape" parent="walls/westWall"]
shape = SubResource( 8 )
[node name="MeshInstance" type="MeshInstance" parent="walls/westWall"]
mesh = SubResource( 9 )
material/0 = null
[node name="southWall" type="StaticBody" parent="walls"]
editor/display_folded = true
transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 0.3, 0, 1, 10 )
physics_material_override = SubResource( 12 )
[node name="CollisionShape" type="CollisionShape" parent="walls/southWall"]
shape = SubResource( 8 )
[node name="MeshInstance" type="MeshInstance" parent="walls/southWall"]
mesh = SubResource( 9 )
material/0 = null
[node name="Pickups" type="Node" parent="."]
editor/display_folded = true
[node name="RigidBody" type="RigidBody" parent="Pickups"]
MIT License
Copyright (c) 2018 Bastiaan Olij
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
extends RigidBody
var speed = 10
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _process(delta):
var velocity = Vector3() # The player's movement vector.
if Input.is_action_pressed("ui_right"):
velocity.x += 1
if Input.is_action_pressed("ui_left"):
velocity.x -= 1
if Input.is_action_pressed("ui_down"):
velocity.z += 1
if Input.is_action_pressed("ui_up"):
velocity.z -= 1
add_force(velocity*speed,Vector3(0,0,0))
\ No newline at end of file
# Godot Oculus GDNative module
This module is provided as is, all files are contained within the addons/godot-oculus folder
This module requires **Godot 3.1 or newer** to run.
The scenes subfolder contains a number of godot scenes that help you set up your project.
For basic functionality start with adding oculus_first_person.tcn to your project.
Also make sure that vsync is turned off in your project settings.
There is support for touch controllers. Note that Godot already supports the XBox One controller natively so this is not part of the module. Other controller support may be added later.
This module only has support for Windows and the Oculus client software must be installed.
Oculus does not (yet) supply an environment for Mac OS X nor Linux.
This module does not support Gear VR, Oculus Go or Oculus Quest.
Source code for this module can be found here:
https://github.com/GodotVR/godot_oculus
Also note that we have a support asset containing a number of useful scenes to get you going building VR applications in Godot:
https://github.com/GodotVR/godot-vr-common
Using the main viewport
-----------------------
The ARVR server module requires a viewport to be configured as the ARVR viewport. If you chose to use the main viewport an aspect ratio corrected copy of the left eye will be rendered to the viewport automatically.
You will need to add the following code to a script on your root node:
```
var interface = ARVRServer.find_interface("Oculus")
if interface and interface.initialize()
# Tell our viewport it is the arvr viewport:
get_viewport().arvr = true
# turn off vsync, we'll be using the headsets vsync
OS.vsync_enabled = false
# change our physics fps
Engine.target_fps = 90
```
Using a separate viewport
-------------------------
If you want control over the output on screen so you can show something independent on the desktop you can add a viewport to your scene and set the arvr property to true and hdr property to false. It is important that the ARVR nodes are child nodes within this viewport. You can add a normal camera to your scene to render a spectator view or turn the main viewport into a 2D viewport and save some rendering overhead.
You can now simplify you initialisation code on your root node to:
```
var interface = ARVRServer.find_interface("Oculus")
if interface and interface.initialize()
# turn off vsync, we'll be using the headsets vsync
OS.vsync_enabled = false
# change our physics fps
Engine.target_fps = 90
```
Licensing
---------
The Godot Oculus module and the godot scenes in this add on are all supplied under an MIT License.
The touch controller meshes and the Oculus client software are copyright Oculus, please check http://oculus.com for license information.
About this repository
---------------------
This repository was created by and is maintained by Bastiaan Olij a.k.a. Mux213
You can follow me on twitter for regular updates here:
https://twitter.com/mux213
Videos about my work with Godot including tutorials on working with VR in Godot can by found on my youtube page:
https://www.youtube.com/BastiaanOlij
[general]
singleton=true
load_once=true
symbol_prefix="godot_oculus_"
reloadable=false
[entry]
X11.64=""
Windows.64="res://addons/godot-oculus/bin/win64/godot_oculus.dll"
OSX.64=""
[dependencies]
X11.64=[ "" ]
Windows=[ "" ]
OSX.64=[ "" ]
test_vr_godot/addons/godot-oculus/icon.png

3.42 KiB

[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-e0c81101eabb15062112f5cd874460a6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/godot-oculus/icon.png"
dest_files=[ "res://.import/icon.png-e0c81101eabb15062112f5cd874460a6.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
[gd_scene load_steps=5 format=2]
[sub_resource type="PlaneMesh" id=1]
size = Vector2( 0.3, 0.15 )
subdivide_width = 10
subdivide_depth = 10
[sub_resource type="Shader" id=2]
code = "shader_type spatial;
render_mode unshaded;
uniform sampler2D viewport_texture : hint_albedo;
void vertex() {
VERTEX.y = 1.0 - cos(VERTEX.x + 0.3) * 0.5 - cos(VERTEX.z + 0.15) * 0.5;
}
void fragment() {
vec4 col = texture(viewport_texture, vec2(1.0-UV.x, UV.y));
ALBEDO = col.rgb;
ALPHA = col.a;
}"
[sub_resource type="ShaderMaterial" id=3]
render_priority = 0
shader = SubResource( 2 )
_sections_unfolded = [ "Resource", "shader_param" ]
[sub_resource type="GDScript" id=4]
script/source = "extends MeshInstance
func _ready():
get_surface_material(0).set_shader_param(\"viewport_texture\", $Viewport.get_texture())
func _process(delta):
$Viewport/World/Label.text = str(Engine.get_frames_per_second()) + \" FPS\""
[node name="FPS" type="MeshInstance" index="0"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = SubResource( 3 )
script = SubResource( 4 )
_sections_unfolded = [ "Transform", "material" ]
[node name="Viewport" type="Viewport" parent="." index="0"]
arvr = false
size = Vector2( 200, 100 )
own_world = false
world = null
transparent_bg = true
msaa = 0
hdr = false
disable_3d = false
usage = 0
debug_draw = 0
render_target_v_flip = false
render_target_clear_mode = 0
render_target_update_mode = 3
audio_listener_enable_2d = false
audio_listener_enable_3d = false
physics_object_picking = false
gui_disable_input = false
gui_snap_controls_to_pixels = true
shadow_atlas_size = 0
shadow_atlas_quad_0 = 2
shadow_atlas_quad_1 = 2
shadow_atlas_quad_2 = 3
shadow_atlas_quad_3 = 4
_sections_unfolded = [ "Render Target", "Rendering" ]
[node name="World" type="Node2D" parent="Viewport" index="0"]
_sections_unfolded = [ "Transform", "Z" ]
[node name="Label" type="Label" parent="Viewport/World" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 200.0
margin_bottom = 100.0
rect_scale = Vector2( 3, 3 )
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 2
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
text = "FPS"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Material", "Rect", "Visibility", "custom_colors" ]
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
[ext_resource path="res://addons/godot-oculus/scenes/oculus_cv1_controller_left/external_controller01_col.png" type="Texture" id=1]
[resource]
resource_name = "external_contoller_01:blinn1SG"
albedo_color = Color( 0, 0, 0, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.4
roughness = 0.6
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
[ext_resource path="res://addons/godot-oculus/scenes/oculus_cv1_controller_right/external_controller01_col.png" type="Texture" id=1]
[resource]
resource_name = "external_contoller_01:blinn1SG"
albedo_color = Color( 0, 0, 0, 1 )
albedo_texture = ExtResource( 1 )
metallic = 0.4
roughness = 0.6
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/external_controller01_col.png-3ad8b920576e5a7f58585030adb672e2.s3tc.stex"
path.etc2="res://.import/external_controller01_col.png-3ad8b920576e5a7f58585030adb672e2.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://addons/godot-oculus/scenes/oculus_cv1_controller_left/external_controller01_col.png"
dest_files=[ "res://.import/external_controller01_col.png-3ad8b920576e5a7f58585030adb672e2.s3tc.stex", "res://.import/external_controller01_col.png-3ad8b920576e5a7f58585030adb672e2.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=1
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/external_controller01_spec.png-1c24f69ea1cebd2f7b3e9328ab869072.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/godot-oculus/scenes/oculus_cv1_controller_left/external_controller01_spec.png"
dest_files=[ "res://.import/external_controller01_spec.png-1c24f69ea1cebd2f7b3e9328ab869072.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
newmtl external_contoller_01:blinn1SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd external_controller01_col.png
Ni 1.00
Ks 0.40 0.40 0.40
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment