Google Cardboard support

I’ll take a look at the orientation issue again “when I have time”. I have more info to go on now, regarding the end results. At least it seems to be working as expected for the time being, even if it’s not optimal.

The new issue, hmm. I don’t recall the cardboard integration doing anything specific with event queues. Will be interesting to see what you come up with.

In case it matters… since it’s in my head and I’m avoiding day job work for a minute…

Off the top of my head:

Vector3f headLoc = ...
Quaternion headRot = ...
float convergenceDistance = ...  // down the center line
float eyeOffset = ...  // from the center line
float angle = FastMath.atan2(convergenceDistance, eyeOffset);
Vector3f leftLoc = headLoc.add(headRot.mult(Vector3f.UNIT_X.mult(eyeOffset));
Vector3f rightLoc = headLoc.subtract(headRot.mult(Vector3f.UNIT_X.mult(eyeOffset));
Quaternion leftEyeRot = new Quaternion().fromAngles(0, -angle, 0);
Quaternion rightEyeRot = new Quaternion().fromAngles(0, angle, 0);
Quaternion leftEyeRotWorld = headRot.mult(leftEyeRot);
Quaternion righttEyeRotWorld = headRot.mult(righttEyeRot);

Possibly adjust for the fact that I often get left-hand/right-hand backwards so the eye rotations and/or positions might be swapped. (Also note: technically the local rightEyeRot is also just leftEyeRot.inverse() before converting to world.)

Anyway… now this won’t be distracting my hind-brain. Probably you don’t have that starting information maybe.

After I spent yesterday to much time to solve the gamepad issue (perhaps this wasn’t helpful…), I solved it today quite quickly. The line

mView.setFocusable(true);

was missing in createView in CardboardContext. I put it just l after the lines

    androidInput.setView(mView);
    androidInput.loadSettings(settings);

So, the event queue itself wasn’t the problem, but rather that the fragment view wasn’t really focused. Now the application reacts again to my gamepad input.

Aha. Have you forked the project? Could you create a pull request for the change, you think? No worries if you can’t, it can be a bit tricky.

I just cloned it before, but now I forked it and made a pull request.

1 Like