Cardboard VR / image alignment

Hi! Does anyone know how to ignore the tilt of the phone on application launch when you deal with images?

I mean, if I place an image in my VR-app, it aligns and displays correctly only if I keep my phone right in front of my eyes (landscape orientation and 90 degrees) before it starts.
Otherwise, it can moves left/right/up/down depend on the tilt angle of the device which was on the launch time, (when you see “place your phone into your cardboard” splash screen)

*imageMode is already set to CENTER and translated to width/2, height/2,
it works, but keep the strongly right rotation angle each time on start makes me mad)

Maybe it can be solved if I install the official google cardboard app, the splash screen prompts me to install this if I press on the setup icon during application launch, but unfortunately, it’s not available for my device from google play directly. (Honor 7C)

How deeply have you searched in all of the Processing forms, Googled or Binged it, and looked in the Android for Processing documentation?

deeply enough, but still didn’t find any clue, maybe I’m using wrong keywords for search.
My current assumption is to buffer the tilt angle on start then compensate an image position depend on it, but maybe there is much simplest solution which I don’t know.
I’m not this kind of person to spam every forum before trying to google it by myself if you mean that by your reply, but I’m asking here cause it seems like a relevant place for questions, isn’t it?

1 Like

Yeah, I know. :smiley: I’m sorry if I made you feel bad. I’ll get to this soon.

1 Like

Ok, seems like I found a root of all evil.
According to android-VR processing reference gyro sensor required, but my phone is a low-coast one and has only accelerometer.

I try to make some angle compensation depend on a first X, Y, Z values from the accelerometer sensor, like that:

void onAccelerometerEvent(float x, float y, float z)
  {
  if(!xChange && x != 0.0) { 
  xFixedAngle = x;
  xChange = true;
  } //.......

then map this values to 0 — 360 degrees for each ax and rotate an image corresponding received angles, but that doesn’t work properly or works a little only on one X-ax (but still laggy).
Probably I really bad in vector math and map it wrong, but I assume accelerometer data can be inaccurate in terms of defining rotations.

There is also some trick I found over the internet, to install something called VirtualSensor on a rooted device. Maybe I’ll try it later, but probably a better idea is just to make some GUI in my app to calibrate an image manually if it was aligned wrong. Anyway, if I keep my phone right it runs just fine without any gyro, which is def good news.

Sounds good! You might want to borrow somebody else’s phone to test it still works with a gyroscope sensor, though. I’m glad you figured this out.