Skip to content

Commit

Permalink
add set / goto gome
Browse files Browse the repository at this point in the history
  • Loading branch information
di57mec committed Sep 19, 2019
1 parent 13530ee commit e222c79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
13 changes: 4 additions & 9 deletions app/src/main/cpp/Other/MatricesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const float*>(&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;
}

7 changes: 2 additions & 5 deletions app/src/main/cpp/Other/MatrixHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
#include <glm/gtx/matrix_decompose.hpp>
#include <sstream>

//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<const float*>(&gvrMatrix.m));
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/constantin/fpv_vr/APlay/AMono360.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -132,6 +134,7 @@ protected void onDestroy() {
gvrLayout.shutdown();
}else{
gvrApi.shutdown();
displaySynchronizer.shutdown();
}
mGLView=null;
mGLRenderer =null;
Expand Down

0 comments on commit e222c79

Please sign in to comment.