Inheritance: MonoBehaviour
 public Matrix4x4 GetProjection(GvrViewer.Eye eye,
                                GvrViewer.Distortion distortion = GvrViewer.Distortion.Distorted) {
   switch(eye) {
     case GvrViewer.Eye.Left:
       return distortion == GvrViewer.Distortion.Distorted ?
           leftEyeDistortedProjection : leftEyeUndistortedProjection;
     case GvrViewer.Eye.Right:
       return distortion == GvrViewer.Distortion.Distorted ?
           rightEyeDistortedProjection : rightEyeUndistortedProjection;
     default:
       return Matrix4x4.identity;
   }
 }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     controller = GetComponent <CharacterController>();
     gvrViewer  = transform.GetChild(0).GetComponent <GvrViewer>();
     vrHead     = Camera.main.transform;
 }
Ejemplo n.º 3
0
 void Awake()
 {
     GvrViewer.Create();
 }
 // Use this for initialization
 void Start()
 {
     speed = speed * Time.deltaTime;
     GvrViewer.Create();
 }
Ejemplo n.º 5
0
 private void Awake()
 {
     viewer = FindObjectOfType <GvrViewer>();
 }
Ejemplo n.º 6
0
 /// @note Each scene load causes an OnDestroy of the current SDK, followed
 /// by and Awake of a new one.  That should not cause the underlying native
 /// code to hiccup.  Exception: developer may call Application.DontDestroyOnLoad
 /// on the SDK if they want it to survive across scene loads.
 void Awake()
 {
     if (instance == null) {
       instance = this;
     }
     if (instance != this) {
       Debug.LogError("There must be only one GvrViewer object in a scene.");
       UnityEngine.Object.DestroyImmediate(this);
       return;
     }
     #if UNITY_IOS
     Application.targetFrameRate = 60;
     #endif
     // Prevent the screen from dimming / sleeping
     Screen.sleepTimeout = SleepTimeout.NeverSleep;
     InitDevice();
     StereoScreen = null;
     AddPrePostRenderStages();
 }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     camera      = GetComponentInChildren <GvrViewer> ();
     gameManager = FindObjectOfType <GameManager> ();
 }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     VRModeEnabled = this.GetComponent <GvrViewer>();
     arBackground  = Head.GetComponent <ARCameraBackground>();
     pressed       = Elevator.GetComponent <MoveUp>();
 }
 void Start()
 {
     myGvrViewer = GetComponentInParent <GvrViewer> ();
     myGvrViewer.Recenter();
 }
Ejemplo n.º 10
0
    /// Compute the position of one of the stereo eye cameras.  Accounts for both
    /// FOV matching and stereo comfort, if those features are enabled.  The input is
    /// the [1,1] entry of the eye camera's projection matrix, representing the vertical
    /// field of view, and the overall scale being applied to the Z axis.  Returns the
    /// position of the stereo eye camera in local coordinates.
    public Vector3 ComputeStereoEyePosition(GvrViewer.Eye eye, float proj11, float zScale)
    {
        if (centerOfInterest == null || !centerOfInterest.gameObject.activeInHierarchy) {
          return GvrViewer.Instance.EyePose(eye).Position * stereoMultiplier;
        }

        // Distance of COI relative to head.
        float distance = centerOfInterest != null ?
        (centerOfInterest.position - transform.position).magnitude : 0;

        // Size of the COI, clamped to [0..distance] for mathematical sanity in following equations.
        float radius = Mathf.Clamp(radiusOfInterest, 0, distance);

        // Move the eye so that COI has about the same size onscreen as in the mono camera FOV.
        // The radius affects the horizon location, which is where the screen-size matching has to
        // occur.
        float scale = proj11 / cam.projectionMatrix[1, 1];  // vertical FOV
        float offset =
        Mathf.Sqrt(radius * radius + (distance * distance - radius * radius) * scale * scale);
        float eyeOffset = (distance - offset) * Mathf.Clamp01(matchMonoFOV) / zScale;

        float ipdScale = stereoMultiplier;
        if (checkStereoComfort) {
          // Manage IPD scale based on the distance to the COI.
          float minComfort = GvrViewer.Instance.ComfortableViewingRange.x;
          float maxComfort = GvrViewer.Instance.ComfortableViewingRange.y;
          if (minComfort < maxComfort) {  // Sanity check.
        // If closer than the minimum comfort distance, IPD is scaled down.
        // If farther than the maximum comfort distance, IPD is scaled up.
        // The result is that parallax is clamped within a reasonable range.
        float minDistance = (distance - radius) / zScale - eyeOffset;
        ipdScale *= minDistance / Mathf.Clamp(minDistance, minComfort, maxComfort);
          }
        }

        return ipdScale * GvrViewer.Instance.EyePose(eye).Position + eyeOffset * Vector3.forward;
    }
Ejemplo n.º 11
0
 // Helper routine for creation of a stereo eye.
 private void CreateEye(GvrViewer.Eye eye)
 {
     string nm = name + (eye == GvrViewer.Eye.Left ? " Left" : " Right");
     GameObject go = new GameObject(nm);
     go.transform.SetParent(transform, false);
     go.AddComponent<Camera>().enabled = false;
     var GvrEye = go.AddComponent<GvrEye>();
     GvrEye.eye = eye;
     GvrEye.CopyCameraAndMakeSideBySide(this);
 }
Ejemplo n.º 12
0
 void Start()
 {
     gvrMain = FindObjectOfType<GvrViewer>();
     gvrHead = FindObjectOfType<GvrHead>();
 }
Ejemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     pressed       = Elevator.GetComponent <MoveUp>();
     mymat         = this.GetComponent <Renderer>().material;
     VRModeEnabled = GvrMain.GetComponent <GvrViewer>();
 }
Ejemplo n.º 14
0
 static void BuildGearVRSettings()
 {
     PlayerSettings.virtualRealitySupported = true;
     GvrViewer cardboard    = (GvrViewer)GameObject.FindGameObjectWithTag("Player").GetComponent <GvrViewer>();
     GvrHead   carboardHead = cardboard.gameObject.transform.GetChild(0).GetComponent <GvrHead>();
 }
Ejemplo n.º 15
0
 public Rect GetViewport(GvrViewer.Eye eye,
                         GvrViewer.Distortion distortion = GvrViewer.Distortion.Distorted) {
   switch(eye) {
     case GvrViewer.Eye.Left:
       return distortion == GvrViewer.Distortion.Distorted ?
           leftEyeDistortedViewport : leftEyeUndistortedViewport;
     case GvrViewer.Eye.Right:
       return distortion == GvrViewer.Distortion.Distorted ?
           rightEyeDistortedViewport : rightEyeUndistortedViewport;
     default:
       return new Rect();
   }
 }
Ejemplo n.º 16
0
 void Start()
 {
     gr = new GvrViewer();
 }
Ejemplo n.º 17
0
 public Pose3D GetEyePose(GvrViewer.Eye eye) {
   switch(eye) {
     case GvrViewer.Eye.Left:
       return leftEyePose;
     case GvrViewer.Eye.Right:
       return rightEyePose;
     default:
       return null;
   }
 }
Ejemplo n.º 18
0
 void Awake()
 {
     GvrViewer.Create();
     cam = GetComponent <Camera>();
     AddStereoRig();
 }
Ejemplo n.º 19
0
 void OnDestroy()
 {
     VRModeEnabled = false;
     if (device != null) {
       device.Destroy();
     }
     if (instance == this) {
       instance = null;
     }
 }
    // Use this for initialization
    void Start()
    {
        GvrViewer gv = GetComponent <GvrViewer>();

        gv.StereoScreenScale = renderScale;
    }