GodotVR / godot-xr-tools

Support scenes for AR and VR in Godot
MIT License
514 stars 74 forks source link

godot 4 beta 7 Pico 4 not in "VR mode" ? #295

Closed flobotics closed 1 year ago

flobotics commented 1 year ago

hi, when i build a apk for the pico 4 and then build and upload it with the android-button on the upper-right side of the godot-editor, the app only opens as a screen-app, like a video-player. Also i cannot move the head or controllers in the app.

If i start the app inside the godot-editor on windows, i can use the pico 4 head and controllers and controll them in the windows-app-view ?

What do i need to run the app on pico 4 in "fullscreen VR mode" ?

thx

naeu commented 1 year ago

The standalone VR works after doing the following on Linux

  1. In your project, install the android build template 01

  2. Enable XR/OpenXR and XR/Shaders in project settings 02

  3. Set the mobile renderer to gl_compatibility for smoother rendering on the Pico 4 03

  4. Clone and build godot_openxr_loaders

git clone https://github.com/GodotVR/godot_openxr_loaders
cd godot_openxr_loaders
./gradlew build
  1. Copy the gdap and loader files from godot_openxr_loaders into your project folder
PROJECT_DIR="~/Godot/MyProject"

mkdir -p "$PROJECT_DIR/android/plugins/godotopenxrpico"

# in godot_openxr_loaders
cp GodotOpenXRPico.gdap "$PROJECT_DIR/android/plugins"
cp godotopenxrpico/build/outputs/aar/* "$PROJECT_DIR/android/plugins/godotopenxrpico/"

The android folder in your project should look like (ignoring the android/build folder)

android/
└── plugins
    ├── godotopenxrpico
    │   ├── godotopenxrpico-debug.aar
    │   └── godotopenxrpico-release.aar
    └── GodotOpenXRPico.gdap
  1. In your project, open Project/Export and create an export for Android

  2. Enable custom build, set the min SDK to 21, and enable the openxr pico plugin 04

  3. Set XR Mode to OpenXR 05

  4. Enable xr in a script in your main scene

func _ready():
    var interface = XRServer.find_interface("OpenXR")
    if interface and interface.is_initialized():
        get_viewport().use_xr = true
  1. Run the Android project on the Pico 4, it should run in VR Mode.

The scene looks better with lighting and a world environment. I didn't test controller input or any of the examples.

flobotics commented 1 year ago

i am on windows 10, on command-shell i needed to set ANDROID_SDK_ROOT=C:\Users\SuperUserName\AppData\Local\Android\Sdk

then it returned Deprecated Gradle features etc. Dont know if this is an error, but the godot-apk is starting in "VR mode", but there is only the white-ring (loading sign) in the middle to see and the app does not start ?

gradlew.bat build
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':godotopenxrmeta:compilePackagingOptionsAidl'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\SuperUserName\git\godot_openxr_loaders\local.properties'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 12s

C:\Users\SuperUserName\git\godot_openxr_loaders>set ANDROID_SDK_ROOT=C:\Users\SuperUserName\AppData\Local\Android\Sdk

C:\Users\SuperUserName\git\godot_openxr_loaders>gradlew.bat build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 4s
159 actionable tasks: 159 up-to-date
C:\Users\SuperUserName\git\godot_openxr_loaders>
flobotics commented 1 year ago

ah, i need to use your get_viewport() code.

func _ready():
    var interface = XRServer.find_interface("OpenXR")
    if interface and interface.is_initialized():
        get_viewport().use_xr = true

For the above test i was using the code from this nice youtube video https://www.youtube.com/watch?v=wDXnsy2IH1A&t=316s

var xr_interface : XRInterface = XRServer.find_interface("OpenXR")
    if xr_interface and xr_interface.is_initialized():
        var vp : Viewport = get_viewport()
                vp.use_xr = true

which seemed not to work anymore, or even not for pico 4.

Now it works so far :) thx

flobotics commented 1 year ago

in godot 4 beta 8 it is not working anymore, filled an issue here https://github.com/GodotVR/godot_openxr_loaders/issues/16