#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Oculus Rift via OSC -> Matrix inversion?

edited March 2014

Last year i posted a shader example for Oculus Rift in the forum. Unfortunately i can't find the post anymore. But in the meantime i wrote a rough OSC server for getting the orientation into Processing:

https://github.com/ixd-hof/Processing/tree/master/Tools/OculusRiftOSC

It simply transfers the rotation and transformation matrix (4x4) via OSC. I am ignoring the transformation values. Unformtunately the y axis is flipped. Any hints how to flip the y axis?

Here's a code snipped:

``````scene.beginDraw();
scene.background(0);

float pos_x = width/2;
float pos_y = height/2;
float pos_z = -433; // ?
scene.applyMatrix(matrix4x4[0], matrix4x4[1], matrix4x4[2], pos_x,
matrix4x4[4], matrix4x4[5], matrix4x4[6], pos_y,
matrix4x4[8], matrix4x4[9], matrix4x4[10], 0,
matrix4x4[12], matrix4x4[13], matrix4x4[14], matrix4x4[15]);

scene.translate(0, 100, pos_z);
scene.fill(255);
scene.box(150);
scene.translate(-200, 0, 0);
scene.fill(255, 0, 100);
scene.box(150);
scene.fill(100, 0, 255);
scene.translate(400, 0, 0);
scene.box(150);
``````
Tagged:

• edited April 2014

Hello, I managed you problem multiplying the second line of the matrix for -1 like this:

** matrix4x4[0], matrix4x4[1], matrix4x4[2], matrix4x4[3], matrix4x4[4]-1, matrix4x4[5]-1, matrix4x4[6]*-1, matrix4x4[7], matrix4x4[8], matrix4x4[9], matrix4x4[10], matrix4x4[11], matrix4x4[12], matrix4x4[13], matrix4x4[14], matrix4x4[15]);
**

I also think It's easier to apply the matrix just to the camera function.

Now I get the proper rotations but I still have some issues with the position transformations.

Is it possible that the reason is because the program you wrote ignores the transformation values from the sensor?

If I try to print the matrix4x4 I noticed that the last 4 elements of the array are "0.0"

Any Idea?