// * * * * * * * * * * * * * // Awake void Awake() { // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if(CameraControllers.Length == 0) Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); else CameraController = CameraControllers[0]; // Find player controller OVRPlayerController[] PlayerControllers; PlayerControllers = gameObject.GetComponentsInChildren<OVRPlayerController>(); if(PlayerControllers.Length == 0) Debug.LogWarning("OVRMainMenu: No OVRPlayerController attached."); else if (PlayerControllers.Length > 1) Debug.LogWarning("OVRMainMenu: More then 1 OVRPlayerController attached."); else PlayerController = PlayerControllers[0]; }
//// -- !UnityAndroid - CameraTexture is not used for Android. #pragma warning restore 414 // The private field 'x' is assigned but its value is never used #endregion #region Monobehaviour Member Functions /// <summary> /// Start /// </summary> void Start() { // Get the OVRCameraController CameraController = transform.parent.GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("OVRCameraController not found!"); this.enabled = false; return; } #if (!UNITY_ANDROID || UNITY_EDITOR) if (!CameraController.UseCameraTexture) { return; } // This will scale the render texture based on ideal resolution if (CameraTexture[0] == null) { CreateRenderTexture(CameraController.CameraTextureScale); } camera.targetTexture = CameraTexture[(RightEye) ? 1 : 0]; #endif }
// Start new void Start() { base.Start(); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); } // NOTE: MSAA TEXTURES NOT AVAILABLE YET // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) #if MSAA_ENABLED CameraTextureScale = OVRDeviceImposter.DistortionScale(); #endif // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering if ((CameraTexture == null) && (CameraTextureScale > 1.0f)) { int w = (int)(Screen.width / 2.0f * CameraTextureScale); int h = (int)(Screen.height * CameraTextureScale); CameraTexture = new RenderTexture(w, h, 24); // 24 bit colorspace // NOTE: MSAA TEXTURES NOT AVAILABLE YET // This value should be the default for MSAA textures // CameraTexture.antiAliasing = 4; // Set it within the project #if MSAA_ENABLED CameraTexture.antiAliasing = QualitySettings.antiAliasing; #endif } }
// Start new void Start() { base.Start(); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); } // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) //CameraTextureScale = OVRDevice.DistortionScale(); // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering if ((CameraTexture == null) && (CameraTextureScale != 1.0f)) { int w = (int)(Screen.width / 2.0f * CameraTextureScale); int h = (int)(Screen.height * CameraTextureScale); CameraTexture = new RenderTexture(w, h, 24); // Use MSAA settings in QualitySettings for new RenderTexture CameraTexture.antiAliasing = QualitySettings.antiAliasing; } }
public void Start() { switch (compass) { case CompassSource.Kinect: if (!skeletonManager) { skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; } if (!skeletonManager) { Debug.LogError("RUISSkeletonManager script is missing from this scene!"); } break; case CompassSource.PSMove: inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if (!inputManager) { Debug.LogError("RUISInputManager script is missing from this scene!"); } break; } if (driftingSensor == DriftingRotation.InputTransform && !driftingTransform) { Debug.LogError("driftingTransform is none, you need to set it from the inspector!"); } oculusCamController = FindObjectOfType(typeof(OVRCameraController)) as OVRCameraController; }
public void AttachCorrectCameraModule() { GameObject cameraHolder = GameObject.FindWithTag("CameraHolder"); // Cleanup up previous camera (if it exists) if( cameraHolder.transform.childCount > 0) Destroy(cameraHolder.transform.GetChild(0).gameObject, 0.0f); // Add correct camera module if(isOVR) { GameObject ovrModule = (GameObject)Instantiate(ovrCameraControllerModulePrefab, new Vector3(), Quaternion.identity); //ovrModule.transform.Rotate(new Vector3(0, -90, 0), Space.Self); ovrModule.transform.parent = cameraHolder.transform; ovrModule.transform.localPosition = new Vector3(); ovrCameraController = (OVRCameraController)GameObject.FindWithTag("OVRCameraController").GetComponent("OVRCameraController"); mainCameraGameObject = GameObject.FindWithTag("MainCamera"); GameObject[] tempCameraObjectArray = GameObject.FindGameObjectsWithTag("MainCamera"); mainCameraComponentList.Clear(); for(int i = 0; i < tempCameraObjectArray.Length; i++) mainCameraComponentList.Add( (Camera)tempCameraObjectArray[i].GetComponent("Camera") ); } else { GameObject normalCameraModule = (GameObject)Instantiate(mainCameraModulePrefab, new Vector3(), Quaternion.identity); //normalCameraModule.transform.Rotate(new Vector3(0, -90, 0), Space.Self); normalCameraModule.transform.parent = cameraHolder.transform; normalCameraModule.transform.localPosition = new Vector3(); mainCameraGameObject = GameObject.FindWithTag("MainCamera"); //GameObject.Find("Main Camera"); } }
// Awake void Awake() { CameraController = GetComponentInChildren(typeof(OVRCameraController)) as OVRCameraController; if (CameraController == null) { Debug.LogWarning("Single Method Failed!"); // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } } }
void Start() { NeedsSetTexture = true; wasFullScreen = Screen.fullScreen; StartCoroutine(CallbackCoroutine()); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("OVRCameraController not found!"); this.enabled = false; return; } if (!CameraController.UseCameraTexture) { return; } #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX) // if AA & AF are disabled, step down RT scale for a FPS boost if (QualitySettings.anisotropicFiltering == 0 && QualitySettings.antiAliasing == 0) { CameraController.CameraTextureScale = Mathf.Min(CameraController.CameraTextureScale, 0.7f); } #endif // This will scale the render texture based on ideal resolution CreateRenderTexture(EyeId, CameraController.CameraTextureScale); GetComponent <Camera>().targetTexture = CameraTexture[EyeId]; OldScale = CameraController.ScaleRenderTarget; }
/// <summary> /// Start /// </summary> new void Start() { base.Start(); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); this.enabled = false; return; } if (!CameraController.UseCameraTexture) { return; } // This will scale the render texture based on ideal resolution if (CameraTexture == null) { CreateRenderTexture(CameraController.CameraTextureScale); } camera.targetTexture = CameraTexture; }
/// <summary> /// Start this instance. /// </summary> new void Start() { base.Start(); // Get the OVRCameraController CameraController = GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); } // Without this, we will be drawing 1 frame behind camera.depth = Mathf.Max(CameraLeft.depth, CameraRight.depth) + 1; // Don't want the camera to render anything.. camera.cullingMask = 0; camera.eventMask = 0; camera.useOcclusionCulling = false; camera.backgroundColor = Color.black; camera.clearFlags = (!CameraController.UseCameraTexture) ? CameraClearFlags.Nothing : CameraClearFlags.SolidColor; // TBD: This may be a performance loss on mobile. camera.renderingPath = RenderingPath.Forward; camera.orthographic = true; }
// * * * * * * * * * * * * * // Awake new public virtual void Awake() { base.Awake(); // We use Controller to move player around Controller = gameObject.GetComponent <CharacterController>(); if (Controller == null) { Debug.LogWarning("OVRPlayerController: No CharacterController attached."); } // We use OVRCameraController to set rotations to cameras, // and to be influenced by rotation OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRPlayerController: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } // Instantiate a Transform from the main game object (will be used to // direct the motion of the PlayerController, as well as used to rotate // a visible body attached to the controller) DirXform = null; Transform[] Xforms = gameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < Xforms.Length; i++) { if (Xforms[i].name == "ForwardDirection") { DirXform = Xforms[i]; break; } } if (DirXform == null) { Debug.LogWarning("OVRPlayerController: ForwardDirection game object not found. Do not use."); } Vector3 currForward = Camera.main.transform.TransformDirection(Vector3.forward); currForward.y = 0; currForward = currForward.normalized; for (int i = 0; i < driftFactor; i++) { forwardDirHistory.Enqueue(currForward); } }
void useSimpleCamera() { simpleCamera.enabled = true; ovrCamera.enabled = false; Destroy (ovrCamera.gameObject); ovrCamera = null; }
void Start() { coatLeft = transform.Find("coatLeft"); coatRight = transform.Find("coatRight"); ovrController = transform.parent.parent.GetComponent <OVRCameraController>(); isHiding = false; calledHiding = false; coatRight.localPosition = cRight = new Vector3(maxCoatRightX, 0f, 0f); coatLeft.localPosition = -cRight; }
void Start() { coatLeft = transform.Find("coatLeft"); coatRight = transform.Find("coatRight"); ovrController = transform.parent.parent.GetComponent<OVRCameraController>(); isHiding = false; calledHiding = false; coatRight.localPosition = cRight = new Vector3(maxCoatRightX, 0f, 0f); coatLeft.localPosition = -cRight; }
// SetOVRCameraController public void SetOVRCameraController(ref OVRCameraController cameraController) { CameraController = cameraController; CameraController.GetCamera(ref MainCam); if(CameraController.PortraitMode == true) { float tmp = DeadZoneX; DeadZoneX = DeadZoneY; DeadZoneY = tmp; } }
/// <summary> /// Start this instance. /// </summary> new void Start() { base.Start(); // Get the OVRCameraController CameraController = GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); } }
// SetOVRCameraController public void SetOVRCameraController(ref OVRCameraController cameraController) { CameraController = cameraController; CameraController.GetCamera(ref MainCam); if (CameraController.PortraitMode == true) { float tmp = DeadZoneX; DeadZoneX = DeadZoneY; DeadZoneY = tmp; } }
void Awake() { // Find camera controller OVRCameraController[] camera_controllers; camera_controllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if (camera_controllers.Length == 0) Debug.LogWarning("ThreeDimGUI: No OVRCameraController attached."); else if (camera_controllers.Length > 1) Debug.LogWarning("ThreeDimGUI: More then 1 OVRCameraController attached."); else m_CameraController = camera_controllers[0]; }
// * * * * * * * * * * * * * // Awake new public virtual void Awake() { base.Awake(); // Don't let the Physics Engine rotate this physics object so it doesn't fall over when running rigidbody.freezeRotation = true; collider.material.dynamicFriction = 0; collider.material.dynamicFriction2 = 0; collider.material.staticFriction = 0; collider.material.staticFriction2 = 0; collider.material.frictionCombine = PhysicMaterialCombine.Minimum; // We use OVRCameraController to set rotations to cameras, // and to be influenced by rotation OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRPlayerController: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } // Instantiate a Transform from the main game object (will be used to // direct the motion of the PlayerController, as well as used to rotate // a visible body attached to the controller) DirXform = null; Transform[] Xforms = gameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < Xforms.Length; i++) { if (Xforms[i].name == "ForwardDirection") { DirXform = Xforms[i]; break; } } if (DirXform == null) { Debug.LogWarning("OVRPlayerController: ForwardDirection game object not found. Do not use."); } }
// * * * * * * * * * * * * * // Awake void Awake() { // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } // Find player controller OVRPlayerController[] PlayerControllers; PlayerControllers = gameObject.GetComponentsInChildren <OVRPlayerController>(); if (PlayerControllers.Length == 0) { Debug.LogWarning("OVRMainMenu: No OVRPlayerController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRMaunMenu: More then 1 OVRPlayerController attached."); } else { PlayerController = PlayerControllers[0]; } // Set the GUI target GUIRenderObject = GameObject.Instantiate(Resources.Load("OVRGUIObjectMain")) as GameObject; if (GUIRenderObject != null) { if (GUIRenderTexture == null) { int w = (int)(Screen.width); int h = (int)(Screen.height); GUIRenderTexture = new RenderTexture(w, h, 24); GuiHelper.Draw3D = true; } } }
void Awake() { ovrCameraController = GetComponentInChildren<OVRCameraController>(); ovrCameraControllerTransform = ovrCameraController.transform; headController = GetComponent<HeadController>(); handsController = GetComponent<HandsController>(); feetController = GetComponent<FeetController>(); motionController = GetComponent<MotionController>(); swooshSound = ovrCameraControllerTransform.Find("SwooshSound").GetComponent<AudioSource>(); materialTriggers = GameObject.FindObjectsOfType( typeof (TriggerSolidColor ) ) as TriggerSolidColor[]; foreach ( CameraAnchor cameraAnchor in GameObject.FindObjectsOfType( typeof(CameraAnchor) )) characterCameraAnchorTransforms.Add( cameraAnchor.transform ); }
void Update() { #if (UNITY_EDITOR) if (AllowMouseLook) { if (LockMouse && CaptureMouseCursor) { Screen.lockCursor = true; } else { Screen.lockCursor = false; } if (CaptureMouseCursor) { OVRCameraController cameraController = GetComponent <OVRCameraController>(); float MousePitchDelta = Input.GetAxis("Mouse Y") * MouseSensitivityPitch; float MouseYawDelta = Input.GetAxis("Mouse X") * MouseSensitivityYaw * -1.0f; if (InvertPitch) { MouseYawDelta = -MouseYawDelta; } MouseAngles.x += MousePitchDelta; MouseAngles.y += MouseYawDelta; if (MousePitchDelta > 0.0f) { if (MouseAngles.x > 89.5f) { MouseAngles.x = 89.5f; } } else if (MousePitchDelta < 0.0f) { if (MouseAngles.x < -89.5f) { MouseAngles.x = -89.5f; } } MouseAngles.y = Mathf.Clamp(MouseAngles.y, -360.0f, 360.0f); Quaternion q = Quaternion.Euler(MouseAngles.x, MouseAngles.y, 0.0f); cameraController.SetOrientationOffset(q); } } #endif }
// Use this for initialization void Start() { movement = Vector3.zero; controller = gameObject.GetComponent<CharacterController>(); OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if(CameraControllers.Length == 0) Debug.LogWarning("OVRPlayerController: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraController attached."); else CameraController = CameraControllers[0]; }
public void Start() { CurrentState = PlayerState.Normal; _changingState = false; _manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); _terrainCollider = GameObject.FindGameObjectWithTag("Terrain").GetComponent <TerrainCollider>(); _sunLight = GameObject.FindGameObjectWithTag("SunLight").GetComponent <Light>(); _startIntensity = _sunLight.intensity; _ovrPlayerController = GetComponent <OVRPlayerController>(); _ovrCameraController = GetComponentInChildren <OVRCameraController>(); _audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>(); }
public void Start() { CurrentState = PlayerState.Normal; _changingState = false; _manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>(); _terrainCollider = GameObject.FindGameObjectWithTag("Terrain").GetComponent<TerrainCollider>(); _sunLight = GameObject.FindGameObjectWithTag("SunLight").GetComponent<Light>(); _startIntensity = _sunLight.intensity; _ovrPlayerController = GetComponent<OVRPlayerController>(); _ovrCameraController = GetComponentInChildren<OVRCameraController>(); _audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent<AudioManager>(); }
// Start new void Start() { base.Start(); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>(); // Get the cameras OVRCamera[] cameras = gameObject.transform.parent.GetComponentsInChildren <OVRCamera>(); for (int i = 0; i < cameras.Length; i++) { if (cameras[i].name == "CameraRight") { CameraRight = cameras[i]; } } if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); } // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) // CameraTextureScale = OVRDevice.DistortionScale(); // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering if ((CameraTexture == null) && (CameraTextureScale != 1.0f)) { int w = (int)(Screen.width / 2.0f * CameraTextureScale); int h = (int)(Screen.height * CameraTextureScale); if (camera.hdr) { CameraTexture = new RenderTexture(w, h, 24, RenderTextureFormat.ARGBFloat); } else { CameraTexture = new RenderTexture(w, h, 24); } // Use MSAA settings in QualitySettings for new RenderTexture CameraTexture.antiAliasing = (QualitySettings.antiAliasing == 0) ? 1 : QualitySettings.antiAliasing; } }
// Awake void Awake() { CameraController = GetComponentInChildren(typeof(OVRCameraController)) as OVRCameraController; if(CameraController==null){ Debug.LogWarning("Single Method Failed!"); // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if(CameraControllers.Length == 0) Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); else CameraController = CameraControllers[0]; } }
// * * * * * * * * * * * * * // Awake void Awake() { OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } }
/// <summary> /// sets various parameters on the Oculus scripts /// </summary> private static void SetOVRParameters(GameObject arCameraGameObject) { #if ENABLE_VUFORIA_OCULUS_INTEGRATION QCARAbstractBehaviour qcarBehaviour = arCameraGameObject.GetComponent <QCARAbstractBehaviour>(); // set black background color OVRCameraController ovrCameraController = arCameraGameObject.GetComponent <OVRCameraController>(); ovrCameraController.BackgroundColor = Color.black; ovrCameraController.FlipCorrectionInY = true; // set up cameras as Oculus expects them to be: qcarBehaviour.PrimaryCamera.depth = 1; OVRCamera leftOVRCamera = qcarBehaviour.PrimaryCamera.GetComponent <OVRCamera>(); leftOVRCamera.RightEye = false; qcarBehaviour.SecondaryCamera.depth = 0; OVRCamera rightOVRCamera = qcarBehaviour.SecondaryCamera.GetComponent <OVRCamera>(); rightOVRCamera.RightEye = true; #endif }
void Awake() { OVRCameraController ovrCameraController = GetComponent <OVRCameraController>(); if (ovrCameraController != null) { mOVRController = ovrCameraController; mOVRController.enabled = false; // This API disables OVR tracking in the scene while Vuforia is tracking. // It needs to be manually added to the Oculus SDK scripts, please see // the Vuforia developer library at developer.vuforia.com for more details. mOVRController.DisableVrTracking = true; } QCARBehaviour arCamera = GetComponent <QCARBehaviour>(); if (arCamera != null) { mQCARBehaviour = arCamera; mQCARBehaviour.enabled = false; } }
// * * * * * * * * * * * * * // Awake public new virtual void Awake() { base.Awake (); // We use Controller to move player around Controller = gameObject.GetComponent<CharacterController> (); if (Controller == null) Debug.LogWarning ("OVRPlayerController: No CharacterController attached."); // We use OVRCameraController to set rotations to cameras, // and to be influenced by rotation OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController> (); if (CameraControllers.Length == 0) Debug.LogWarning ("OVRPlayerController: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning ("OVRPlayerController: More then 1 OVRCameraController attached."); else CameraController = CameraControllers [0]; // Instantiate a Transform from the main game object (will be used to // direct the motion of the PlayerController, as well as used to rotate // a visible body attached to the controller) DirXform = null; Transform[] Xforms = gameObject.GetComponentsInChildren<Transform> (); for (int i = 0; i < Xforms.Length; i++) { if (Xforms [i].name == "ForwardDirection") { DirXform = Xforms [i]; break; } } if (DirXform == null) Debug.LogWarning ("OVRPlayerController: ForwardDirection game object not found. Do not use."); }
public void AttachCorrectCameraModule() { GameObject cameraHolder = GameObject.FindWithTag("CameraHolder"); // Cleanup up previous camera (if it exists) if (cameraHolder.transform.childCount > 0) { Destroy(cameraHolder.transform.GetChild(0).gameObject, 0.0f); } // Add correct camera module if (isOVR) { GameObject ovrModule = (GameObject)Instantiate(ovrCameraControllerModulePrefab, new Vector3(), Quaternion.identity); //ovrModule.transform.Rotate(new Vector3(0, -90, 0), Space.Self); ovrModule.transform.parent = cameraHolder.transform; ovrModule.transform.localPosition = new Vector3(); ovrCameraController = (OVRCameraController)GameObject.FindWithTag("OVRCameraController").GetComponent("OVRCameraController"); mainCameraGameObject = GameObject.FindWithTag("MainCamera"); GameObject[] tempCameraObjectArray = GameObject.FindGameObjectsWithTag("MainCamera"); mainCameraComponentList.Clear(); for (int i = 0; i < tempCameraObjectArray.Length; i++) { mainCameraComponentList.Add((Camera)tempCameraObjectArray[i].GetComponent("Camera")); } } else { GameObject normalCameraModule = (GameObject)Instantiate(mainCameraModulePrefab, new Vector3(), Quaternion.identity); //normalCameraModule.transform.Rotate(new Vector3(0, -90, 0), Space.Self); normalCameraModule.transform.parent = cameraHolder.transform; normalCameraModule.transform.localPosition = new Vector3(); mainCameraGameObject = GameObject.FindWithTag("MainCamera"); //GameObject.Find("Main Camera"); } }
/// <summary> /// Start /// </summary> new void Start() { base.Start(); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>(); if (CameraController == null) { Debug.LogWarning("WARNING: OVRCameraController not found!"); } // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering int w = 0; int h = 0; GetIdealResolution(ref w, ref h); int index = (RightEye) ? 1 : 0; if (camera.hdr) { CameraTexture[index] = new RenderTexture(w, h, 24, RenderTextureFormat.ARGBFloat); } else { CameraTexture[index] = new RenderTexture(w, h, 24); } // Use MSAA settings in QualitySettings for new RenderTexture CameraTexture[index].antiAliasing = (QualitySettings.antiAliasing == 0) ? 1 : QualitySettings.antiAliasing; camera.targetTexture = CameraTexture[index]; }
// * * * * * * * * * * * * * // Awake new public virtual void Awake() { base.Awake(); Instance = this; // We use Controller to move player around Controller = gameObject.GetComponent <CharacterController>(); if (Controller == null) { Debug.LogWarning("OVRPlayerController: No CharacterController attached."); } // We use OVRCameraController to set rotations to cameras, // and to be influenced by rotation OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRPlayerController: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } if (DirXform == null) { Debug.LogWarning("OVRPlayerController: ForwardDirection game object not found. Do not use."); } }
//// -- !UnityAndroid - CameraTexture is not used for Android. #pragma warning restore 414 // The private field 'x' is assigned but its value is never used #endregion #region Monobehaviour Member Functions /// <summary> /// Start /// </summary> void Start() { // Get the OVRCameraController CameraController = transform.parent.GetComponent<OVRCameraController>(); if(CameraController == null) { Debug.LogWarning("OVRCameraController not found!"); this.enabled = false; return; } #if (!UNITY_ANDROID || UNITY_EDITOR) if (!CameraController.UseCameraTexture) return; // This will scale the render texture based on ideal resolution if (CameraTexture[0] == null) CreateRenderTexture (CameraController.CameraTextureScale); camera.targetTexture = CameraTexture[(RightEye) ? 1 : 0]; #endif }
void Start() { OvrController = GameObject.Find("OVRCameraController").GetComponent<OVRCameraController>(); cameras = GameObject.FindGameObjectsWithTag("MainCamera"); characterController = GameObject.FindGameObjectWithTag("Player").GetComponent<MyCharacterMotor>(); }
// Start new void Start() { base.Start (); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent<OVRCameraController>(); if(CameraController == null) Debug.LogWarning("WARNING: OVRCameraController not found!"); // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) // CameraTextureScale = OVRDevice.DistortionScale(); // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering if((CameraTexture == null) && (CameraTextureScale != 1.0f)) { int w = (int)(Screen.width / 2.0f * CameraTextureScale); int h = (int)(Screen.height * CameraTextureScale); if ( camera.hdr ) CameraTexture = new RenderTexture( w, h, 24, RenderTextureFormat.ARGBFloat ); else CameraTexture = new RenderTexture( w, h, 24 ); // Use MSAA settings in QualitySettings for new RenderTexture CameraTexture.antiAliasing = ( QualitySettings.antiAliasing == 0 ) ? 1 : QualitySettings.antiAliasing; } }
public void Start() { switch(compass) { case CompassSource.Kinect: if (!skeletonManager) { skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; } if(!skeletonManager) Debug.LogError("RUISSkeletonManager script is missing from this scene!"); break; case CompassSource.PSMove: inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if(!inputManager) Debug.LogError("RUISInputManager script is missing from this scene!"); break; } if(driftingSensor == DriftingRotation.InputTransform && !driftingTransform) Debug.LogError("driftingTransform is none, you need to set it from the inspector!"); oculusCamController = FindObjectOfType(typeof(OVRCameraController)) as OVRCameraController; }
// End of Yaw Drift Corrector members void Awake() { localPosition = Vector3.zero; localRotation = Quaternion.identity; rawRotation = Quaternion.identity; filterPos = new KalmanFilter(); filterPos.initialize(3,3); filterPos.skipIdenticalMeasurements = true; // filterRot = new KalmanFilter(); // filterRot.initialize(4,4); // Mobile Razer Hydra base filtering hydraBaseFilterPos = new KalmanFilter(); hydraBaseFilterPos.initialize(3,3); hydraBaseFilterPos.skipIdenticalMeasurements = true; // hydraBaseFilterRot = new KalmanFilter(); // hydraBaseFilterRot.initialize(4,4); filterRot.skipIdenticalMeasurements = true; // Yaw Drift Corrector invocations in Awake() filterDrift = new KalmanFilter(); filterDrift.initialize(2,2); transform.localPosition = defaultPosition; eyeCenterPosition = defaultPosition; measuredHeadPosition = defaultPosition; hydraBasePosition = new Vector3(0, 0, 0); hydraBaseRotation = Quaternion.identity; oculusCamController = gameObject.GetComponentInChildren(typeof(OVRCameraController)) as OVRCameraController; if(oculusCamController) { useOculusRiftRotation = true; } else { useOculusRiftRotation = false; } //oculusCamController = FindObjectOfType(typeof(OVRCameraController)) as OVRCameraController; //if(headRotationInput == HeadRotationSource.OculusRift && !oculusCamController) // Debug.LogError("OVRCameraController script is missing from this scene!"); filterPosition = false; }
// * * * * * * * * * * * * * // Awake public new virtual void Awake() { base.Awake(); // Don't let the Physics Engine rotate this physics object so it doesn't fall over when running rigidbody.freezeRotation = true; collider.material.dynamicFriction = 0; collider.material.dynamicFriction2 = 0; collider.material.staticFriction = 0; collider.material.staticFriction2 = 0; collider.material.frictionCombine = PhysicMaterialCombine.Minimum; // We use OVRCameraController to set rotations to cameras, // and to be influenced by rotation OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if(CameraControllers.Length == 0) Debug.LogWarning("OVRPlayerController: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraController attached."); else CameraController = CameraControllers[0]; // Instantiate a Transform from the main game object (will be used to // direct the motion of the PlayerController, as well as used to rotate // a visible body attached to the controller) DirXform = null; Transform[] Xforms = gameObject.GetComponentsInChildren<Transform>(); for(int i = 0; i < Xforms.Length; i++) { if(Xforms[i].name == "ForwardDirection") { DirXform = Xforms[i]; break; } } if(DirXform == null) Debug.LogWarning("OVRPlayerController: ForwardDirection game object not found. Do not use."); }
// Use this for initialization void Start() { Time.timeScale=1; leftarrows = (Texture)Resources.Load("leftarrow"); rightarrows = (Texture)Resources.Load("rightarrow"); uparrows = (Texture)Resources.Load("uparrow"); left.renderer.material.color = Color.yellow; right.renderer.material.color = Color.yellow; straight.renderer.material.color = Color.yellow; ovr = GameObject.Find("OVRCameraController").GetComponent<OVRCameraController>(); }
/// <summary> /// Sets the OVR camera controller. /// </summary> /// <param name="cameraController">Camera controller.</param> public void SetOVRCameraController(ref OVRCameraController cameraController) { CameraController = cameraController; CameraController.GetCamera(ref MainCam); }
// OnEnable void OnEnable() { m_Component = (OVRCameraController)target; }
// OnEnable void OnEnable() { m_Component = (OVRCameraController)target; }
// Use this for initialization void Start() { // Set the GUI target GUIRenderObject = GameObject.Instantiate(Resources.Load("OVRGUIObjectMain")) as GameObject; // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = FindObjectsOfType(typeof(OVRCameraController)) as OVRCameraController[]; if (CameraControllers.Length == 0) { Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } if (GUIRenderObject != null) { if (GUIRenderTexture == null) // TODO: *** Screen.width from RUISDisplayManager { int w = Screen.width; int h = Screen.height; if (CameraController.PortraitMode == true) { int t = h; h = w; w = t; } GUIRenderTexture = new RenderTexture(w, h, 24); GuiHelper.SetPixelResolution(w, h); GuiHelper.SetDisplayResolution(OVRDevice.HResolution, OVRDevice.VResolution); } } // Attach GUI texture to GUI object and GUI object to Camera if (GUIRenderTexture != null && GUIRenderObject != null) { GUIRenderObject.renderer.material.mainTexture = GUIRenderTexture; if (CameraController != null) { // Grab transform of GUI object Transform t = GUIRenderObject.transform; // Attach the GUI object to the camera CameraController.AttachGameObjectToCamera(ref GUIRenderObject); // Reset the transform values (we will be maintaining state of the GUI object // in local state) OVRUtils.SetLocalTransform(ref GUIRenderObject, ref t); // Deactivate object until we have completed the fade-in // Also, we may want to deactive the render object if there is nothing being rendered // into the UI // we will move the position of everything over to the left, so get // IPD / 2 and position camera towards negative X Vector3 lp = GUIRenderObject.transform.localPosition; float ipd = 0.0f; CameraController.GetIPD(ref ipd); lp.x -= ipd * 0.5f; GUIRenderObject.transform.localPosition = lp; GUIRenderObject.SetActive(false); } } // Mag Yaw-Drift correction magCal.SetOVRCameraController(ref CameraController); }
/// <summary> /// Start this instance. /// </summary> new void Start() { base.Start (); // Get the OVRCameraController CameraController = GetComponent<OVRCameraController>(); if(CameraController == null) Debug.LogWarning("WARNING: OVRCameraController not found!"); }
void Start() { NeedsSetTexture = true; wasFullScreen = Screen.fullScreen; StartCoroutine(CallbackCoroutine()); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent<OVRCameraController>(); if(CameraController == null) { Debug.LogWarning("OVRCameraController not found!"); this.enabled = false; return; } if (!CameraController.UseCameraTexture) return; #if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX) // if AA & AF are disabled, step down RT scale for a FPS boost if (QualitySettings.anisotropicFiltering == 0 && QualitySettings.antiAliasing == 0) CameraController.CameraTextureScale = Mathf.Min(CameraController.CameraTextureScale, 0.7f); #endif // This will scale the render texture based on ideal resolution CreateRenderTexture(EyeId, CameraController.CameraTextureScale); GetComponent<Camera>().targetTexture = CameraTexture[EyeId]; OldScale = CameraController.ScaleRenderTarget; }
// * * * * * * * * * * * * * // Awake void Awake() { OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if(CameraControllers.Length == 0) Debug.LogWarning("No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("More then 1 OVRCameraController attached."); else CameraController = CameraControllers[0]; }
/// <summary> /// Start /// </summary> new void Start() { base.Start (); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent<OVRCameraController>(); if(CameraController == null) Debug.LogWarning("WARNING: OVRCameraController not found!"); // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering int w = 0; int h = 0; GetIdealResolution(ref w, ref h); int index = (RightEye) ? 1 : 0; if ( GetComponent<Camera>().hdr ) CameraTexture[index] = new RenderTexture( w, h, 24, RenderTextureFormat.ARGBFloat ); else CameraTexture[index] = new RenderTexture(w, h, 24); // Use MSAA settings in QualitySettings for new RenderTexture CameraTexture[index].antiAliasing = (QualitySettings.antiAliasing == 0) ? 1 : QualitySettings.antiAliasing; GetComponent<Camera>().targetTexture = CameraTexture[index]; }
/// <summary> /// Start this instance. /// </summary> void Start() { // Get the OVRCameraController CameraController = GetComponent<OVRCameraController>(); if(CameraController == null) Debug.LogWarning("WARNING: OVRCameraController not found!"); // Without this, we will be drawing 1 frame behind camera.depth = Mathf.Max (CameraLeft.depth, CameraRight.depth) + 1; // Don't want the camera to render anything.. camera.cullingMask = 0; camera.eventMask = 0; camera.useOcclusionCulling = false; camera.backgroundColor = Color.black; camera.clearFlags = (!CameraController.UseCameraTexture) ? CameraClearFlags.Nothing : CameraClearFlags.SolidColor; // TBD: This may be a performance loss on mobile. camera.renderingPath = RenderingPath.Forward; camera.orthographic = true; }
// // PUBLIC FUNCTIONS // /// <summary> /// Sets the camera controller. /// </summary> /// <param name="cameraController">Camera controller.</param> public void SetOVRCameraController(ref OVRCameraController cameraController) { CameraController = cameraController; }
void Start() { controller = GetComponent<OVRCameraController>(); }
// Start new void Start() { base.Start (); // Get the OVRCameraController CameraController = gameObject.transform.parent.GetComponent<OVRCameraController>(); if(CameraController == null) Debug.LogWarning("WARNING: OVRCameraController not found!"); // NOTE: MSAA TEXTURES NOT AVAILABLE YET // Set CameraTextureScale (increases the size of the texture we are rendering into // for a better pixel match when post processing the image through lens distortion) #if MSAA_ENABLED CameraTextureScale = OVRDevice.DistortionScale(); #endif // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture // Otherwise, fall back to normal camera rendering if((CameraTexture == null) && (CameraTextureScale > 1.0f)) { int w = (int)(Screen.width / 2.0f * CameraTextureScale); int h = (int)(Screen.height * CameraTextureScale); CameraTexture = new RenderTexture( w, h, 24); // 24 bit colorspace // NOTE: MSAA TEXTURES NOT AVAILABLE YET // This value should be the default for MSAA textures // CameraTexture.antiAliasing = 4; // Set it within the project #if MSAA_ENABLED CameraTexture.antiAliasing = QualitySettings.antiAliasing; #endif } }
/// <summary> /// Sets the OVR camera controller. /// </summary> /// <param name="cameraController">Camera controller.</param> public void SetOVRCameraController(ref OVRCameraController cameraController) { CameraController = cameraController; CameraController.GetCamera(ref MainCam); }
// * * * * * * * * * * * * * // Awake new public virtual void Awake() { base.Awake(); // We use Controller to move player around Controller = gameObject.GetComponent <CharacterController>(); if (Controller == null) { Debug.LogWarning("OVRPlayerController: No CharacterController attached."); } // We use OVRCameraController to set rotations to cameras, // and to be influenced by rotation OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraController>(); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRPlayerController: No OVRCameraController attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraController attached."); } else { CameraController = CameraControllers[0]; } // Instantiate a Transform from the main game object (will be used to // direct the motion of the PlayerController, as well as used to rotate // a visible body attached to the controller) DirXform = null; Transform[] Xforms = gameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < Xforms.Length; i++) { if (Xforms[i].name == "ForwardDirection") { DirXform = Xforms[i]; } if (Xforms[i].name == "Gun") { Debug.Log("Found Hand"); Hand = Xforms[i]; OldHand = Hand.position; } if (Hand != null && DirXform != null) { break; } } if (DirXform == null) { Debug.LogWarning("OVRPlayerController: ForwardDirection game object not found. Do not use."); } }
// Use this for initialization void Start() { // Set the GUI target GUIRenderObject = GameObject.Instantiate(Resources.Load("OVRGUIObjectMain")) as GameObject; // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = FindObjectsOfType(typeof(OVRCameraController)) as OVRCameraController[]; if(CameraControllers.Length == 0) Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); else CameraController = CameraControllers[0]; if(GUIRenderObject != null) { if(GUIRenderTexture == null) // TODO: *** Screen.width from RUISDisplayManager { int w = Screen.width; int h = Screen.height; if(CameraController != null && CameraController.PortraitMode == true) { int t = h; h = w; w = t; } GUIRenderTexture = new RenderTexture(w, h, 24); GuiHelper.SetPixelResolution(w, h); GuiHelper.SetDisplayResolution(OVRDevice.HResolution, OVRDevice.VResolution); } } // Attach GUI texture to GUI object and GUI object to Camera if(GUIRenderTexture != null && GUIRenderObject != null) { GUIRenderObject.renderer.material.mainTexture = GUIRenderTexture; if(CameraController != null) { // Grab transform of GUI object Transform t = GUIRenderObject.transform; // Attach the GUI object to the camera CameraController.AttachGameObjectToCamera(ref GUIRenderObject); // Reset the transform values (we will be maintaining state of the GUI object // in local state) OVRUtils.SetLocalTransform(ref GUIRenderObject, ref t); // Deactivate object until we have completed the fade-in // Also, we may want to deactive the render object if there is nothing being rendered // into the UI // we will move the position of everything over to the left, so get // IPD / 2 and position camera towards negative X Vector3 lp = GUIRenderObject.transform.localPosition; float ipd = 0.0f; CameraController.GetIPD(ref ipd); lp.x -= ipd * 0.5f; GUIRenderObject.transform.localPosition = lp; GUIRenderObject.SetActive(false); } } // Mag Yaw-Drift correction if(CameraController != null) { magCal.SetOVRCameraController(ref CameraController); magCal.SetInitialCalibarationState(); } // Show Oculus magnetometer status at the beginning if(showCalibrationStatus && OVRDevice.IsSensorPresent(0)) { delayedShowTime = delayedShowDuration; showMagStatus = true; } }
// SetOVRCameraController public void SetOVRCameraController(ref OVRCameraController cameraController) { CameraController = cameraController; }
private void Start() { ovrController = GameObject.Find("ORCamera").GetComponent<OVRCameraController>(); }
/// <summary> /// Awake this instance. /// </summary> void Awake() { // Find camera controller OVRCameraController[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren<OVRCameraController>(); if(CameraControllers.Length == 0) Debug.LogWarning("OVRMainMenu: No OVRCameraController attached."); else if (CameraControllers.Length > 1) Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraController attached."); else{ CameraController = CameraControllers[0]; } // Find player controller OVRPlayerController[] PlayerControllers; PlayerControllers = gameObject.GetComponentsInChildren<OVRPlayerController>(); if(PlayerControllers.Length == 0) Debug.LogWarning("OVRMainMenu: No OVRPlayerController attached."); else if (PlayerControllers.Length > 1) Debug.LogWarning("OVRMainMenu: More then 1 OVRPlayerController attached."); else{ PlayerController = PlayerControllers[0]; } }
private void Start() { CameraFade.StartAlphaFade(Color.black, true, 2f); ovrController = GameObject.Find("ORCamera").GetComponent <OVRCameraController>(); }