www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: billda on September 09, 2014, 01:32:06 pm

Title: Different camera rotation than device rotation
Post by: billda on September 09, 2014, 01:32:06 pm
Hi, Ok i have another silly question. I am implementing some kind of augmented reality application. I am displaying camera preview and overlaying it with 3D object. I am getting data from gyroscope and rotating camera of jpct so object is rotated corresponding with device rotation. My problem is that model is moving quicker than "real world" at camera preview. I thought that it has something to do with FOV so i took that "FOV" code from vuforia sample, but it didnt solve that problem, model was streched and problem with rotation was not solved.

Is there any way how I can "normalize" this movements?
Title: Re: Different camera rotation than device rotation
Post by: EgonOlsen on September 10, 2014, 08:16:43 am
I'm not sure. If you are doing the transformation between the different coordinate systems properly, i would expect the rotations to be in sync. But then again, i've never used this stuff, so i've no real idea what kind of matrix the gyroscope API returns.
Title: Re: Different camera rotation than device rotation
Post by: billda on September 15, 2014, 04:27:46 pm
Here is code for my transformation:
Code: [Select]
            cam = world.getCamera();
            Matrix r = getRotationMatrix(rotationMatrix);
            r.transformToGL();
            cam.setBack(r);

where rotationMatrix is matrix from gyroscope. Method getRotationMatrix is just converting between different data types for matrices. Do you think that I should do some extra transformation? I thought that its not necessary when all three rotations are in the right direction.
Title: Re: Different camera rotation than device rotation
Post by: EgonOlsen on September 16, 2014, 02:55:29 pm
Looks fine at first glance. it would be nice to see getRotationMatrix() anyway...
Title: Re: Different camera rotation than device rotation
Post by: billda on September 16, 2014, 03:51:37 pm
Okey, its only converting from 3x3 array to 4x4 matrix:

Code: [Select]
private Matrix getRotationMatrix(float[] data) {
            Matrix ret = new Matrix();

            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    ret.set(i, j, data[i * 3 + j]);
                }
            }
            ret.setRow(3, 0, 0, 0, 1);
            ret.setColumn(3, 0, 0, 0, 1);
            return ret;
       }
Title: Re: Different camera rotation than device rotation
Post by: EgonOlsen on September 18, 2014, 08:14:00 pm
Looks ok...have you tried to leave out the r.transformToGL(); call just to make sure that the matrix isn't in the correct format already?