wrld3d / unity-api

Issue tracking for the WRLD Unity SDK
28 stars 8 forks source link

Integrating Cardboard VR #25

Closed Quidam2k closed 3 years ago

Quidam2k commented 6 years ago

When I set the build settings in Unity to compile for Android and to include Cardboard VR support, I'm having issues on the device with what appears to be camera conflicts between the motion tracking of the headset and the connection the camera has to the map. I've tried mucking about with disabling the Fly Behavior Script, Use Built-In Camera Controls, and both SetControlledCamera & ClearControlledCamera.

Nothing I've tried seems to be doing the thing for me. Completely disabling camera control turns off the map's reactivity to the camera. Enabling it causes jittery motion and there also appears to be a grey area of undrawn map if the headset is pointed straight down.

Is there a way to allow a Cardboard headset complete control over the point of view while still allowing the WRLD map to react normally?

johnbell84 commented 6 years ago

Hello,

Thanks for trying our maps!

It sounds like you might be on a slightly out-of-date version of the SDK. Version 0.5 was released on the Asset Store last Friday and I'd recommend upgrading to that if possible.

It should be possible to drive the camera yourself. This would involve disabling the "Use Built-in Camera Controls" checkbox on your WRLD map instance, as well as any additional camera controllers (e.g. The Fly Camera Behaviour). It is also possible to separate the streaming and rendering entirely - see "Separate Streaming and Rendering" in the Examples scene.

If the World Space setting on your WRLDMap instance is set to ECEF, the world resources will be continuously centered around the streaming camera (this is due to issues with floating-point precision). I'd recommend setting your World Space to UnityWorldSpace if you can.

Lastly, we have some guides to using the SDK with ARKit. Things won't be exactly the same for cardboard, but hopefully they might provide some pointers.

https://www.wrld3d.com/blog/use-arkit-wrld-unity-sdk-part-1/
https://www.wrld3d.com/blog/using-arkit-wrld-sdk-part-2/

I hope this helps. Please let us know if you have any further issues.

Kind regards,

John

Quidam2k commented 6 years ago

Thank you! That was very helpful.

It seems that you can't use the MoveTo function without calling SetControlledCamera, which ought not be done with VR. Does that mean that the only way to update the map's displayed location in VR is to separate the streaming and rendering? I'd like to avoid that if I can, because I'm fine with the VR camera being used for both streaming and rendering, but not if that precludes being able to update the map's position via code.

Thanks again for the response.

GabrielBakker commented 6 years ago

Just chiming in here .. you may not have experienced it yet, but the problem with using the VR camera for streaming is that people tend to look around a lot in VR, which causes the buildings on the map to constantly be removed and redrawn. If you even shake your head "no" the parts of the map visible in the distance will blink in and out of existence as you turn your head. Back when I made my project, there was no option for separating streaming and rendering, and so this problem ultimately defeated my project.

So if you're trying to work with VR you may want to separate the streaming and rendering anyway, and solve both problems at once.

Gabriel

On Fri, Sep 22, 2017 at 1:47 PM, Quidam2k notifications@github.com wrote:

Thank you! That was very helpful.

It seems that you can't use the MoveTo function without calling SetControlledCamera, which ought not be done with VR. Does that mean that the only way to update the map's displayed location in VR is to separate the streaming and rendering? I'd like to avoid that if I can, because I'm fine with the VR camera being used for both streaming and rendering, but not if that precludes being able to update the map's position via code.

Thanks again for the response.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wrld3d/unity-api/issues/25#issuecomment-331515441, or mute the thread https://github.com/notifications/unsubscribe-auth/Aco2BzGOarOUZ1AHIs9P6Vf9vzvDVQRhks5sk_KWgaJpZM4PeWu6 .

Quidam2k commented 6 years ago

Yeah, I'm getting that impression.

What I'm struggling with now is how I can move the streaming cam around without having it be a controlled camera, which turns on the default camera controls. I've tried setting it to be controlled, moving it, then clearing it, but that doesn't seem to have any effect.

malcolm-brown commented 6 years ago

I believe I see the problem. The MoveTo() method on the camera API only works when using the Built-In Camera Controls (the default mouse controlled camera we provide). We're missing a few helpers to make this a little easier when not using the built-in controls, but for now you might be able to work around this.

The Unity World space mode works by letting you pick an origin point Latitude and Longitude, and this will be used to represent the coordinates 0,0,0 in your Unity scene. For example, if we take the default UnityWorldSpace.scene in the Wrld Asset package, and write a script that runs the following two lines:

// Set Unity's origin to near the statue of liberty, at sea level
Api.Instance.SetOriginPoint(new LatLongAltitude(40.687240, -74.044457, 0.0));

// Position the camera 100m south, 0m east and 400m above the origin point. Have Built-in Camera Controls disabled
Camera.main.transform.position = new Vector3(0.0f, 400.0f, -100.0f);

This should give you a view near the Statue of Liberty, and the camera can be freely rotated here accordingly. The GeographicTransform component and API work in the same way, where you can specify a Lat/Long origin point and transform objects relative to that location to position objects at certain Latitude and Longitudes.

As for Streaming and Rendering, you should be able to do that fine via the example here. You just need to make sure you're calling the StreamResourcesForCamera() method every Update() and passing in the Unity Camera you want to stream with.

ghost commented 3 years ago

Valid workaround provided.