Ejemplo n.º 1
0
    /// @endcond

    private void InitDevice()
    {
        // 1.3.0 -- 初始化设备
        if (device != null)
        {
            device.Destroy();
        }
        // 获取设备
        device = BaseVRDevice.GetDevice();
        // 设备初始化,这是继承类,其中override重新了Init。参考下图
        device.Init();

        List <string> diagnostics = new List <string>();

        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null)
        {
            device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetNeckModelScale(neckModelScale);

#if !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
        device.SetVRModeEnabled(vrModeEnabled);
#endif  // !UNITY_HAS_GOOGLEVR || UNITY_EDITOR

        device.UpdateScreenData();
    }
Ejemplo n.º 2
0
    /// @endcond

    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List <string> diagnostics = new List <string>();

        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null)
        {
            device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetNeckModelScale(neckModelScale);

        device.SetVRModeEnabled(vrModeEnabled);

        device.UpdateScreenData();
    }
Ejemplo n.º 3
0
 public virtual void Destroy()
 {
     if (device == this)
     {
         device = null;
     }
 }
Ejemplo n.º 4
0
    /// @endcond

    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        Svr.SvrLog.Log("InitDevice");
        SVR.AtwAPI.BeginTrace("init");
        device = BaseVRDevice.GetDevice();
        SVR.AtwAPI.EndTrace();
        if (Svr.SvrSetting.IsVR9Device)
        {
            return;
        }
        device.Init();


        SVR.AtwAPI.BeginTrace("other");
        List <string> diagnostics = new List <string>();

        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null)
        {
            device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.Native &&
                                              NativeDistortionCorrectionSupported);
        device.SetNeckModelScale(neckModelScale);

#if !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
        device.SetVRModeEnabled(vrModeEnabled);
#endif  // !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
        SVR.AtwAPI.EndTrace();
        SVR.AtwAPI.BeginTrace("updatedata");
        device.UpdateScreenData();
        SVR.AtwAPI.EndTrace();
    }
Ejemplo n.º 5
0
    public static BaseVRDevice GetDevice()
    {
        if (device == null)
        {
#if UNITY_EDITOR
            device = new UnityEditorDevice();
#elif ANDROID_DEVICE
            device = new CardboardAndroidDevice();
#elif IPHONE_DEVICE
            device = new CardboardiOSDevice();
#else
            throw new InvalidOperationException("Unsupported device.");
#endif
        }
        return(device);
    }
Ejemplo n.º 6
0
    /// @endcond

    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        // 根据当前运行场景获取对应的设备对象
        device = BaseVRDevice.GetDevice();
        device.Init();

        device.SetVRModeEnabled(vrModeEnabled);
        // 更新界面数据
        device.UpdateScreenData();

        GazeApi(GazeTag.Show, "");
        GazeApi(GazeTag.Set_Size, ((int)GazeSize.Original).ToString());
    }
Ejemplo n.º 7
0
    /// @endcond

    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List <string> diagnostics = new List <string>();

        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null)
        {
            device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetAlignmentMarkerEnabled(enableAlignmentMarker);
        device.SetSettingsButtonEnabled(enableSettingsButton);
        device.SetVRBackButtonEnabled(backButtonMode != BackButtonModes.Off);
        device.SetShowVrBackButtonOnlyInVR(backButtonMode == BackButtonModes.OnlyInVR);
        device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.Native &&
                                              NativeDistortionCorrectionSupported);
        device.SetTapIsTrigger(tapIsTrigger);
        device.SetNeckModelScale(neckModelScale);
        device.SetAutoDriftCorrectionEnabled(autoDriftCorrection);
        device.SetElectronicDisplayStabilizationEnabled(electronicDisplayStabilization);

        device.SetVRModeEnabled(vrModeEnabled);

        device.UpdateScreenData();
    }
Ejemplo n.º 8
0
    /// @endcond

    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List <string> diagnostics = new List <string>();

        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null)
        {
            device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.None &&         //Fix
                                              NativeDistortionCorrectionSupported);
//		device.SetDistortionCorrectionEnabled (false);     //Fix
        device.SetNeckModelScale(neckModelScale);

#if !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
        device.SetVRModeEnabled(vrModeEnabled);
#endif  // !UNITY_HAS_GOOGLEVR || UNITY_EDITOR

        device.UpdateScreenData();
    }
Ejemplo n.º 9
0
    /// <summary>
    ///
    ///  fov范围 [40~90]
    /// </summary>
    /// <param name="fov"></param>
    public void UpdateCameraFov(float fov)
    {
        if (fov > 90)
        {
            fov = 90;
        }
        if (fov < 5)
        {
            fov = 5;
        }
        // cache左右眼透视矩阵
        if (eyeOriginalProjection == null && eyes[0] != null && eyes[1] != null)
        {
            eyeOriginalProjection    = new Matrix4x4[2];
            eyeOriginalProjection[0] = eyes[0].cam.projectionMatrix;
            eyeOriginalProjection[1] = eyes[1].cam.projectionMatrix;
        }
        oldFov = fov;
        float near = NvrGlobal.fovNear > 0 ? NvrGlobal.fovNear : 0.0305f;
        float far  = NvrGlobal.fovFar > 0 ? NvrGlobal.fovFar : 2000;

        far = far > 100 ? far : 2000;
        float     fovLeft       = near * Mathf.Tan(-fov * Mathf.Deg2Rad);
        float     fovTop        = near * Mathf.Tan(fov * Mathf.Deg2Rad);
        float     fovRight      = near * Mathf.Tan(fov * Mathf.Deg2Rad);
        float     fovBottom     = near * Mathf.Tan(-fov * Mathf.Deg2Rad);
        Matrix4x4 eyeProjection = BaseVRDevice.MakeProjection(fovLeft, fovTop, fovRight, fovBottom, near, far);

        if (device != null)
        {
            for (int i = 0; i < 2; i++)
            {
                NvrEye eye = eyes[i];
                if (eye != null)
                {
                    eye.cam.projectionMatrix = eyeProjection;
                }
            }
        }
    }
Ejemplo n.º 10
0
    /// @endcond

    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List <string> diagnostics = new List <string>();

        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null)
        {
            device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.Native &&
                                              NativeDistortionCorrectionSupported);
        device.SetNeckModelScale(neckModelScale);
        device.SetElectronicDisplayStabilizationEnabled(electronicDisplayStabilization);

        device.SetVRModeEnabled(vrModeEnabled);

        device.UpdateScreenData();
    }
Ejemplo n.º 11
0
    /// <summary>
    ///  检查初始是否需要更新相机投影矩阵
    /// </summary>
    /// <param name="eye"></param>
    public void UpdateEyeCameraProjection(Eye eye)
    {
        if (oldFov != -1 && eye == Eye.Right)
        {
            UpdateCameraFov(oldFov);
        }

        if (!Application.isEditor && device != null && eye == Eye.Right)
        {
            if (mFar > 0)
            {
                float mNear = 0.0305f;
                if (NvrGlobal.fovNear > -1)
                {
                    mNear = NvrGlobal.fovNear;
                }
                // Debug.Log("new near : " + mNear + "," + NvrGlobal.fovNear+ ",new far : " + mFar + "," + NvrGlobal.fovFar);

                // 更新camera  near far
                float fovLeft   = mNear * Mathf.Tan(-Profile.viewer.maxFOV.outer * Mathf.Deg2Rad);
                float fovTop    = mNear * Mathf.Tan(Profile.viewer.maxFOV.upper * Mathf.Deg2Rad);
                float fovRight  = mNear * Mathf.Tan(Profile.viewer.maxFOV.inner * Mathf.Deg2Rad);
                float fovBottom = mNear * Mathf.Tan(-Profile.viewer.maxFOV.lower * Mathf.Deg2Rad);

                //Debug.Log("fov : " +fovLeft+","+fovRight+","+fovTop+","+fovBottom);

                Matrix4x4 eyeProjection = BaseVRDevice.MakeProjection(fovLeft, fovTop, fovRight, fovBottom, mNear, mFar);
                for (int i = 0; i < 2; i++)
                {
                    NvrEye mEye = eyes[i];
                    if (mEye != null)
                    {
                        mEye.cam.projectionMatrix = eyeProjection;
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
    private void InitDevice()
    {
        if (device != null)
        {
            device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List <string> diagnostics = new List <string>();

        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0)
        {
            Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                             + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        device.SetVRModeEnabled(vrModeEnabled);
        device.SetDistortionCorrectionEnabled(distortionCorrection &&
                                              NativeDistortionCorrectionSupported);
        device.SetAlignmentMarkerEnabled(enableAlignmentMarker &&
                                         NativeUILayerSupported);
        device.SetSettingsButtonEnabled(enableSettingsButton &&
                                        NativeUILayerSupported);
        device.SetNeckModelScale(neckModelScale);
        device.SetAutoDriftCorrectionEnabled(autoDriftCorrection);

        device.UpdateScreenData();
    }
  public static BaseVRDevice GetDevice() {
    if (device == null) {
#if UNITY_EDITOR
      device = new UnityEditorDevice();
#elif ANDROID_DEVICE
      device = new CardboardAndroidDevice();
#elif IPHONE_DEVICE
      device = new CardboardiOSDevice();
#else
      throw new InvalidOperationException("Unsupported device.");
#endif
    }
    return device;
  }
 public virtual void Destroy() {
   if (device == this) {
     device = null;
   }
 }
Ejemplo n.º 15
0
    private void InitDevice()
    {
        if (device != null) {
          device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List<string> diagnostics = new List<string>();
        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0) {
          Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                       + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0) {
          Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                       + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null) {
          device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetVRModeEnabled(vrModeEnabled);
        device.SetDistortionCorrectionEnabled(distortionCorrection
        && NativeDistortionCorrectionSupported);
        device.SetAlignmentMarkerEnabled(enableAlignmentMarker
        && NativeUILayerSupported);
        device.SetSettingsButtonEnabled(enableSettingsButton);
        device.SetTapIsTrigger(tapIsTrigger);
        device.SetNeckModelScale(neckModelScale);
        device.SetAutoDriftCorrectionEnabled(autoDriftCorrection);

        device.UpdateScreenData();
    }
Ejemplo n.º 16
0
  /// @endcond

  private void InitDevice() {
    if (device != null) {
      device.Destroy();
    }
    device = BaseVRDevice.GetDevice();
    device.Init();

    List<string> diagnostics = new List<string>();
    NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
    if (diagnostics.Count > 0) {
      Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                       + String.Join("; ", diagnostics.ToArray()) + "]");
    }
    diagnostics.Clear();
    NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
    if (diagnostics.Count > 0) {
      Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                       + String.Join("; ", diagnostics.ToArray()) + "]");
    }

    if (DefaultDeviceProfile != null) {
      device.SetDefaultDeviceProfile(DefaultDeviceProfile);
    }

    device.SetAlignmentMarkerEnabled(enableAlignmentMarker);
    device.SetSettingsButtonEnabled(enableSettingsButton);
    device.SetVRBackButtonEnabled(backButtonMode != BackButtonModes.Off);
    device.SetShowVrBackButtonOnlyInVR(backButtonMode == BackButtonModes.OnlyInVR);
    device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.Native
        && NativeDistortionCorrectionSupported);
    device.SetNeckModelScale(neckModelScale);
    device.SetAutoDriftCorrectionEnabled(autoDriftCorrection);
    device.SetElectronicDisplayStabilizationEnabled(electronicDisplayStabilization);

    device.SetVRModeEnabled(vrModeEnabled);

    device.UpdateScreenData();
  }
Ejemplo n.º 17
0
    /// @endcond
    private void InitDevice()
    {
        if (device != null) {
          device.Destroy();
        }
        device = BaseVRDevice.GetDevice();
        device.Init();

        List<string> diagnostics = new List<string>();
        NativeDistortionCorrectionSupported = device.SupportsNativeDistortionCorrection(diagnostics);
        if (diagnostics.Count > 0) {
          Debug.LogWarning("Built-in distortion correction disabled. Causes: ["
                       + String.Join("; ", diagnostics.ToArray()) + "]");
        }
        diagnostics.Clear();
        NativeUILayerSupported = device.SupportsNativeUILayer(diagnostics);
        if (diagnostics.Count > 0) {
          Debug.LogWarning("Built-in UI layer disabled. Causes: ["
                       + String.Join("; ", diagnostics.ToArray()) + "]");
        }

        if (DefaultDeviceProfile != null) {
          device.SetDefaultDeviceProfile(DefaultDeviceProfile);
        }

        device.SetDistortionCorrectionEnabled(distortionCorrection == DistortionCorrectionMethod.Native
        && NativeDistortionCorrectionSupported);
        device.SetNeckModelScale(neckModelScale);

        device.SetVRModeEnabled(vrModeEnabled);

        device.UpdateScreenData();
    }