diff --git a/app/src/main/cpp/Other/MatricesManager.cpp b/app/src/main/cpp/Other/MatricesManager.cpp index 573e7120..49b3ca23 100644 --- a/app/src/main/cpp/Other/MatricesManager.cpp +++ b/app/src/main/cpp/Other/MatricesManager.cpp @@ -67,16 +67,11 @@ void MatricesManager::calculateNewHeadPose360(gvr::GvrApi *gvr_api, const int pr worldMatrices.monoViewTracked360=toGLM(tmpHeadPose); } -glm::mat4x4 startToHeadRotation(gvr::GvrApi *gvr_api) { - gvr::Mat4f mat = gvr_api->GetHeadSpaceFromStartSpaceRotation(gvr::GvrApi::GetTimePointNow()); //we only want rotation, screw the mirage solo - glm::mat4x4 tmat=glm::make_mat4(reinterpret_cast(&mat.m)); - return glm::toMat4(glm::quat_cast(tmat)); -} - void MatricesManager::setHomeOrientation360(gvr::GvrApi *gvr_api) { // Get the current start->head transformation - worldMatrices.monoForward360=worldMatrices.monoForward360*startToHeadRotation(gvr_api); - // Reset yaw back to start - //gvr_api->RecenterTracking(); + gvr::Mat4f tmpHeadPose=gvr_api->GetHeadSpaceFromStartSpaceRotation(gvr::GvrApi::GetTimePointNow()); + gvr_api->ApplyNeckModel(tmpHeadPose,1); + glm::mat4 headView=toGLM(tmpHeadPose); + worldMatrices.monoForward360*=headView; } diff --git a/app/src/main/cpp/Other/MatrixHelper.h b/app/src/main/cpp/Other/MatrixHelper.h index 6b31b07f..d89719ec 100644 --- a/app/src/main/cpp/Other/MatrixHelper.h +++ b/app/src/main/cpp/Other/MatrixHelper.h @@ -15,15 +15,12 @@ #include #include -//convert between gvr / glm -//really messy ! -//TODO: Add tests usw -//gvr matrices are stored in row major order +//1)gvr matrices are stored in row major order //See gvr_types.h: /// A floating point 4x4 matrix stored in row-major form. It needs to be /// transposed before being used with OpenGL. -//glm matrices are stored in column major order (glm manual,section 4.11), as well as OpenGL matrices +//2)glm matrices are stored in column major order (glm manual,section 4.11), as well as OpenGL matrices static glm::mat4 toGLM(const gvr::Mat4f &gvrMatrix){ glm::mat4x4 ret=glm::make_mat4(reinterpret_cast(&gvrMatrix.m)); diff --git a/app/src/main/java/constantin/fpv_vr/APlay/AMono360.java b/app/src/main/java/constantin/fpv_vr/APlay/AMono360.java index 1e96bd2d..0b355d6c 100644 --- a/app/src/main/java/constantin/fpv_vr/APlay/AMono360.java +++ b/app/src/main/java/constantin/fpv_vr/APlay/AMono360.java @@ -28,7 +28,8 @@ public class AMono360 extends AppCompatActivity { private GLSurfaceView mGLView; private GLRMono360 mGLRenderer; private TelemetryReceiver telemetryReceiver; - //either create gvr api directly or use gvr layout as wrapper - first one introduces bug, e.g. "wrong 360° video orientation" + //either create gvr api directly or use gvr layout as wrapper + //First one caused bugs when not forwarding onResume/Pause to the DisplaySynchronizer, see https://github.com/googlevr/gvr-android-sdk/issues/556 private static final boolean useGvrLayout=true; private GvrApi gvrApi; private GvrLayout gvrLayout; @@ -52,6 +53,7 @@ protected void onCreate(Bundle savedInstanceState) { gvrLayout.setStereoModeEnabled(false); gvrLayout.setPresentationView(mGLView); }else{ + //gvrApi = new GvrApi(this, new DisplaySynchronizer(this,getWindowManager().getDefaultDisplay())); displaySynchronizer=new DisplaySynchronizer(this,getWindowManager().getDefaultDisplay()); gvrApi = new GvrApi(this, displaySynchronizer); gvrApi.reconnectSensors(); @@ -132,6 +134,7 @@ protected void onDestroy() { gvrLayout.shutdown(); }else{ gvrApi.shutdown(); + displaySynchronizer.shutdown(); } mGLView=null; mGLRenderer =null;