ViveSoftware / ViveInputUtility-Unity

A toolkit that helps developing/prototyping VR apps.
http://u3d.as/uF7
Other
352 stars 82 forks source link

Oculus GO - issue with hmd and controller position #170

Closed alamboley closed 3 years ago

alamboley commented 4 years ago

Hello,

I'm using Unity 2019.2.21f1 (2019.3 trigger error with Wave SDK), and latest VIU release. My project is working with HTC Vive Focus, I'm trying to add Oculus Go support. I imported "com.unity.xr.oculus.android": "1.38.6" package, but when pressing play my head is in the ground and my touchpad way too height.

My Vive Focus setup : VR origin set to y 0 and CustomDeviceHeight 1.75.

Not that I've the same issue with all the examples.

chengnay commented 4 years ago

@alamboley A quick temporary fix, In Assets\HTC.UnityPlugin\VRModule\Modules\UnityEngineVRModule_2017_1.cs, function UpdateTrackingSpaceType(), Modify both tracking space type to XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary);

To allow Assets\HTC.UnityPlugin\ViveInputUtility\Examples\Shared\Scripts\CustomDeviceHeight.cs to take effect, You will need to modify as follows, function UpdateHeight(), ... switch (VRModule.activeModule) { ... _case VRModuleActiveEnum.UnityNativeVR: transform.localPosition = new Vector3(pos.x, mheight, pos.y); break; } ...

I will provide a proper fix ASAP, sorry for the inconvenience.

alamboley commented 4 years ago

Hi @chengnay thank you for the fix. It works fine for my first scene, but loading an other scene with the same configuration I'm in the ground.

I see things changing RoomScale to Stationnary, and other UnityNativeVR stuff. I suppose it doesn't impact Vive Focus Plus, but it will for Vive Pro & Oculus Quest? My project has to work on many VR systems.

chengnay commented 4 years ago

@alamboley Do you consider using Oculus Integration Unity package? Currently, if you only installed Oculus Android package from Package Manager, it will only support Unity Native, not Oculus VR support. And, VIU's Unity Native does not support Oculus Quest. Cannot recognize Oculus Quest device.

You mentioned "loading another scene with same configuration", do you have two scenes to switch? Or it is individual scene?

alamboley commented 4 years ago

Thanks for the quick answer, no the Rift isn't considered at the moment.

And, VIU's Unity Native does not support Oculus Quest. Cannot recognize Oculus Quest device.

You mean Oculus Quest doesn't work with this plugin?

You mentioned "loading another scene with same configuration", do you have two scenes to switch? Or it is individual scene?

Just to be sure: it is a simple SceneManager.LoadScene(scene); with the same VR Prefab than previously.

chengnay commented 4 years ago

@alamboley Yes, "com.unity.xr.oculus.android": "1.38.6" does not support Oculus Quest, when you install apk to Quest, you will be seeing Oculus Go controller. I am still thinking how to fix this part.

You can still use Oculus Integration to support Oculus Quest.

Just to be sure: it is a simple SceneManager.LoadScene(scene); with the same VR Prefab than previously. Are you able to share your code or project?

alamboley commented 4 years ago

Sure, could you provide me an email?

chengnay commented 4 years ago

Sure, could you provide me an email?

chengnan_yang@htc.com

chengnay commented 4 years ago

@alamboley I googled and found out that probably I need a proper AndroidManifest.xml to support Oculus Quest. I am looking into this part.

UPDATE: Finally Oculus Quest can be recognized with a proper AndroidManifest.xml, I will attach for your reference AndroidManifest.zip

chengnay commented 4 years ago

@alamboley Could you try below solution? I couldn't build your app as it needs to sign. In Assets\HTC.UnityPlugin\VRModule\Modules\UnityEngineVRModule_2017_1.cs, public override void BeforeRenderUpdate() { ... SetupKnownDeviceModel(currState);

if (deviceIndex == 0 && currState.serialNumber.Contains("Oculus Go"))
{
    XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary);
}

}

Please change the previous solution back,

function UpdateTrackingSpaceType(), Modify both tracking space type to XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary);

alamboley commented 4 years ago

Hi @chengnay please remove the cert and the Editor folder, that way you could provide your custom one.

I applied your code, no luck when I change the scene.

chengnay commented 4 years ago

@alamboley Could you try below solution? I couldn't build your app as it needs to sign. In Assets\HTC.UnityPlugin\VRModule\Modules\UnityEngineVRModule_2017_1.cs, public override void BeforeRenderUpdate() { ... SetupKnownDeviceModel(currState);

if (deviceIndex == 0 && currState.serialNumber.Contains("Oculus Go"))
{
    XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary);
}

}

Please remove above solution, and update your code to below solution.

  1. In Assets\HTC.UnityPlugin\VRModule\Modules\UnityEngineVRModule_2017_1.cs, public override void UpdateTrackingSpaceType() { switch (VRModule.trackingSpaceType) { .... case VRModuleTrackingSpaceType.RoomScale: _var prevtrackingOrigin = XRDevice.trackingOriginMode; XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale); _if (prevtrackingOrigin == XRDevice.trackingOriginMode) { XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary); } break; } }

  2. In Assets\HTC.UnityPlugin\ViveInputUtility\Examples\Shared\Scripts\CustomDeviceHeight.cs, private void OnEnable() { VRModule.onActiveModuleChanged += OnActiveModuleChanged; VRModule.Initialize();

    if (XRDevice.model.Equals("Oculus Go")) { UpdateHeight(); } } ... public void UpdateHeight() { ... switch (VRModule.activeModule) { ... case VRModuleActiveEnum.UnityNativeVR: _if (XRDevice.model.Equals("Oculus Go")) { transform.localPosition = new Vector3(pos.x, mheight, pos.y); } break; } ...

I found out that for Oculus Go, XRDevice.trackingOriginMode will not change after calling XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale). But, Oculus Quest works fine. So, above solution will be specifically for Oculus Go. Let me know if you still have issue. :)

alamboley commented 4 years ago

hi @chengnay you can remove the signing to test (and the script in the Editor folder).

I made your changes, glad it works :)

However this part is ambigous:

case VRModuleTrackingSpaceType.RoomScale:
    var prev_trackingOrigin = XRDevice.trackingOriginMode;
    XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale);
    if (prev_trackingOrigin == XRDevice.trackingOriginMode)
    {
        XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary);
    }
    break;

Since you forced prev_trackingOrigin = XRDevice.trackingOriginMode; the if condition always happen, is it the expected behaviour?

chengnay commented 4 years ago

For Oculus Quest, after SetTrackingSpaceType to RoomScale, XRDevice.trackingOriginMode will return Floor. For Oculus Go, after SetTrackingSpaceType to RoomScale, XRDevice.trackingOriginMode still return as Device.

Both cases initially XRDevice.trackingOriginMode returns Device. This is why I keep the prev trackingOriginMode, if it stays the same, then I will SetTrackingSpaceType to Stationary again. And, I also found out that VRModule.trackingSpaceType default value will be VRModuleTrackingSpaceType.RoomScale which was set in VRModuleManager.cs.

Let me know if you still think it is ambiguous. Cheers!

chengnay commented 4 years ago

hi @chengnay you can remove the signing to test (and the script in the Editor folder).

Yup, I did that already, this is why I come up with the solution for you! I already verified with the project that you shared. :)