1
我有一些麻煩實施Android的增強現實應用程序,我希望有人能幫助我。 (對不起,我的英文...)傳感器和min3d ANDROID
基本上我從加速計和磁場傳感器獲取數值,然後當我讀remapCoordinatessystem(inR,AXIS_X,AXIS_Z,outR)...並最終我getOrientation .. 。
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
mGravity = event.values;
}
if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
mGeomagnetic = event.values;
}
if (mGravity != null && mGeomagnetic != null) {
float R[] = new float[9];
float I[] = new float[9];
boolean success = SensorManager.getRotationMatrix(R, I, mGravity, mGeomagnetic);
float outR[] = new float[9];
SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_X, SensorManager.AXIS_Z, outR);
if (success) {
float orientation[] = new float[3];
SensorManager.getOrientation(outR, orientation);
// Here I pass the orientation values to the object, which is render by the min3d framework
}
}
}
我得到的值是否正確?或者我需要將它們轉換成度數?¿我迷路了...
然後我用我從傳感器讀取的值旋轉我的3D對象...但是它的對象完全沒有移動。
public void updateScene() {
objModel.rotation().y = _orientation[2];
objModel.rotation().x = _orientation[1];
objModel.rotation().z = _orientation[0];
}
OpenGL是不是我的朋友......所以我不知道我在正確的轉變......這是旋轉軸的順序,或者也沒關係......從哪個值方向應該對應於由Min3D加載的3D對象的軸?
如果這不是我必須遵循的路徑......有人可以引導我到正確的嗎?這是幾個星期的戰鬥。
太謝謝你了...(StackOverflow的情人)