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; } }
// Use this for initialization void Start() { controller = GetComponent <CharacterController>(); gvrViewer = transform.GetChild(0).GetComponent <GvrViewer>(); vrHead = Camera.main.transform; }
void Awake() { GvrViewer.Create(); }
// Use this for initialization void Start() { speed = speed * Time.deltaTime; GvrViewer.Create(); }
private void Awake() { viewer = FindObjectOfType <GvrViewer>(); }
/// @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(); }
// Use this for initialization void Start() { camera = GetComponentInChildren <GvrViewer> (); gameManager = FindObjectOfType <GameManager> (); }
// 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(); }
/// 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; }
// 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); }
void Start() { gvrMain = FindObjectOfType<GvrViewer>(); gvrHead = FindObjectOfType<GvrHead>(); }
// Use this for initialization void Start() { pressed = Elevator.GetComponent <MoveUp>(); mymat = this.GetComponent <Renderer>().material; VRModeEnabled = GvrMain.GetComponent <GvrViewer>(); }
static void BuildGearVRSettings() { PlayerSettings.virtualRealitySupported = true; GvrViewer cardboard = (GvrViewer)GameObject.FindGameObjectWithTag("Player").GetComponent <GvrViewer>(); GvrHead carboardHead = cardboard.gameObject.transform.GetChild(0).GetComponent <GvrHead>(); }
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(); } }
void Start() { gr = new GvrViewer(); }
public Pose3D GetEyePose(GvrViewer.Eye eye) { switch(eye) { case GvrViewer.Eye.Left: return leftEyePose; case GvrViewer.Eye.Right: return rightEyePose; default: return null; } }
void Awake() { GvrViewer.Create(); cam = GetComponent <Camera>(); AddStereoRig(); }
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; }