谷歌纸板VR传感器 [英] Google Cardboard VR sensors

查看:256
本文介绍了谷歌纸板VR传感器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的谷歌纸板的(其头部跟踪类)来检测有关设备的旋转某些事情在AR应用。它工作得很好。

I'm using the Google Cardboard (its HeadTracker class) to detect certain things about device rotation in an AR application. It works very well.

然而,在某些设备上,它不工作(没有任何反应)。我想这是因为他们没有必要的传感器。我的问题:

However, on some devices, it doesn't work (nothing happens). I assume this is because they don't have the necessary sensors. My questions:

1)欲在运行时检测当前设备是否支持头部跟踪,即它具有必要的传感器提供。对于这一点,我需要知道哪些传感器所使用的头部跟踪,这样我可以查询,如果这些传感器是present。什么是这些传感器?

1) I want to detect at runtime whether the current device supports the HeadTracker, i.e. it has the necessary sensors available. For this, I need to know which sensors are used by HeadTracker, so that I can query if those sensors are present. What are these sensors?

2)有没有一种方法来指定AndroidManifest上必要的传感器?据我所看到的,也没有办法。因此,如果用户下载我的应用程序,应用程序将必须通知在运行时不支持他的设备的用户。这是不是很好。有什么想法?

2) Is there a way to specify the necessary sensors in AndroidManifest? As far as I can see, there is no way. Therefore, if a user downloads my app, the app will have to inform the user at runtime that his device is not supported. This is not nice. Any thoughts?

推荐答案

谷歌纸板的网站上有一个装置兼容性列表: 这似乎有点不完整的,所以我想考虑看看到Cardboard.jar的<一个href="https://github.com/Zomega/Cardboard/blob/master/src/com/google/vrtoolkit/cardboard/sensors/HeadTracker.java">source code 。 HeadTracker.java似乎有以下逻辑:

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

{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.

您的应用程序可能需要一定的审查才能运行(甚至可以看到在Android Market上)与你的清单下面几行:

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" />

您还可以检查传感器可为您的应用程序在运行时使用的SensorManager的 公共传感器getDefaultSensor(整型)的功能。

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

这篇关于谷歌纸板VR传感器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆