Skip to content

Commit

Permalink
Add recenterPose api to GVRContext
Browse files Browse the repository at this point in the history
Implement appropriately for Oculus
Fix build errors due to order of maven repos
  • Loading branch information
liaxim committed Mar 19, 2019
1 parent 83275ab commit b47d560
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,13 @@ void createSwapChain(){

mRenderBundle.createRenderTargetChain(isMultiview);
}
/*
* GVRF APIs
*/

private native long getRenderTextureInfo(long ptr, int index, int eye );
private native long getRenderTextureInfo(long ptr, int index, int eye);
private native void drawEyes(long ptr);
private native void recenterPose(long ptr);

@Override
public void recenterPose() {
recenterPose(mApplication.getActivityNative().getNative());
}
}
5 changes: 5 additions & 0 deletions GVRf/Framework/backend_oculus/src/main/jni/ovr_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,9 @@ void GVRActivity::onDrawFrame(jobject jViewManager) {
LOGD("Activity: usingMultview = %d", use_multiview);
return use_multiview;
}

void GVRActivity::recenterPose() const {
vrapi_RecenterPose(oculusMobile_);
}

}
2 changes: 2 additions & 0 deletions GVRf/Framework/backend_oculus/src/main/jni/ovr_activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace gvr {
void setGearController(GearController *controller){
gearController = controller;
}

void recenterPose() const;
};

}
Expand Down
11 changes: 9 additions & 2 deletions GVRf/Framework/backend_oculus/src/main/jni/ovr_activity_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace gvr {
return reinterpret_cast<long>(gvrActivity);
}

JNIEXPORT long JNICALL Java_org_gearvrf_OvrViewManager_getRenderTextureInfo(JNIEnv* jni, jclass clazz, jlong jactivity , jint index, jint eye){
JNIEXPORT long JNICALL Java_org_gearvrf_OvrViewManager_getRenderTextureInfo(JNIEnv*, jobject, jlong jactivity, jint index, jint eye) {
GVRActivity* gvrActivity = reinterpret_cast<GVRActivity*>(jactivity);
return reinterpret_cast<long>(gvrActivity->getRenderTextureInfo(eye, index));
}
Expand Down Expand Up @@ -94,7 +94,14 @@ namespace gvr {
const GVRActivity *activity = reinterpret_cast<GVRActivity*>(appPtr);
return activity->usingMultiview();
}



JNIEXPORT void JNICALL
Java_org_gearvrf_OvrViewManager_recenterPose__J(JNIEnv*, jobject, jlong ptr) {
const GVRActivity *activity = reinterpret_cast<GVRActivity*>(ptr);
activity->recenterPose();
}

} //extern "C" {

} //namespace gvr
4 changes: 2 additions & 2 deletions GVRf/Framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if(file("../../../extra_properties.gradle").exists()) {
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
Expand All @@ -15,11 +15,11 @@ buildscript {

allprojects {
repositories {
google()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
google()
}
}
subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,11 @@ final GVRReference findReference(long nativePointer) {
return null;
}

/**
* Recenter the head and the controller pose orientation on the yaw axis
*/
public void recenterPose() {
getMainScene().getMainCameraRig().resetYaw();
}

}

0 comments on commit b47d560

Please sign in to comment.