Unregister sensors in a Google Cardboard Activity/ RajawaliVRActivity

219 views Asked by At

I'm working on a 360 video player app for android. I have 3 playback modes: touch mode, gyro mode and cardboard mode. I'm able to see gyroscope mode and cardboard mode ok with the cardboard stereo renderer, but I couldn't find a way of stopping the orientation sensors for the touch mode.

Usually, I would work with SensorManagerand then use this function: sm.unregisterListener(this, sm.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR)); in the object or class that was acting as de SensorListener of the application. The problem is that this work now is done natively in the Google Cardboard code and I can't see where the Sensor changes are processed.

Thus, my question is: is there some way to stop orientation sensors besides the method descrived above? Or some other way to get this method to work?

I've tried using it with the view, the renderer and the activity but couldn't get it to work. Also I searched in google cardboard api but find nothing useful. If this is impossible to be done, is it viable to work with two separate renderers and associated views for the different playback modes? If so, I would appreciate any guide on how to get them to work.

If you need any more info, ask me and I'll be glad to explain anything else.

1

There are 1 answers

5
Sowattana Sigen On BEST ANSWER

I have figure out a trick to do that by applying ViewMatrix to eyeMatrix in the function onDrawEye() in RajawaliCardboardRenderer class.

@Override
public void onDrawEye(Eye eye) {
    eyeMatrix.setAll(getCurrentCamera().getViewMatrix());
    eyeQuaternion.fromMatrix(eyeMatrix);
    getCurrentCamera().setOrientation(eyeQuaternion);
}