jPCT-AE - a 3d engine for Android > Support

[Tips] Android, augmented reality 3D with JPCT + Camera.

**Darkflame**:

Thats exactly my goal.

Or, rather, allowing anyone to place messages tied to real locations and share them with anyone else :)

This is why I'm using Wave-servers as a back-end, it lets people have a kinda "social" AR. They can share their posts with either individuals, groups, or the public at large.

I already got the system working on PC's with a google map style client;

http://arwave.org/ (see video)

That was more or less to prove the concept. (though as its made in qt, porting later to nokia phones shouldn't be too hard).

Now I want to make a full AR one.

**Darkflame**:

Anyone know how to use the orientation sensors to set the JPCT camera to corrispond?

Ive been looking at the sourcecode of Mixare;

http://code.google.com/p/mixare/source/checkout

for guidelines.

The problem comes that they are using their own engine, and thus the rotations arnt in the needed format.

Heres what Ive tried;

--- Code: ---@Override

public void onSensorChanged(SensorEvent evt) {

try

{

if (evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

grav[0] = evt.values[0];

grav[1] = evt.values[1];

grav[2] = evt.values[2];

arView.postInvalidate();

} else if (evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {

mag[0] = evt.values[0];

mag[1] = evt.values[1];

mag[2] = evt.values[2];

arView.postInvalidate();

}

SensorManager.getRotationMatrix(RTmp, I, grav, mag);

//SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X, SensorManager.AXIS_MINUS_Z, Rt);

Rt=RTmp;

tempR.setRow(0, Rt[0], Rt[1], Rt[2],0);

tempR.setRow(1, Rt[3], Rt[4], Rt[5],0);

tempR.setRow(2, Rt[6], Rt[7], Rt[8],0);

tempR.setRow(3, 0, 0, 0,1);

Log.i("--", Rt[0] +" "+ Rt[1] +" "+ Rt[2]);

Log.i("--", Rt[3] +" "+ Rt[4] +" "+ Rt[5]);

Log.i("--", Rt[6] +" "+ Rt[7] +" "+ Rt[8]);

arView.setCameraOrentation(tempR);

}

catch (Exception ex)

{

Log.e("Sensor", "ProcessingError", ex);

}

}

--- End code ---

The function "setCameraOrentation" just leads to a

world.getCamera().setBack(RotMatrix);

Where RotMatrix is the Matrix passed to it.

What I'm not sure of is how Androids SensorManager.getRotationMatrix() matrix corresponds to the JCPTs "setBack" matrix :-/

I know one is 3x3 and the other is 4x4...but I think I dealt with that correct, so I'm not sure whats wrong now :?

The jcpt camera moves on rotations, but clearly not correctly. (or any simple angular displacement).

**Darkflame**:

Theres also this code here which I've tried with a similar lack of success;

http://mysticlakesoftware.blogspot.com/2009/07/sensor-accelerometer-magnetics.html

This code features a filtering function, which is nice, but I still cant match the v[x] output to the Jpct camera.

Also this code seems very slow compared to the above.

**EgonOlsen**:

If the matrix from Android is similar to what OpenGL uses, it's most likely column major, while jPCT's matrices are row major. You have to convert them by making rows to cols. The easiest way is to create a float[16]-array for Matrix.setDump() and fill it accordingly. So that

--- Code: ---a d g

b e h

c f j

--- End code ---

becomes

--- Code: ---a b c 0

d e f 0

g h j 0

0 0 0 1

--- End code ---

In addition, you have to convert between the coordinate systems. You can either do this by rotating the matrix 90° around the x-axis or by negating the second and third column of the matrix (can be done when filling the array anyway). The next release will include a method that does this conversion.

**Darkflame**:

I thought that at first but.....

--- Quote ---Each matrix is returned either as a 3x3 or 4x4 row-major matrix depending on the length of the passed array:

If the array length is 16:

/ M[ 0] M[ 1] M[ 2] M[ 3] \

| M[ 4] M[ 5] M[ 6] M[ 7] |

| M[ 8] M[ 9] M[10] M[11] |

\ M[12] M[13] M[14] M[15] /

This matrix is ready to be used by OpenGL ES's glLoadMatrixf(float[], int).

Note that because OpenGL matrices are column-major matrices you must transpose the matrix before using it. However, since the matrix is a rotation matrix, its transpose is also its inverse, conveniently, it is often the inverse of the rotation that is needed for rendering; it can therefore be used with OpenGL ES directly.

Also note that the returned matrices always have this form:

/ M[ 0] M[ 1] M[ 2] 0 \

| M[ 4] M[ 5] M[ 6] 0 |

| M[ 8] M[ 9] M[10] 0 |

\ 0 0 0 1 /

If the array length is 9:

/ M[ 0] M[ 1] M[ 2] \

| M[ 3] M[ 4] M[ 5] |

\ M[ 6] M[ 7] M[ 8] /

--- End quote ---

so that's right isn't it?

I guess its the varying co-ordinate system causing the problem?

Also, where's the most efficient place to put the

world.getCamera().setBack(CameraMatrix);

?

Camera rotation is only every second or more at the moment, so I'm trying to work out what part of my code is slowing it down.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version