简体   繁体   English

传感器和 min3d ANDROID

[英]Sensors and min3d ANDROID

I'm having some troubles implementing an augmented reality app for android and I'm hoping that someone could help me.我在为 android 实现增强现实应用程序时遇到了一些麻烦,我希望有人可以帮助我。 (Sorry for my English...) (对不起我的英语不好...)

Basically I'm getting values from the accelerometer and mangetic field sensors, then as I read remapCoordinatessystem(inR, AXIS_X, AXIS_Z, outR)...and eventually I getOrientation...基本上我从加速度计和磁场传感器获取值,然后当我读取 remapCoordinatessystem(inR, AXIS_X, AXIS_Z, outR) ......最终我得到了方向......

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

Am I getting the values correct?我得到的值正确吗? Or I need to transform them into degrees?¿ I'm lost...或者我需要将它们转换成度数?¿我迷路了......

Then I rotate my 3D object with the values I have read from the sensors... but the obejct it's not moving at all.然后我用我从传感器读取的值旋转我的 3D object ......但对象根本没有移动。

public void updateScene() {
    objModel.rotation().y = _orientation[2];
    objModel.rotation().x = _orientation[1];
    objModel.rotation().z = _orientation[0];        
}

OpenGL is not my friend...so I'm not sure I'm transforming correctly... which is the order of the rotation axis or it doesn't matter... and which value from orientation should correspond to the axis of the 3D object loaded by Min3D? OpenGL 不是我的朋友...所以我不确定我是否正确转换...这是旋转轴的顺序还是无关紧要...方向的哪个值应该对应于轴Min3D加载的3D object?

If this is not the path I must follow... could someone guide me to the correct one please?如果这不是我必须遵循的路径...有人可以指导我找到正确的路径吗? It's been a few weeks fighting with this.与此作斗争已经有几个星期了。

Thank you so much... (StackOverflow lover)非常感谢...(StackOverflow 爱好者)

I had an issue with我有一个问题

mGeomagnetic = event.values;

you should write你应该写

mGeomagnetic = event.values.clone(); 

instead反而

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM