googlevr / gvr-android-sdk

Google VR SDK for Android
http://developers.google.com/vr/android/
Other
3.28k stars 1.28k forks source link

VRView tracks the real heading / setHeadOffset() #581

Closed AppWerft closed 6 years ago

AppWerft commented 6 years ago

This issue (https://github.com/googlevr/gvr-android-sdk/issues/334) is two years old. And I don't understand Google and the VR-team. Of course we need a possibility to control the yaw/headrotation. I see more then one solutions:

We build a touristic AR app and now we say to user: please rotate and if the heading is equal a value we start the VRView, this cannot be the solution!

This Titanium app uses this module: https://github.com/AppWerft/Ti.VRView

sigmaxipi commented 6 years ago

The core problem is that many developers wanted slightly different functionality for mixing custom yaw/pitch config and gyro-based config and there was no way to support all of them.

Instead we created the video360 sample which demonstrates creating a custom 360 viewer which whatever functionality you need. See #510 for more info.

sewasewa777 commented 6 years ago

G

sewasewa777 commented 6 years ago

V

sewasewa777 commented 6 years ago

581

KeySeeDev commented 5 years ago

Hi, I'm using the vr360 project, how would you rotate the mesh from VrVideoActivity? @sigmaxipi I tried with gvrView.setRotationY(45) but it rotates the View .-. and not the sphere

sigmaxipi commented 5 years ago

Mesh.glDraw takes in a model-view-projection matrix but SceneRenderer.glDrawFrame only passes in a view-projection matrix since there was no need for a rotation matrix in this sample. You'll need to add a rotation matrix in either of those two functions. Reticle.glDrawFrame shows how to take in a view-projection matrix & rotation matrix to update the reticle. You'll want to replicate this for Mesh.

KeySeeDev commented 5 years ago

Uh cool, will try to implement ASAP and will post back. But wouldn't it be better to change directly the viewProjectionMatrix / sensor data like in the MonoscopicView? @sigmaxipi

KeySeeDev commented 5 years ago

For the moment implemented the rotation inside VrVideoActivity.java within onDrawEye function. Probably not the best performance wise but works, maybe later on will search for a better solution. Of course if you already have better implementions, maybe share them 😁

@Override
public void onDrawEye(Eye eye) {
     Matrix.multiplyMM(viewProjectionMatrix, 0, eye.getPerspective(Z_NEAR, Z_FAR), 0, eye.getEyeView(), 0);
     Matrix.rotateM(viewProjectionMatrix, 0, my_offset_value, 0, 1, 0);
     scene.glDrawFrame(viewProjectionMatrix, eye.getType());
}
sigmaxipi commented 5 years ago

If you changed the viewProjectionMatrix, you would end up rotating the world and not the mesh. This is OK for MonoscopicView where the only item in the world is the mesh, but wouldn't be the proper way of doing it for a more complicated GL scene.

KeySeeDev commented 5 years ago

Yeah, you got a point. Luckily this is exactly what I need for the moment 👍 Will surely take it consideration for future developments, thanks sigmaxipi!