简体   繁体   中英

Unregister sensors in a Google Cardboard Activity/ RajawaliVRActivity

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 SensorManager and 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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM