googlevr / gvr-ios-sdk

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

How do you specify the view? #318

Open bsabiston opened 6 years ago

bsabiston commented 6 years ago

With GoogleVR, how do you specify the view -- ie, the point at which the camera is looking, the camera position, the relative scale of the world? Currently I am working with the default settings, but everything is at a very small scale. Are there functions to set these things?

Performador commented 6 years ago

The camera view for left and right eyes are driven from head transformation. The world to head transformation is given by:

gvr_get_head_space_from_start_space_transform

You need to multiply that with the eye from head transform. You can adjust the eye from head transform to model the interpupillary distance. The wider apart the eyes are the smaller the world will look.

The default values provided by GVR typical averages. The world units are in meters.

https://developers.google.com/vr/reference/ios-ndk/group/headtracking

bsabiston commented 6 years ago

Thanks -- but I am not sure that answers my question. Are you just forced to accept the world space that GoogleVR uses, or can you place the GoogleVR "head" someplace in your game world? Maybe I am asking if you can set the transformation for the "start space". Do you understand what I mean? If I have a pre-existing game that I am adapting to GoogleVR, do I have to shrink everything down and orient it to match the GoogleVR world space, or can I tell GoogleVr "this is where you are in the world, this is where you are looking by 'default'". I see a lot about reading where the head and eyes are looking -- but how do you SET those things initially? I must be misunderstanding how it works...

Performador commented 6 years ago

You can apply your own start space from world transformation on top of the head transform that GVR gives you.

Let's say you would like the head to be at position (T) and orientation (R). Then your world from start transformation becomes T * R. So the matrices you want to apply for an eye become:

projection * eye_from_head * head_from_start * start_from_world projection * eye_from_head * head_from_start * inv(T * R)

bsabiston commented 6 years ago

Thanks! Finally got a chance to try this and it works great.