我在为android实现增强现实应用时遇到了一些麻烦,我希望有人能帮助我。(对不起,我的英语...)
基本上我是从加速度计和磁场传感器获得值,然后当我读取remapCoordinatessystem(inR,AXIS_X,AXIS_Z,outR)时,...and最终我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不是我的friend...so我不确定我的转换是否正确...是旋转轴的顺序还是无关紧要。方向中的哪个值应该与Min3D加载的3D对象的轴相对应?
如果这不是我必须走的路...有没有人能带我去找正确的?这已经有几个星期了。
非常感谢你..。(StackOverflow爱好者)
发布于 2011-08-03 17:03:57
我遇到了一个问题
mGeomagnetic = event.values;你应该写下
mGeomagnetic = event.values.clone(); 相反,
https://stackoverflow.com/questions/6283712
复制相似问题