I am playing a 360 video: an equirectangular movie is projected on sphere, camera sits in the sphere’s center, the camera’s orientation is driven by the MotionManager::getOrientation, so that the user can rotate the smartphone to investigate the whole scene.
The problem with this approach is that every time the video starts, depending on the smartphone orientation, the user looks at a different viewport. This is what I would like to avoid.
I would like my user, regardless of her phone orientation, to always start watching the movie through the same viewport. I am only interested in y-axis rotation, assuming that the initial phone orientation is vertical.
For this I am saving the initial phone orientation on first MotionManager update, when the app starts:
quat init = MotionManager::getRotation( getOrientation() );
auto w = init.w; //rotation angle
mInitialRotationQuat = quat(-w,0.0,1.,0.); // only y-axis is important
Then in the update() I am multiplying the current orientation quaternion by the initial one to set the camera orientation:
mCamPersp->setOrientation( MotionManager::getRotation( getOrientation() ) * mInitialRotationQuat);
In the above I am following the QuaternionAccum example, in which it is shown how to increment a quaternion.
However, this produces a reproducible but undesired result –– the camera orientation gets corrected, but it is pointing to a different part of the video, instead of the same part of video, every time I change the phone orientation when starting the video.
What am I doing wrong?
Thanks.