Configuration data for Oculus virtual reality.
Inheritance: MonoBehaviour
 private void CreateInputManager()
 {
     _ovrManager = Instantiate <OVRManager>(_ovrManagerPrefab);
     _ovrManager.transform.SetParent(transform);
     _ovrManager.name = _ovrManagerPrefab.name;
     _ovrManager.transform.localPosition = Vector3.zero;
 }
Exemple #2
0
    /// <summary>
    /// Show the confirm quit menu
    /// </summary>
    void ShowConfirmQuitMenu()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        Debug.Log("[PlatformUI-ConfirmQuit] Showing @ " + Time.time);
        OVRManager.PlatformUIConfirmQuit();
#endif
    }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     Cursor.lockState = CursorLockMode.None;
     manager          = OVRManager.instance;
     recordedHeadPoseRelativeOffsetTranslation = manager.headPoseRelativeOffsetTranslation;
     recordedHeadPoseRelativeOffsetRotation    = manager.headPoseRelativeOffsetRotation;
 }
	public void ReadFrom(OVRManager manager)
	{
		enableMixedReality = manager.enableMixedReality:
		compositionMethod = manager.compositionMethod:
		extraHiddenLayers = manager.extraHiddenLayers:
		capturingCameraDevice = manager.capturingCameraDevice:
		flipCameraFrameHorizontally = manager.flipCameraFrameHorizontally:
		flipCameraFrameVertically = manager.flipCameraFrameVertically:
		handPoseStateLatency = manager.handPoseStateLatency:
		sandwichCompositionRenderLatency = manager.sandwichCompositionRenderLatency:
		sandwichCompositionBufferedFrames = manager.sandwichCompositionBufferedFrames:
		chromaKeyColor = manager.chromaKeyColor:
		chromaKeySimilarity = manager.chromaKeySimilarity:
		chromaKeySmoothRange = manager.chromaKeySmoothRange:
		chromaKeySpillRange = manager.chromaKeySpillRange:
		useDynamicLighting = manager.useDynamicLighting:
		depthQuality = manager.depthQuality:
		dynamicLightingSmoothFactor = manager.dynamicLightingSmoothFactor:
		dynamicLightingDepthVariationClampingValue = manager.dynamicLightingDepthVariationClampingValue:
		virtualGreenScreenType = manager.virtualGreenScreenType:
		virtualGreenScreenTopY = manager.virtualGreenScreenTopY:
		virtualGreenScreenBottomY = manager.virtualGreenScreenBottomY:
		virtualGreenScreenApplyDepthCulling = manager.virtualGreenScreenApplyDepthCulling:
		virtualGreenScreenDepthTolerance = manager.virtualGreenScreenDepthTolerance:
	}
	public void ApplyTo(OVRManager manager)
	{
		manager.enableMixedReality = enableMixedReality:
		manager.compositionMethod = compositionMethod:
		manager.extraHiddenLayers = extraHiddenLayers:
		manager.capturingCameraDevice = capturingCameraDevice:
		manager.flipCameraFrameHorizontally = flipCameraFrameHorizontally:
		manager.flipCameraFrameVertically = flipCameraFrameVertically:
		manager.handPoseStateLatency = handPoseStateLatency:
		manager.sandwichCompositionRenderLatency = sandwichCompositionRenderLatency:
		manager.sandwichCompositionBufferedFrames = sandwichCompositionBufferedFrames:
		manager.chromaKeyColor = chromaKeyColor:
		manager.chromaKeySimilarity = chromaKeySimilarity:
		manager.chromaKeySmoothRange = chromaKeySmoothRange:
		manager.chromaKeySpillRange = chromaKeySpillRange:
		manager.useDynamicLighting = useDynamicLighting:
		manager.depthQuality = depthQuality:
		manager.dynamicLightingSmoothFactor = dynamicLightingSmoothFactor:
		manager.dynamicLightingDepthVariationClampingValue = dynamicLightingDepthVariationClampingValue:
		manager.virtualGreenScreenType = virtualGreenScreenType:
		manager.virtualGreenScreenTopY = virtualGreenScreenTopY:
		manager.virtualGreenScreenBottomY = virtualGreenScreenBottomY:
		manager.virtualGreenScreenApplyDepthCulling = virtualGreenScreenApplyDepthCulling:
		manager.virtualGreenScreenDepthTolerance = virtualGreenScreenDepthTolerance:
	}
Exemple #6
0
    /// <summary>
    /// Recenters the head pose.
    /// </summary>
    public void RecenterPose()
    {
#if USING_XR_SDK
        XRInputSubsystem currentInputSubsystem = OVRManager.GetCurrentInputSubsystem();
        if (currentInputSubsystem != null)
        {
            currentInputSubsystem.TryRecenter();
        }
#elif !REQUIRES_XR_SDK
#pragma warning disable 618
        InputTracking.Recenter();
#pragma warning restore 618
#endif

        // The current poses are cached for the current frame and won't be updated immediately
        // after UnityEngine.VR.InputTracking.Recenter(). So we need to wait until next frame
        // to trigger the RecenteredPose delegate. The application could expect the correct pose
        // when the RecenteredPose delegate get called.
        recenterRequested           = true;
        recenterRequestedFrameCount = Time.frameCount;

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        OVRMixedReality.RecenterPose();
#endif
    }
Exemple #7
0
    void Update()
    {
        if (OVRInput.GetDown(OVRInput.Button.One) || OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger))
        {
            buttonPressed = true;
        }

        if (buttonPressed && (OVRInput.GetUp(OVRInput.Button.One) || OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger)))
        {
            buttonPressed = false;
            Scene scene = SceneManager.GetActiveScene();

            if (scene.name == "heart_01")
            {
#if UNITY_ANDROID && !UNITY_EDITOR
                OVRManager.PlatformUIConfirmQuit();
#endif
            }
            else
            {
                SceneManager.LoadScene("heart_01", LoadSceneMode.Single);
            }
        }

        if (OVRInput.GetUp(OVRInput.Button.One) || OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger))
        {
            buttonPressed = false;
        }
    }
Exemple #8
0
 public void ReadFrom(OVRManager manager)
 {
     enableMixedReality = manager.enableMixedReality;
     compositionMethod  = manager.compositionMethod;
     extraHiddenLayers  = manager.extraHiddenLayers;
     externalCompositionBackdropColorRift  = manager.externalCompositionBackdropColorRift;
     externalCompositionBackdropColorQuest = manager.externalCompositionBackdropColorQuest;
     capturingCameraDevice             = manager.capturingCameraDevice;
     flipCameraFrameHorizontally       = manager.flipCameraFrameHorizontally;
     flipCameraFrameVertically         = manager.flipCameraFrameVertically;
     handPoseStateLatency              = manager.handPoseStateLatency;
     sandwichCompositionRenderLatency  = manager.sandwichCompositionRenderLatency;
     sandwichCompositionBufferedFrames = manager.sandwichCompositionBufferedFrames;
     chromaKeyColor              = manager.chromaKeyColor;
     chromaKeySimilarity         = manager.chromaKeySimilarity;
     chromaKeySmoothRange        = manager.chromaKeySmoothRange;
     chromaKeySpillRange         = manager.chromaKeySpillRange;
     useDynamicLighting          = manager.useDynamicLighting;
     depthQuality                = manager.depthQuality;
     dynamicLightingSmoothFactor = manager.dynamicLightingSmoothFactor;
     dynamicLightingDepthVariationClampingValue = manager.dynamicLightingDepthVariationClampingValue;
     virtualGreenScreenType              = manager.virtualGreenScreenType;
     virtualGreenScreenTopY              = manager.virtualGreenScreenTopY;
     virtualGreenScreenBottomY           = manager.virtualGreenScreenBottomY;
     virtualGreenScreenApplyDepthCulling = manager.virtualGreenScreenApplyDepthCulling;
     virtualGreenScreenDepthTolerance    = manager.virtualGreenScreenDepthTolerance;
 }
    // Start is called before the first frame update
    void Start()
    {
        soundManager = FindObjectOfType <SoundManager>();
        player       = FindObjectOfType <OVRManager>();
        colorChanger = FindObjectOfType <ChangeColors>();
        fader        = FindObjectOfType <FadeUIElement>();

        foreach (GameObject node in Node0)
        {
            node.GetComponent <BaseHitObject>().ListNum = 0;
        }

        foreach (GameObject node in Node1)
        {
            node.GetComponent <BaseHitObject>().ListNum = 1;
        }

        foreach (GameObject node in Node2)
        {
            node.GetComponent <BaseHitObject>().ListNum = 2;
        }

        foreach (GameObject node in Node3)
        {
            node.GetComponent <BaseHitObject>().ListNum = 3;
        }

        foreach (GameObject node in Node4)
        {
            node.GetComponent <BaseHitObject>().ListNum = 4;
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         OVRManager.PlatformUIConfirmQuit();
     }
 }
Exemple #11
0
 public void ApplyTo(OVRManager manager)
 {
     manager.enableMixedReality                = this.enableMixedReality;
     manager.compositionMethod                 = this.compositionMethod;
     manager.extraHiddenLayers                 = this.extraHiddenLayers;
     manager.capturingCameraDevice             = this.capturingCameraDevice;
     manager.flipCameraFrameHorizontally       = this.flipCameraFrameHorizontally;
     manager.flipCameraFrameVertically         = this.flipCameraFrameVertically;
     manager.handPoseStateLatency              = this.handPoseStateLatency;
     manager.sandwichCompositionRenderLatency  = this.sandwichCompositionRenderLatency;
     manager.sandwichCompositionBufferedFrames = this.sandwichCompositionBufferedFrames;
     manager.chromaKeyColor              = this.chromaKeyColor;
     manager.chromaKeySimilarity         = this.chromaKeySimilarity;
     manager.chromaKeySmoothRange        = this.chromaKeySmoothRange;
     manager.chromaKeySpillRange         = this.chromaKeySpillRange;
     manager.useDynamicLighting          = this.useDynamicLighting;
     manager.depthQuality                = this.depthQuality;
     manager.dynamicLightingSmoothFactor = this.dynamicLightingSmoothFactor;
     manager.dynamicLightingDepthVariationClampingValue = this.dynamicLightingDepthVariationClampingValue;
     manager.virtualGreenScreenType              = this.virtualGreenScreenType;
     manager.virtualGreenScreenTopY              = this.virtualGreenScreenTopY;
     manager.virtualGreenScreenBottomY           = this.virtualGreenScreenBottomY;
     manager.virtualGreenScreenApplyDepthCulling = this.virtualGreenScreenApplyDepthCulling;
     manager.virtualGreenScreenDepthTolerance    = this.virtualGreenScreenDepthTolerance;
 }
Exemple #12
0
 // Start is called before the first frame update
 void Start()
 {
     oVRCameraRig       = this.gameObject.GetComponent <OVRCameraRig>();
     oVRManager         = this.gameObject.GetComponent <OVRManager>();
     oVRHeadsetEmulator = this.gameObject.GetComponent <OVRHeadsetEmulator>();
     viewpointCamera    = this.gameObject.GetComponent <Camera>();
 }
Exemple #13
0
    void Start()
    {
        player              = GameObject.Find("OVRPlayerController");
        playerCube          = GameObject.Find("Cube");
        characterController = player.GetComponent <CharacterController>();
        ovrManager          = GameObject.Find("OVRCameraRig").GetComponent <OVRManager>();
        avatar              = GameObject.Find("LocalAvatar").GetComponent <OvrAvatar>();


        //sword = GameObject.Find("Weapon");

        grip           = GameObject.Find("RightHandAnchor");
        swordEye       = GameObject.FindGameObjectsWithTag("swordEye");
        trackingAnchor = GameObject.Find("TrackerAnchor");
        gManager       = GameObject.Find("GameManager");
        gScript        = gManager.GetComponent <GameManager>();

        soundObject  = GameObject.Find("SoundManager");
        soundManager = soundObject.GetComponent <SoundManager>();
        soundPlayer  = gameObject.GetComponent <AudioSource>();
        soundPlayer2 = gameObject.GetComponentInParent <AudioSource>();


        if (gScript.difficulty == 0 && gScript.GetGameLevel() == 3)
        {
            health = 20;
        }


        if (gScript.difficulty == 1 && gScript.GetGameLevel() == 3)
        {
            health = gScript.playerHealth;
        }
    }
Exemple #14
0
    /// <summary>
    /// Show the platform UI global menu
    /// </summary>
    void ShowGlobalMenu()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        Debug.Log("[PlatformUI-Global] Showing @ " + Time.time);
        OVRManager.PlatformUIGlobalMenu();
#endif
    }
    void Update()
    {
        if (OVRInput.GetDown(OVRInput.Button.Back) || Input.GetKeyDown(KeyCode.Escape))
        {
            buttonPressed = true;
        }

        if (buttonPressed && (OVRInput.GetUp(OVRInput.Button.Back) || Input.GetKeyUp(KeyCode.Escape)))
        {
            buttonPressed = false;
            Scene scene = SceneManager.GetActiveScene();

            if (scene.name == "main")
            {
#if UNITY_ANDROID && !UNITY_EDITOR
                OVRManager.PlatformUIConfirmQuit();
#endif
            }
            else
            {
                SceneManager.LoadScene("main", LoadSceneMode.Single);
            }
        }

        if (OVRInput.GetUp(OVRInput.Button.Back) || Input.GetKeyUp(KeyCode.Escape))
        {
            buttonPressed = false;
        }
    }
Exemple #16
0
 void Update()
 {
     // "←"ボタンを押した時にメニュー画面を開く処理
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         OVRManager.PlatformUIConfirmQuit();
     }
 }
    private void UpdateHandAnchorsIfNeedIt(bool updateHandAnchors, OVRPose tracker)
    {
        if (updateHandAnchors && HandView.IsMine)
        {
            //Need this for controller offset because if we're on OpenVR, we want to set the local poses as specified by Unity, but if we're not, OVRInput local position is the right anchor
            if (OVRManager.loadedXRDevice == OVRManager.XRDevice.OpenVR)
            {
                Vector3    leftPos   = Vector3.zero;
                Vector3    rightPos  = Vector3.zero;
                Quaternion leftQuat  = Quaternion.identity;
                Quaternion rightQuat = Quaternion.identity;

                if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.LeftHand, NodeStatePropertyType.Position, OVRPlugin.Node.HandLeft, OVRPlugin.Step.Render, out leftPos))
                {
                    leftHandAnchor.localPosition = leftPos;
                }
                if (OVRNodeStateProperties.GetNodeStatePropertyVector3(Node.RightHand, NodeStatePropertyType.Position, OVRPlugin.Node.HandRight, OVRPlugin.Step.Render, out rightPos))
                {
                    rightHandAnchor.localPosition = rightPos;
                }
                if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.LeftHand, NodeStatePropertyType.Orientation, OVRPlugin.Node.HandLeft, OVRPlugin.Step.Render, out leftQuat))
                {
                    leftHandAnchor.localRotation = leftQuat;
                }
                if (OVRNodeStateProperties.GetNodeStatePropertyQuaternion(Node.RightHand, NodeStatePropertyType.Orientation, OVRPlugin.Node.HandRight, OVRPlugin.Step.Render, out rightQuat))
                {
                    rightHandAnchor.localRotation = rightQuat;
                }
            }
            else
            {
                leftHandAnchor.localPosition  = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
                rightHandAnchor.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
                leftHandAnchor.localRotation  = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
                rightHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
            }
            trackerAnchor.localPosition = tracker.position;

            OVRPose leftOffsetPose  = OVRPose.identity;
            OVRPose rightOffsetPose = OVRPose.identity;
            if (OVRManager.loadedXRDevice == OVRManager.XRDevice.OpenVR)
            {
                GetOpenVRControllerOffset(Node.LeftHand, HandView, ref leftOffsetPose);
                GetOpenVRControllerOffset(Node.RightHand, HandView, ref rightOffsetPose);

                //Sets poses of left and right nodes, local to the tracking space.
                OVRManager.SetOpenVRLocalPose(trackingSpace.InverseTransformPoint(leftControllerAnchor.position),
                                              trackingSpace.InverseTransformPoint(rightControllerAnchor.position),
                                              Quaternion.Inverse(trackingSpace.rotation) * leftControllerAnchor.rotation,
                                              Quaternion.Inverse(trackingSpace.rotation) * rightControllerAnchor.rotation);
            }
            rightControllerAnchor.localPosition = rightOffsetPose.position;
            rightControllerAnchor.localRotation = rightOffsetPose.orientation;
            leftControllerAnchor.localPosition  = leftOffsetPose.position;
            leftControllerAnchor.localRotation  = leftOffsetPose.orientation;
        }
    }
Exemple #18
0
    void OnEnable()
    {
        OVRManager.HMDAcquired += OnHMDAcquired;
        OVRManager.HMDLost     += OnHMDLost;

        OVRGamepadController.GPC_Initialize();

        OVRManager.DismissHSWDisplay();
    }
Exemple #19
0
        private void InitializeNonFloorOrigin()
        {
#if VR_BLOCKS_OCULUS
            Debug.Log("VrBlocks: Setting Tracking Origin to Floor via OVRManager");
            OVRManager manager = this.gameObject.AddComponent <OVRManager>();
            manager.trackingOriginType = OVRManager.TrackingOrigin.FloorLevel;
#else
            Debug.Log("VrBlocks: Setting default height for non-floor tracking origin.");
            PlayerHeightAdjustment = 1.754f;
#endif
        }
 //後ろの文字を消去します。
 //TextHandler の UnityEvent に登録して呼び出します。
 public void OnBackspace()
 {
     if (textMesh.text.Length != 0)
     {
         textMesh.text = textMesh.text.Remove(textMesh.text.Length - 1, 1);
     }
     else
     {
         OVRManager.PlatformUIConfirmQuit();
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (AllowMovement)
        {
            float gamePad_FwdAxis    = OVRInput.Get(OVRInput.RawAxis2D.LThumbstick).y;
            float gamePad_StrafeAxis = OVRInput.Get(OVRInput.RawAxis2D.LThumbstick).x;

            Vector3 fwdMove    = (CameraRig.centerEyeAnchor.rotation * Vector3.forward) * gamePad_FwdAxis * Time.deltaTime * ForwardSpeed;
            Vector3 strafeMove = (CameraRig.centerEyeAnchor.rotation * Vector3.right) * gamePad_StrafeAxis * Time.deltaTime * StrafeSpeed;
            transform.position += fwdMove + strafeMove;
        }

        bool hasDevice = false;

#if USING_XR_SDK
        XRDisplaySubsystem currentDisplaySubsystem = OVRManager.GetCurrentDisplaySubsystem();
        if (currentDisplaySubsystem != null)
        {
            hasDevice = currentDisplaySubsystem.running;
        }
#elif REQUIRES_XR_SDK
        hasDevice = false;
#else
        hasDevice = UnityEngine.XR.XRDevice.isPresent;
#endif

        if (!hasDevice && (AllowYawLook || AllowPitchLook))
        {
            Quaternion r = transform.rotation;
            if (AllowYawLook)
            {
                float      gamePadYaw = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick).x;
                float      yawAmount  = gamePadYaw * Time.deltaTime * GamePad_YawDegreesPerSec;
                Quaternion yawRot     = Quaternion.AngleAxis(yawAmount, Vector3.up);
                r = yawRot * r;
            }
            if (AllowPitchLook)
            {
                float gamePadPitch = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick).y;
                if (Mathf.Abs(gamePadPitch) > 0.0001f)
                {
                    if (InvertPitch)
                    {
                        gamePadPitch *= -1.0f;
                    }
                    float      pitchAmount = gamePadPitch * Time.deltaTime * GamePad_PitchDegreesPerSec;
                    Quaternion pitchRot    = Quaternion.AngleAxis(pitchAmount, Vector3.left);
                    r = r * pitchRot;
                }
            }

            transform.rotation = r;
        }
    }
Exemple #22
0
    public void GoToPrevious()
    {
        if (panelHistory.Count == 0)
        {
            OVRManager.PlatformUIConfirmQuit();
            return;
        }
        int lastIndex = panelHistory.Count - 1;

        SetCurrent(panelHistory[lastIndex]);
        panelHistory.RemoveAt(lastIndex);
    }
        protected virtual void FixOculus()
        {
#if VRTK_DEFINE_SDK_OCULUS
            string        oculusPath    = "[VRTK_SDKManager]/[VRTK_SDKSetups]/Oculus";
            GameObject    oculusSDK     = GameObject.Find(oculusPath);
            GameObject    currentRig    = GameObject.Find(oculusPath + "/OVRCameraRig");
            GameObject    currentAvatar = GameObject.Find(oculusPath + "/LocalAvatar");
            VRTK_SDKSetup oculusSetup   = oculusSDK.GetComponent <VRTK_SDKSetup>();

            if (currentRig != null)
            {
                DestroyImmediate(currentRig);
            }
            if (currentAvatar != null)
            {
                DestroyImmediate(currentAvatar);
            }

            GameObject ovrCameraRig = PrefabUtility.InstantiatePrefab((GameObject)AssetDatabase.LoadAssetAtPath("Assets/Oculus/VR/Prefabs/OVRCameraRig.prefab", typeof(GameObject))) as GameObject;
            if (ovrCameraRig != null)
            {
                ovrCameraRig.transform.SetParent(oculusSDK.transform);
                ovrCameraRig.SetActive(false);
                oculusSetup.actualBoundaries      = ovrCameraRig;
                oculusSetup.actualHeadset         = GameObject.Find(oculusPath + "/OVRCameraRig/TrackingSpace/CenterEyeAnchor");
                oculusSetup.actualLeftController  = GameObject.Find(oculusPath + "/OVRCameraRig/TrackingSpace/LeftHandAnchor");
                oculusSetup.actualRightController = GameObject.Find(oculusPath + "/OVRCameraRig/TrackingSpace/RightHandAnchor");
                OVRManager ovrManager = ovrCameraRig.GetComponent <OVRManager>();
                ovrManager.trackingOriginType = OVRManager.TrackingOrigin.FloorLevel;
                Debug.Log("Successfully repaired Oculus OVRCameraRig prefab");
            }

            GameObject ovrAvatar = PrefabUtility.InstantiatePrefab((GameObject)AssetDatabase.LoadAssetAtPath("Assets/Oculus/Avatar/Content/Prefabs/LocalAvatar.prefab", typeof(GameObject))) as GameObject;
            if (ovrAvatar == null)
            {
                //legacy location
                ovrAvatar = PrefabUtility.InstantiatePrefab((GameObject)AssetDatabase.LoadAssetAtPath("Assets/OvrAvatar/Content/Prefabs/LocalAvatar.prefab", typeof(GameObject))) as GameObject;
            }
            if (ovrAvatar != null)
            {
                ovrAvatar.transform.SetParent(oculusSDK.transform);
                ovrAvatar.SetActive(false);
                oculusSetup.modelAliasLeftController  = GameObject.Find(oculusPath + "/LocalAvatar/controller_left");
                oculusSetup.modelAliasRightController = GameObject.Find(oculusPath + "/LocalAvatar/controller_right");
                GameObject.Find(oculusPath + "/LocalAvatar/hand_left").SetActive(false);
                GameObject.Find(oculusPath + "/LocalAvatar/hand_right").SetActive(false);
                VRTK_TransformFollow transformFollow = ovrAvatar.AddComponent <VRTK_TransformFollow>();
                transformFollow.gameObjectToFollow = ovrCameraRig;
                Debug.Log("Successfully repaired Oculus LocalAvatar prefab");
            }
#endif
        }
Exemple #24
0
    private IEnumerator CallbackCoroutine()
    {
        while (true)
        {
            yield return(waitForEndOfFrame);

                        #if UNITY_ANDROID && !UNITY_EDITOR
            OVRManager.DoTimeWarp(timeWarpViewNumber);
                        #else
            display.EndFrame();
                        #endif
        }
    }
Exemple #25
0
    // Start is called before the first frame update
    void Start()
    {
        oVRCameraRig       = this.gameObject.GetComponent <OVRCameraRig>();
        oVRManager         = this.gameObject.GetComponent <OVRManager>();
        oVRHeadsetEmulator = this.gameObject.GetComponent <OVRHeadsetEmulator>();

        currentTreasureIndex = 0;
        foreach (CollectibleTreasure treasure in treasureItems)
        {
            treasure.gameObject.active = false;
        }
        treasureItems[currentTreasureIndex].gameObject.active = true;
    }
Exemple #26
0
    //-----------------------------------------------------------

    void Start()
    {
        localAvatar  = GameObject.Find("LocalAvatar(Clone)");
        ovrCameraRig = GameObject.Find("OVRCameraRig");
        gunman       = GameObject.Find("Gunman");
        bullet       = Resources.Load("Bullet") as GameObject;
        ovrM         = ovrCameraRig.GetComponent <OVRManager>();
        pv           = GetComponent <PhotonView>();

        gunman.SetActive(false);
        defPos = localAvatar.transform.position;
        defRot = localAvatar.transform.rotation;
    }
Exemple #27
0
    void enableOculusPositionalTracking()
    {
        OVRManager ovrManager = FindObjectOfType <OVRManager>();

        if (ovrManager)
        {
            ovrManager.usePositionTracking = true;
        }
        if (OVRManager.tracker != null)
        {
            OVRManager.tracker.isEnabled = true;
        }
    }
Exemple #28
0
 void Start()
 {
     OVRManager.TrackingAcquired += OnOculusStart;
     OVRManager.TrackingLost     += OnOculusEnd;
     if (OVRManager.capiHmd != null)
     {
         OVRManager.DismissHSWDisplay();     // disable safety message
         OnOculusStart();
     }
     else
     {
         OnOculusEnd();
     }
 }
Exemple #29
0
 private void SetupManager()
 {
     if (OVRManager.instance == null)
     {
         Debug.Log("[GearVR] Adding OVRManager");
         var go = new GameObject("OVRManager");
         mManager = go.AddComponent <OVRManager>();
         DontDestroyOnLoad(go);
     }
     else
     {
         mManager = OVRManager.instance;
     }
 }
    void OnPostRender()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        // Allow custom code to render before we kick off the plugin
        if (OnCustomPostRender != null)
        {
            OnCustomPostRender();
        }

        OVREye eye = ((RenderEventType)Camera.current.depth == RenderEventType.RightEyeEndFrame) ?
                     OVREye.Right : OVREye.Left;
        OVRManager.EndEye(eye);
#endif
    }
	// Use this for initialization
	void Start () {
		rift = GameObject.Find("OVRCameraRig");
		manager = rift.GetComponent<OVRManager>();
	}
	void Start()
	{
		// Get information about Oculus Rift version and if it is connected
		ovrManager = FindObjectOfType<OVRManager>();
		bool isRiftConnected = false;
		//		#if UNITY_EDITOR
		//		if(UnityEditorInternal.InternalEditorUtility.HasPro())
		//		#endif
		{
			try
			{
				if(OVRManager.capiHmd != null)
					ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type;
				if(OVRManager.display != null)
				{
					isRiftConnected = OVRManager.display.isPresent;
					
					if(coordinateSystem && coordinateSystem.applyToRootCoordinates && headPositionInput == HeadPositionSource.OculusDK2)
					{
						OVRManager.display.RecenteredPose += RecenterPoseWarning;
					}	
				}
			}
			catch(UnityException e)
			{
				Debug.LogError(e);
			}
		}
		
		if(headPositionInput == HeadPositionSource.OculusDK2)
		{
			if(!isRiftConnected) 
			{
				headPositionInput = HeadPositionSource.None;
				this.transform.localPosition = defaultPosition;
			}
			else 
			{
				OculusCounterPoseOffset();
				if(coordinateSystem && coordinateSystem.applyToRootCoordinates)
					this.localRotation = coordinateSystem.GetOculusCameraYRotation();
			}
		}
		
		if(headPositionInput == HeadPositionSource.Kinect1) {
			kinectSensorID = RUISSkeletonManager.kinect1SensorID;
		}
		if(headPositionInput == HeadPositionSource.Kinect2) {
			kinectSensorID = RUISSkeletonManager.kinect2SensorID;
		}
		
		inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		if(		!inputManager
		   &&  (	headPositionInput == HeadPositionSource.PSMove
		     || headRotationInput == HeadRotationSource.PSMove
		     || (externalDriftCorrection && compass == CompassSource.PSMove)))
			Debug.LogError("RUISInputManager script is missing from this scene!");
		
		if(inputManager && !inputManager.enablePSMove)
		{
			if(headPositionInput == HeadPositionSource.PSMove)
				Debug.LogError(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for position "
				               +	"tracking, but you have not enabled it from InputManager.");
			if(headRotationInput == HeadRotationSource.PSMove)
				Debug.LogError(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for rotation "
				               +	"tracking, but you have not enabled it from InputManager.");
			if(externalDriftCorrection && compass == CompassSource.PSMove)
				Debug.LogError(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for yaw drift "
				               +	"correction, but you have not enabled it from InputManager.");
		}
		
		if (!skeletonManager)
			skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager;
		if(		!skeletonManager
		   &&  (	headPositionInput == HeadPositionSource.Kinect1
		     || headPositionInput == HeadPositionSource.Kinect2
		     || (!useOculusRiftRotation && (headRotationInput == HeadRotationSource.Kinect1 || headRotationInput == HeadRotationSource.Kinect2))
		     || (externalDriftCorrection && (compass == CompassSource.Kinect1 || compass == CompassSource.Kinect2))))
		{
			Debug.LogError("RUISSkeletonManager script is missing from this scene!");
		}
		
		if(inputManager && !inputManager.enableRazerHydra)
		{
			if(headPositionInput == HeadPositionSource.RazerHydra)
				Debug.LogWarning(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for "
				                 +	"position tracking, but you have disabled Razer Hydra from RUIS "
				                 +	"InputManager.");
			if(headRotationInput == HeadRotationSource.RazerHydra)
				Debug.LogWarning(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for "
				                 +	"rotation tracking, but you have disabled Razer Hydra from RUIS "
				                 +	"InputManager.");
			if(externalDriftCorrection && compass == CompassSource.RazerHydra)
				Debug.LogWarning(	"Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for "
				                 +	"yaw drift correction, but you have disabled Razer Hydra from RUIS "
				                 +	"InputManager.");
		}
		
		if(headPositionInput == HeadPositionSource.InputTransform && !positionInput)
			Debug.LogError("Position tracker's Input Transform is none, you need to set it in Unity inspector!");
		
		if(headRotationInput == HeadRotationSource.InputTransform && !rotationInput && !useOculusRiftRotation)
			Debug.LogError("Rotation tracker's Input Transform is none, you need to set it in Unity inspector!");
		
		if(headPositionInput == HeadPositionSource.Kinect1 && positionJoint == RUISSkeletonManager.Joint.None)
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track position with a "
			               + "Kinect joint, but you have left its value to None in Unity inspector!");
		
		if(		headRotationInput == HeadRotationSource.Kinect1 && rotationJoint == RUISSkeletonManager.Joint.None
		   &&	!useOculusRiftRotation																
		   )
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track rotation with a "
			               + "Kinect joint, but you have left its value to None in Unity inspector!");
		
		if(		externalDriftCorrection && compass == CompassSource.Kinect1 && compassJoint == RUISSkeletonManager.Joint.None
		   &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to do yaw drift correction with a "
			               + "Kinect joint, but you have left its value to None in Unity inspector!");
		
		if(headPositionInput == HeadPositionSource.Kinect2 && positionJoint == RUISSkeletonManager.Joint.None)
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track position with a "
			               + "Kinect2 joint, but you have left its value to None in Unity inspector!");
		
		if(		headRotationInput == HeadRotationSource.Kinect2 && rotationJoint == RUISSkeletonManager.Joint.None
		   &&	!useOculusRiftRotation																	
		   )
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track rotation with a "
			               + "Kinect2 joint, but you have left its value to None in Unity inspector!");
		
		if(		externalDriftCorrection && compass == CompassSource.Kinect2 && compassJoint == RUISSkeletonManager.Joint.None
		   &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
			Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to do yaw drift correction with a "
			               + "Kinect2 joint, but you have left its value to None in Unity inspector!");
		
		if(		externalDriftCorrection && compass == CompassSource.InputTransform && !compassTransform 
		   &&  !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform))
			Debug.LogError("Yaw drift corrector's Input Transform is none, you need to set it in Unity inspector!");
		
		if(externalDriftCorrection && compassIsPositionTracker && headPositionInput == HeadPositionSource.None)
			Debug.LogError(		"Position Tracker is set to None, but in 'Yaw Drift Correction' you have enabled "
			               +	"'Use Position Tracker'!");
		
		if(isRazerBaseMobile && (	headPositionInput == HeadPositionSource.RazerHydra
		                         || headRotationInput == HeadRotationSource.RazerHydra
		                         || compass == CompassSource.RazerHydra				  ))
		{
			if(mobileRazerBase == RazerHydraBase.InputTransform && hydraBaseInput == null)
				Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track Razer Hydra base station with a "
				               + "custom Input Transform, but you have left its value to None in Unity inspector!");
			if(mobileRazerBase == RazerHydraBase.Kinect1 && hydraBaseJoint == RUISSkeletonManager.Joint.None)
				Debug.LogError(	 "Your " + typeof(RUISTracker) + " settings indicate that you want to track Razer Hydra base station with a "
				               + "Kinect joint, but you have left its value to None in Unity inspector!");
		}
		
		if(useOculusRiftRotation && headPositionInput != HeadPositionSource.OculusDK2 && ovrCameraRig != null)
		{
			DisableOculusPositionalTracking();
			
			// OVR manager is not necessarily initialized, so lets do the above disabling later as well
			StartCoroutine(DelayedDisableOculusPositionalTracking());
			
			Debug.Log(  typeof(RUISTracker) + ": Position Tracker is " + headPositionInput + " and " + typeof(OVRCameraRig)
			          + " found in a child gameObject, turning off Oculus Rift position tracking altogether. If you do not "
			          + "want this, then remove the " + typeof(OVRCameraRig) + " component from the child object(s).");
		}
		
		if(ovrCameraRig && Application.isEditor)
			Debug.Log(typeof(OVRCameraRig) + " script detected in a child object of this " + gameObject.name
			          + " object. Using Oculus Rift as a Rotation Tracker. You can access other rotation "
			          + "trackers when you remove the " + typeof(OVRCameraRig) + " component from the child object(s).");
		
		//		if(useOculusRiftRotation && inputManager)
		//		{
		//			if(		(inputManager.enableKinect 		&& headPositionInput == HeadPositionSource.Kinect)
		//				||	(inputManager.enableRazerHydra 	&& headPositionInput == HeadPositionSource.RazerHydra)
		//				||	(inputManager.enablePSMove 		&& headPositionInput == HeadPositionSource.PSMove)
		//				||	headPositionInput == HeadPositionSource.InputTransform								  )
		//			{
		//				oculusCamController.SetNeckPosition(Vector3.zero);
		//				oculusCamController.SetEyeCenterPosition(Vector3.zero);
		//				Debug.Log(	"Head position tracker found, setting NeckPosition and EyeCenterPosition to zero from "
		//						  + "OVRManager.");
		//			}
		//		}
	}
    void Awake()
    {
        riftManagerScript = GameObject.Find("OVRCameraRig").GetComponent("OVRManager") as OVRManager;
        riftTextPlane1 = GameObject.Find("TextPlane1");
        riftTextPlane2 = GameObject.Find("TextPlane2");
        riftTextPlane3 = GameObject.Find("TextPlane3");
        WriteToLeftGlove = new byte[(LpalmChannel? 1: 0 )+ LchannelsPerFinger * LnumChannelFingers];
        WriteToRightGlove = new byte[(LpalmChannel? 1: 0 )+ LchannelsPerFinger * LnumChannelFingers];
        colors = new Color[]{ Color.blue, Color.red, Color.yellow, Color.green, Color.cyan,   Color.magenta   };
        SubID =  PlayerPrefs.GetInt("Subject Identifier");
        numSpheres = PlayerPrefs.GetInt("Number of Stimuli");
        modeString = PlayerPrefs.GetString("Mode");
        diff =  PlayerPrefs.GetInt("Difficulty");
        expectedNumberOfTrials = PlayerPrefs.GetInt("Number of Trials");

        pattern = System.Convert.ToBoolean(PlayerPrefs.GetInt("Pattern"));
        setPatternBool();
        setTimedBool();
        stimFoundTimes = new string[numSpheres];

        cpuCounter = new PerformanceCounter();

        cpuCounter.CategoryName = "Processor";
        cpuCounter.CounterName = "% Processor Time";
        cpuCounter.InstanceName = "_Total";

        ramCounter = new PerformanceCounter("Memory", "Available MBytes");

            path = @"C:\Users\Holodeck\Documents\GitHub\UnityHolodeckProject\Assets\TreasureHunt\SubjectData\ID-" + SubID + "_" + "Time-" + System.DateTime.Now.ToString("yyyy-MM-dd_H-mm") + ".txt";

        int i = 0;
           /* for (; ; )
        {
            if (File.Exists(@path))
            {
                i++;

            }
            else
            {
                path = path.Insert((path.Length - 5), i.ToString());
                break;
            }
        }*/

           using( StreamWriter stream = new StreamWriter(path, true)){

            string header = "Object Swap Task- Subj: " + SubID + ", Mode: " + modeString + "," + "Pattern Type: " + ((pattern ) ? "Pattern" : "Random")
                + ", Trials: " + expectedNumberOfTrials + ", #Stim: " + numSpheres + ", Difficulty: " + diff + "\r\n\n";

            stream.WriteLine(header);

        }

        OpenConnection();

        byte[] test = {8};
        print(test);
        try
        {
            _SerialPort.Write(test, 0, 1);
        }
        catch (System.InvalidOperationException e) {  }

        handControlScript = GameObject.FindObjectOfType(typeof(HandController)) as HandController;

        randShape = GameObject.CreatePrimitive(PrimitiveType.Cube);
        randShape.layer = 8;
        randShape.name = "RandShape";
        randShape.renderer.enabled = false;
        Destroy(randShape.collider);
        Destroy(randShape.transform.rigidbody);

        gameObjcorners = CalcSearchCorners(gameObject);

        gameObject.renderer.material.shader = Shader.Find("Transparent/Diffuse");
        Color temp = gameObject.renderer.material.color;
        temp.a = .3f;
        gameObject.renderer.material.color = temp;

        // foreach (Vector3 printVec in gameObjcorners) print("Corner is: (" + printVec.x + ", " + printVec.y + ", " + printVec.z + ")"); // for debugging
    }
    void Awake ()
	{
		// Setup the UI
        GameObject stui = GameObject.Find("ScoreText");
        scoreText = stui.GetComponent<Text>();
        GameObject edui = GameObject.Find("FinalScoreText");
        finalScoreText = edui.GetComponent<Text>();
        GameObject kText = GameObject.Find("KinectText");
        kinectConnectedText = kText.GetComponent<Text>();
        GameObject oText = GameObject.Find("OculusText");
        oculusConnectedText = oText.GetComponent<Text>();
        GameObject ovrcanvas = GameObject.Find("UICanvas");
        startAnim = ovrcanvas.GetComponent<Animator>();
        score = 0;
        GameObject es = GameObject.Find("EventSystem");
        lookInput = es.GetComponent<LookInputModule>();


        //Disable Game over Button
        GameObject gameOverButton = GameObject.Find("RestartButton");
        Button b = gameOverButton.GetComponent<Button>();
        gameOverButton.SetActive(false);

        //Setup Player
        platformController = GameObject.Find("PlatformController");
        testSpawner = platformController.GetComponent<TestSpawner>();
        player = GameObject.Find("FPSPreFab");
        infinitePlayerController = player.GetComponent<InfinitePlayerController>();
        playerHealth = player.GetComponent<PlayerHealthController>();

        //Setup Kinect
        bodyManagerComponent = bodyManager.GetComponent<BodySourceManager>();
        handManagerComponent = handController.GetComponent<HandGestureTrigger>();

        //Setup Oculus
        GameObject ovrCameraRig = GameObject.Find("OVRCameraRig");
        oculusOVRManager = ovrCameraRig.GetComponent<OVRManager>();

        problemSolverObject = GameObject.Find("ProblemSolver");

    }