Google Cardboard VR sensors

懵懂的女人 提交于 2019-12-02 22:45:00

Google cardboard's website has a device compatibility list: It seems somewhat incomplete, so I tried taking a look into Cardboard.jar's source code. HeadTracker.java seems to have the following logic:

SensorManager sensorManager = (SensorManager)HeadTracker.this.mContext.getSystemService("sensor");

for (int sensorType : HeadTracker.INPUT_SENSORS) {
  Sensor sensor = sensorManager.getDefaultSensor(sensorType);
  sensorManager.registerListener(HeadTracker.this.mSensorEventListener, sensor, 0, handler);
}

With INPUT_SENSORS defined in the same file as

{TYPE_ACCELEROMETER, TYPE_GYROSCOPE};

I'm not sure if HeadTracker can work on phones with only one of those sensors. My guess is that both are necessary.

your app can require certain censors in order to run (or even be visible on the android market) with the following lines in your manifest:

<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true" />

you can also check if the sensors are available to your app at runtime using SensorManager's public Sensor getDefaultSensor (int type) function.

The google Cardboard headset won't work with just the accelerometer, it needs the gyro.

The accelerometer can detect forces applied to the phone. That includes reading the Earth's gravitational pull, so the phone can estimate where "down" is. But the accelerometer can't tell you percisely what your orientation in 3d space is, it can only approximate that basing on the forces it read.

That's far too low accuracy for VR, so that's why you need a gyroscope.

If you are dead set on making it work on your non-gyro phone, you can write a piece of your own code approximating phone orientation basing on accelerometer data, but keep in mind it will be very far from a really satisfying VR experience.

Use Fibrum SDK if you want your game working with no gyro phones

for example try

Space X Hunter VR :

https://play.google.com/store/apps/details?id=com.creation3d.spacexhuntervr

VR Bowl :

https://play.google.com/store/apps/details?id=com.creation3d.vrbowl

and the games from Fibrum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!