Results 1 to 3 of 3
  1. #1
    TobiasReich is offline Member
    Join Date
    Jul 2012
    Rep Power

    Default Sensor Orientiation -> GLRotation doesn't work properly

    I know that is a bit more complex question but you are my last hope.
    My aim is simple: I want to use the Android orientation sensor data for my GLES camera - giving it the rotation matrix. I found a very good example here:

    android - How to use onSensorChanged sensor data in combination with OpenGL - Stack Overflow

    but this is only working with GL1.0. So I need to work on it for GLES2.0

    That was so far easy, using my own shaders. Everything works. Moving the camera manuall is fine. But the moment I use the rotation matrix like in the example, it doesn't really work.

    I generate (like in his example) the rotation matrix with:

    Java Code:
    SensorManager.getRotationMatrix(rotationMatrix, null, bufferedAccelGData, bufferedMagnetData);
    My application is running in LANDSCAPE so I use that methode after (like in the example code):

    Java Code:
    float[] result = new float[16];
    SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, result);
    return result;
    It worked fine on my phone in his code but not in mine. My screen looks like that:

    Sensor Orientiation -> GLRotation doesn't work properly-glscreenshot.png

    The rotation matrix seems to be rotated 90° to the right (almost as if I have forgotten to switch to landscape for my activity). I was thinking of using the remap() methode in a wrong way but in his example it makes sense and I don't see any other way. After all, the camera movement works now. If I rotate to the left, the screen rotates to the left as well, even though, since everything is turned, it rotates "up" (compared to the ground, which is not on the bottom but on the right). So it just looks like I made a wall instead of a ground but I'm sure my coordinates are right for the vertices.

    I took a look ath the draw methode for the GLSurface and I don't see what I might have done wrong here:

    Java Code:
    MatrixStack.glLoadMatrix(sensorManager.getRotationMatrix());  // Schreibt die MVMatrix mit der ogn. Rotationsmatrix
    GameRenderer.setPerspMatrix(); // Schreibt die Perspektivmatrix Uniform für GLES. Daran sollte es nicht liegen.
    As I said, when moving my camera manually everything works perfect. So what is wrong with the rotation matrix I get? Or is there anything else wrong?

    I know its hard to tell but maybe someone where know ans anwer!
    Thank you very much,


    P.S. There is a post of someone who seems to have had the same problem. Maybe this describes my problem better:

    orientation and android openGl with sensor not working the way i expected - Stack Overflow

  2. #2
    TobiasReich is offline Member
    Join Date
    Jul 2012
    Rep Power

    Default Re: Sensor Orientiation -> GLRotation doesn't work properly

    Sorry to bother you with that but is there nobody who has an idea about that??? :-(

  3. #3
    TobiasReich is offline Member
    Join Date
    Jul 2012
    Rep Power

    Default Re: Sensor Orientiation -> GLRotation doesn't work properly

    Well, I got an idea.
    Here: SensorEvent | Android Developers
    is mentioned: "The axes are not swapped when the device's screen orientation changes."
    So I assume this is the problem. Has anyone any idea how to change that since I have Landscape mode not Portrait? I'd like to try this.
    Thank you very much!

Similar Threads

  1. The <sup> tag doesn't work properly
    By JosAH in forum AWT / Swing
    Replies: 26
    Last Post: 02-18-2012, 07:55 AM
  2. Help, I can't make the JButton to work properly
    By furieux in forum New To Java
    Replies: 11
    Last Post: 01-07-2012, 05:13 PM
  3. actions dont work properly, calculator
    By lordjb in forum New To Java
    Replies: 14
    Last Post: 02-03-2011, 07:00 AM
  4. class that wont work out properly.
    By vampire-elf in forum New To Java
    Replies: 7
    Last Post: 09-07-2010, 01:39 AM
  5. Eclipse Documentation does not work properly.
    By krawetko in forum Eclipse
    Replies: 0
    Last Post: 10-05-2008, 10:06 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts