googlevr / gvr-ios-sdk

Google VR SDK for iOS
http://developers.google.com/vr/ios/
Other
645 stars 191 forks source link

Mapping points in panorama to view coordinates #258

Closed DanielMaly closed 7 years ago

DanielMaly commented 7 years ago

Hi, this isn't really a feature request - I just want to know if anyone has successfully solved the same problem. I'm trying to place UI elements on top of a GVRPanoramaView that would always appear over the same spot in the image, a common enough use case. To determine the position of a UI element on screen, one has to:

  1. Determine which way the panorama is oriented and calculate the distance of the UI element to the current center of the panorama. This is easy thanks to the headRotation property.
  2. Find the mapping between coordinates specified relative to the 2D image that we found in the previous step, and coordinates in the GVRPanoramaView which shows a projection of said image. This is what I'm having trouble with. Could anyone point me in the right direction as to what exactly the projection is and how to find specific image coordinates in a rendered GVRPanoramaView?

Thank you

DanielMaly commented 7 years ago

Update: I now have a pretty good idea how to do this, except I need to know how wide the field of view is in the panorama view. I've tried experimenting with different screen sizes, image sizes and aspect ratios and the field of view can be anywhere from 84° to 100°.

Is there any way to find out exactly how wide the field of view is in a given GVRPanoramaView?

sanjayc77 commented 7 years ago

I am assuming you are doing this in non-VR (i.e. monoscopic) view. The FOV (both horizontal and vertical) used by GVRPanoramaView and GVRVideoView is 100 degrees.

For stereoscopic view, it is dependent upon the Cardboard viewer that is currently paired.

DanielMaly commented 7 years ago

Thanks, but that's just not right. I could be missing something glaringly obvious but from what I have seen, the FOV differs based on the view's aspect ratio. I will have to measure it for every possible iOS device screen size which is an awful solution but the only one currently available. Is there something I'm missing?