0

I am developing Android VR Application using 'Gear vr Framework'.

I want to get the head tracking value that can be used in Quaternion. (OrientationXYZW,PositionXYZ,linearVelocityXTZ, angularVelocityXYZ,.. etc. not camera value!(roll,yaw,pitch)).

I was able to get head tracking values Using judax's OculusMobileSDKHeadTracking library in the 'Gearvr framework (GearVRf v3.0.1 - Oculus Mobile SDK 1.0.3)'.

Judax's OculusMobileSDKHeadTracking github: [https://github.com/judax/OculusMobileSDKHeadTracking]

However, it was not possible with GearVRf v3.1 (Oculus Mobile SDK 1.0.4).

Because judax OculusMobileSDKHeadTracking uses Oculus Mobile SDK v.1.0.3. So, 'GearVRf v3.1' is having trouble getting head tracking values due to version conflicts.

Judax's OculusMobileSDKHeadTracking can be modified and used(Get positionXYZ, HeadDepth, etc.), but it is not easy to deal with JNI and NDK.

Is there a way to get headtracking values from the Gearvr framework? Or, please recommend other open source libraries.

bon_0418
  • 1
  • 2

2 Answers2

1

Can you use http://docs.gearvrf.org/v3.1/Framework/org/gearvrf/GVRCamera.html 's getTransform(), and then getRotationX(), getRotationY(), getRotationZ(), getRotationW() to get the quaternion?

BoHuang
  • 46
  • 2
0

Indeed, as the earlier answer (+1'd :)) suggests, the quaternion is available via an appropriate GVRTransform's getRotationX, ... getRotationZ methods. Here's a snippet which might help with an implementation:

public class SomeViewManager extends GVRMain {

    private GVRTransform mHeadTransfom;
    private HeadListener mHeadListener;

    MovieViewManager(HeadTransformListener headListener) {
        mHeadListener = headListener;
    }

    @Override
    public void onInit(GVRContext gvrContext) {
        GVRScene scene = gvrContext.getMainScene();
        mHeadTransfom = scene.getMainCameraRig().getHeadTransform();
    }

    @Override
    public void onStep() {
        mHeadListener.onOrientation(
                mHeadTransfom.getRotationW(),
                mHeadTransfom.getRotationX(),
                mHeadTransfom.getRotationY(),
                mHeadTransfom.getRotationZ()
        );
    }
}

public interface HeadTransformListener {
    public void onHeadTransform(float w, float x, float y, float z);
}

In my case the aim was to pass the head orientation to an FB360 (formerly "TwoBigEars") audio renderer, for spatial audio, and the following achieved that, using v0.9.95 of com.twobigears.TBAudioEngine:

public class SomeActivity extends GVRActivity implements HeadTransformListener  {
    @Override
    public void onHeadTransform(float w, float x, float y, float z) {
        // Set orientation
        TBAudioEngine.setListenerOrientation(new TBQuat(w, x, y, z));
    }
}
Jonathan
  • 1,089
  • 1
  • 7
  • 10