Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the openvr tutorial to godot 4.4 #162

Open
6 tasks
fire opened this issue Jan 9, 2025 · 7 comments
Open
6 tasks

Update the openvr tutorial to godot 4.4 #162

fire opened this issue Jan 9, 2025 · 7 comments

Comments

@fire
Copy link

fire commented Jan 9, 2025

@Toxic-Cookie was struggling to create a Godot 4.4 dev 7 demo with openvr overlays.

_xr_interface_openvr.application_type = 2 # Set to OVERLAY MODE = 2, NORMAL MODE = 1
_xr_interface_openvr.tracking_universe = 1 # Set to SEATED MODE = 0, STANDING MODE = 1, RAW MODE = 2
@fire fire changed the title Create a Godot 4.4 dev 7 demo with openvr overlays Update the openvr tutorial to godot 4.4 Jan 9, 2025
@vilhalmer
Copy link
Collaborator

Are you trying to do this with master, or with #155 applied? Overlays don't work at all on master right now.

Feel free to ping me in one of the Godot discord servers as well until I get around to an example.

@Toxic-Cookie
Copy link

Are you trying to do this with master, or with #155 applied? Overlays don't work at all on master right now.

Feel free to ping me in one of the Godot discord servers as well until I get around to an example.

I have successfully cloned your repo, pulled #155 into master, and grabbed the release files that were generated by GitHub Actions. The only thing that's holding me back now from having this fully working is an example of what my node tree needs to look like to get this to work.

So far I have the OpenVROverlayContainer as the root, a SubViewport under it and a ColorRect to hopefully see something.
image

On the root node I have the following GD Script:

@tool
extends Node

var _xr_interface_openvr : XRInterfaceOpenVR

func get_interface():
	return _xr_interface_openvr

func start_xr():
	if _xr_interface_openvr:
		print("Capabilities " + str(_xr_interface_openvr.get_capabilities()))
		print("Target size " + str(_xr_interface_openvr.get_render_target_size()))
		_xr_interface_openvr.application_type = 2
		_xr_interface_openvr.tracking_universe = 1

		if _xr_interface_openvr.initialize():
			get_viewport().use_xr = true

			print("Initialised")
		else:
			print("Failed to initialise")
	else:
		print("Interface was not instantiated")


func _enter_tree():
	_xr_interface_openvr = XRInterfaceOpenVR.new()
	if _xr_interface_openvr:
		XRServer.add_interface(_xr_interface_openvr)


func _exit_tree():
	if _xr_interface_openvr:
		XRServer.remove_interface(_xr_interface_openvr)
		_xr_interface_openvr = null

This so far only yields a window that briefly opens and then closes itself. Any help would be eternally appreciated.

@vilhalmer
Copy link
Collaborator

Looking at this today.

@vilhalmer
Copy link
Collaborator

Dot NET godot requires a dot net runtime. https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-8.0.11-windows-x64-installer

Also fwiw I have not tested mono, as it isn't required for this repo and I have a large enough build matrix in my head already 😅

@fire
Copy link
Author

fire commented Jan 11, 2025

Don't worry about the dotnet requirement. @Toxic-Cookie required it but it's not necessary for this tutorial.

@vilhalmer
Copy link
Collaborator

vilhalmer commented Jan 11, 2025

The main script should be a lot simpler, the interface management is handled by the autoload script. You're also never calling your start_xr, so XR never starts :) There's nothing magic about start_xr, it was just added in the older version of this plugin as a helper.

Make sure you have the singleton enabled in project settings, then you can do this:

extends Node

var _xr_interface_openvr : XRInterfaceOpenVR


func _enter_tree():
	_xr_interface_openvr = OpenVRInterface.get_interface()

	_xr_interface_openvr.set_application_type(2)
	_xr_interface_openvr.set_tracking_universe(1)

	if not _xr_interface_openvr.initialize():
		print("Failed to connect to OpenVR")

Note I don't even bother with the start_xr currently provided by the plugin, since we're changing the application mode. I should probably add an argument + enum for this, though the method is tiny enough I'm tempted to just remove it entirely in favor of documentation.

You also don't need use_xr on the viewport since this rendering happens alongside the XR pipeline now instead of using it, and in fact I think it might break things to set that since it will be trying to render the overlay as a scene app as well.

Edit: Oh, and move the overlay's absolute position out by a few meters or it spawns inside your feet 😆

godot_openvr-test

@vilhalmer
Copy link
Collaborator

Demo added to #155: 32cd2cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants