Skip to content

Commit dad7890

Browse files
committed
Added an OpenXR render models demo
1 parent 8be477c commit dad7890

18 files changed

+618
-0
lines changed

xr/openxr_render_models/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Normalize EOL for all files that Git considers text files.
2+
* text=auto eol=lf

xr/openxr_render_models/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Godot 4+ specific ignores
2+
.godot/
3+
/android/

xr/openxr_render_models/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# OpenXR Render models demo
2+
3+
This is a demo showing OpenXR's render models implementation.
4+
5+
Language: GDScript
6+
7+
Renderer: Compatibility
8+
9+
> [!NOTE]
10+
>
11+
> This demo requires Godot 4.5 or later
12+
13+
## Screenshots
14+
15+
![Screenshot](screenshots/render_model_demo.png)
16+
17+
## How does it work?
18+
19+
OpenXR allows us to run our application without having knowledge of the hardware being used,
20+
or that we as developers have access too at the time of developing our application.
21+
22+
As a result we don't have direct information telling us what hardware is being used,
23+
however there are situations where we want to visually show this hardware.
24+
25+
This specifically applies to the controllers used by the user, as showing the correct hardware
26+
improves the user's sense of immersion.
27+
28+
The render model API allows us to enumerate the devices currently in use and then query
29+
information such as its 3D asset, its position and orientation in space and the position
30+
and orientation of individual components of the asset.
31+
32+
Godot's implementation hides most of the complexity of this through the OpenXRRenderModelManager
33+
node as a child of the XROrigin3D node. You can add just this node by itself and let it show
34+
all render models that are currently active, or like we do in this demo, you can add nodes
35+
in the tree of each controller to show render models related to that controller.
36+
37+
## Action map
38+
39+
This demo project has a bare bones action map as we're only dealing with positioning.
40+
41+
## Running on PCVR
42+
43+
This project can be run as normal for PCVR. Ensure that an OpenXR runtime has been installed.
44+
45+
## Running on standalone VR
46+
47+
You must install the Android build templates and OpenXR loader plugin and configure an export template for your device.
48+
Please follow [the instructions for deploying on Android in the manual](https://docs.godotengine.org/en/stable/tutorials/xr/deploying_to_android.html).
49+
50+
1.77 KB
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://btobyv4xjhltq"
6+
path.s3tc="res://.godot/imported/pattern.png-cf6f03dfd1cdd4bc35da3414e912103d.s3tc.ctex"
7+
metadata={
8+
"imported_formats": ["s3tc_bptc"],
9+
"vram_texture": true
10+
}
11+
12+
[deps]
13+
14+
source_file="res://assets/pattern.png"
15+
dest_files=["res://.godot/imported/pattern.png-cf6f03dfd1cdd4bc35da3414e912103d.s3tc.ctex"]
16+
17+
[params]
18+
19+
compress/mode=2
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/uastc_level=0
23+
compress/rdo_quality_loss=0.0
24+
compress/hdr_compression=1
25+
compress/normal_map=0
26+
compress/channel_pack=0
27+
mipmaps/generate=true
28+
mipmaps/limit=-1
29+
roughness/mode=0
30+
roughness/src_normal=""
31+
process/channel_remap/red=0
32+
process/channel_remap/green=1
33+
process/channel_remap/blue=2
34+
process/channel_remap/alpha=3
35+
process/fix_alpha_border=true
36+
process/premult_alpha=false
37+
process/normal_map_invert_y=false
38+
process/hdr_as_srgb=false
39+
process/hdr_clamp_exposure=false
40+
process/size_limit=0
41+
detect_3d/compress_to=0

xr/openxr_render_models/box.tscn

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[gd_scene load_steps=5 format=3 uid="uid://cfgfwisj8m2mg"]
2+
3+
[ext_resource type="Texture2D" uid="uid://btobyv4xjhltq" path="res://assets/pattern.png" id="1_g2tbl"]
4+
5+
[sub_resource type="BoxShape3D" id="BoxShape3D_oq5cr"]
6+
7+
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bqn3j"]
8+
albedo_color = Color(0.16217351, 0.546357, 0.5366536, 1)
9+
albedo_texture = ExtResource("1_g2tbl")
10+
uv1_scale = Vector3(3, 3, 3)
11+
12+
[sub_resource type="BoxMesh" id="BoxMesh_3n43a"]
13+
material = SubResource("StandardMaterial3D_bqn3j")
14+
15+
[node name="Box" type="RigidBody3D"]
16+
17+
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
18+
shape = SubResource("BoxShape3D_oq5cr")
19+
20+
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
21+
mesh = SubResource("BoxMesh_3n43a")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class_name CollisionHands3D
2+
extends AnimatableBody3D
3+
4+
func _ready():
5+
# Make sure these are set correctly
6+
top_level = true
7+
sync_to_physics = false
8+
process_physics_priority = -90
9+
10+
func _physics_process(_delta):
11+
# Follow our parent node around
12+
var dest_transform = get_parent().global_transform
13+
14+
# We just apply rotation for this example
15+
global_basis = dest_transform.basis
16+
17+
# Attempt to move to where our tracked hand is
18+
move_and_collide(dest_transform.origin - global_position)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://c5bnmb8grcumh

xr/openxr_render_models/icon.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)