"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Orthogonal/Perspective Camera View problem

Hello, we are trying to use QCAR together with jPCT-AE on Android 3.0 on an LG-V900 Optimus Pad device. We want to use both API's in a very unusual way: - QCAR shall recognize a marker and then the program shall show a 3D model (obj) as an overlay over the (real) camera view. - That means, the marker only shall activate something like a switch and then the 3D model shall appear. - The 3D model shall be independent from the marker then. - If I touch the screen, the 3D model shall disappear again until QCAR recognizes the marker again. We use this command to tell our 3D model the position where it shall appear (in C++ code): [CODE]modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose());[/CODE] The code gets transfered from the C++ code to the Java code of Android: [CODE]public native float[] getMatrixForJPCT(float[] matrix); cam = world.getCamera(); float[] matrix = getMatrixForJPCT(new float[16]); com.threed.jpct.Matrix matrixForJPCT = new Matrix(); for (int i = 0; i < 4; i++) { matrixForJPCT.setRow(i, matrix[i * 4], matrix[i * 4 + 1], matrix[i * 4 + 2], matrix[i * 4 + 3]); } cam.setBack(matrixForJPCT);[/CODE] In Java (Android) we use this matrix and put the 3D model at that position (only one time). Then we replace the information by the information which we receive from the Android SensorManager via SensorManager.getRotationMatrix(rotationMatrix, null, bufferedAccelGData, bufferedMagnetData); until I touch the screen. The example code of the SensorManager and jPCT which we used is here: [url]http://www.jpct.net/forum2/index.php?topic=1666.0[/url] The matrix for cam.setBack (4x4 matrix) includes a rotation matrix (first 3 rows of the matrix ending with a 0 in the last column = 3x3 matrix) and a translation vector (last row of the matrix ending with a 1 in the last column = 1x3 matrix). We could already program it so far. And it works good so far. But we have one big problem: The 3D model appears in an orthographic view. But we need it in a perspective view. [url]http://db-in.com/blog/wp-content/uploads/2011/03/projection_example.gif[/url] - that means the 3D model gets stretched as soon as the SensorManager gives new data. I tried already the following examples: - [url]http://opengles2learning.wordpress.com/tag/gles20/[/url] - [url]http://www.learnopengles.com/android-lesson-one-getting-started/[/url] - [url]http://blog.shayanjaved.com/2011/03/13/shaders-android/[/url] And I tried gl.glMatrixMode(). But I have the feeling that all that code gets ignored as soon as I enter it in the functions onSurfaceCreated, onSurfaceChanged and onDrawFrame in the Android OpenGL ES Renderer class. Is it possible that there are functions which have a higher priority, e.g. the code of the QCAR C++ code? That the C++ code overrides the Java code here? Please tell me if you need more detailed information. As I said, the problem is to get the GL camera from an orthographic view into a perspective view somehow. Maybe someone had already a similar problem. I'm sorry for possible spelling and grammar mistakes, I'm a German native speaker. Many thanks for your help in advance. byte

byte_2702

Thu, 11/17/2011 - 11:23

We have solved it in another way now. We know the reason meanwhile, too. But we couldn't solve it. The problem was in the SensorManager somewhere. We didn't get a correct rotation matrix back and the command SensorManager.remapCoordinateSystem() didn't work for us.