Results 1 to 3 of 3
- 07-31-2012, 02:29 PM #1
Member
- Join Date
- Jul 2012
- Posts
- 4
- Rep Power
- 0
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:
My application is running in LANDSCAPE so I use that methode after (like in the example code):Java Code:SensorManager.getRotationMatrix(rotationMatrix, null, bufferedAccelGData, bufferedMagnetData);
It worked fine on my phone in his code but not in mine. My screen looks like that:Java Code:float[] result = new float[16]; SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, result); return result;

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:
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?Java Code:GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); 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. MatrixStack.mvPushMatrix(); drawGround(); MatrixStack.mvPopMatrix();
I know its hard to tell but maybe someone where know ans anwer!
Thank you very much,
Tobias
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
- 08-03-2012, 07:52 PM #2
Member
- Join Date
- Jul 2012
- Posts
- 4
- Rep Power
- 0
Re: Sensor Orientiation -> GLRotation doesn't work properly
Sorry to bother you with that but is there nobody who has an idea about that??? :-(
- 08-03-2012, 11:02 PM #3
Member
- Join Date
- Jul 2012
- Posts
- 4
- Rep Power
- 0
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
-
The <sup> tag doesn't work properly
By JosAH in forum AWT / SwingReplies: 26Last Post: 02-18-2012, 07:55 AM -
Help, I can't make the JButton to work properly
By furieux in forum New To JavaReplies: 11Last Post: 01-07-2012, 05:13 PM -
actions dont work properly, calculator
By lordjb in forum New To JavaReplies: 14Last Post: 02-03-2011, 07:00 AM -
class that wont work out properly.
By vampire-elf in forum New To JavaReplies: 7Last Post: 09-07-2010, 01:39 AM -
Eclipse Documentation does not work properly.
By krawetko in forum EclipseReplies: 0Last Post: 10-05-2008, 10:06 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks