传感器和min3d ANDROID

问题描述:

我有一些麻烦实施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对象的轴?

如果这不是我必须遵循的路径......有人可以引导我到正确的吗?这是几个星期的战斗。

太谢谢你了...(*的情人)

我有一个问题与

mGeomagnetic = event.values; 

你应该写

mGeomagnetic = event.values.clone(); 

代替