예제 #1
0
void
HMDInfoCardboard::Notify(const mozilla::hal::ScreenConfiguration& config)
{
  mOrient = config.orientation();

  if (mOrient == eScreenOrientation_LandscapePrimary) {
    mScreenTransform = Quaternion(0.f, 0.f, M_SQRT1_2, M_SQRT1_2);
  } else if (mOrient == eScreenOrientation_LandscapeSecondary) {
    mScreenTransform = Quaternion(0.f, 0.f, -M_SQRT1_2, M_SQRT1_2);
  } else if (mOrient == eScreenOrientation_PortraitPrimary) {
    mScreenTransform = Quaternion();
  } else if (mOrient == eScreenOrientation_PortraitSecondary) {
    mScreenTransform = Quaternion(0.f, 0.f, 1.f, 0.f);
  }
}
예제 #2
0
// Android sends us events that have a 90-degree rotation about 
// the x axis compared to what we want (phone flat vs. phone held in front of the eyes).
// Correct for this by applying a transform to undo this rotation.
void
HMDInfoCardboard::Notify(const mozilla::hal::ScreenConfiguration& config)
{
  mOrient = config.orientation();

  if (mOrient == eScreenOrientation_LandscapePrimary) {
    mScreenTransform = Quaternion(-0.5f, 0.5f, 0.5f, 0.5f);
  } else if (mOrient == eScreenOrientation_LandscapeSecondary) {
    mScreenTransform = Quaternion(-0.5f, -0.5f, -0.5f, 0.5f);
  } else if (mOrient == eScreenOrientation_PortraitPrimary) {
    mScreenTransform = Quaternion((float) -M_SQRT1_2, 0.f, 0.f, (float) M_SQRT1_2);
  } else if (mOrient == eScreenOrientation_PortraitSecondary) {
    // Currently, PortraitSecondary event doesn't be triggered.
    mScreenTransform = Quaternion((float) M_SQRT1_2, 0.f, 0.f, (float) M_SQRT1_2);
  }
}