예제 #1
0
        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
        }
예제 #2
0
    public void Start()
    {
        transformFollow = GetComponent <VRTK_TransformFollow>();

        if (menuState)
        {
            OpenMenu();
        }
        else
        {
            CloseMenu();
        }
    }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        //getting MS!!
        MS = GameObject.Find("MSLogger").GetComponent <MSLogger>().MS;


        // if the MS is MS1
        if (MS == MovementSystem.MS1)
        {
            // getting the left hand and supernova game objects(supernova directly gets the transform follow component)
            superNovaLeftObject  = GameObject.FindGameObjectWithTag("SuperNovaLeft");
            superNovaRightObject = GameObject.FindGameObjectWithTag("SuperNovaRight");

            superNovaRightObject.SetActive(false);
            Debug.Log("This is the left hand: " + leftHand);

            // getting tracked object components
            trackedLeftHand  = leftHand.GetComponent <SteamVR_TrackedObject>();
            trackedRightHand = rightHand.GetComponent <SteamVR_TrackedObject>();

#if ALT
            leftHandFollow         = leftHand.GetComponent <VRTK_TransformFollow>();
            rightHandFollow        = rightHand.GetComponent <VRTK_TransformFollow>();
            leftHandFollow.enabled = false;
#endif
        }
        // If the MS is MS2
        else if (MS == MovementSystem.MS2)
        {
            // getting tracked object components
            trackedLeftHand  = leftHand.GetComponent <SteamVR_TrackedObject>();
            trackedRightHand = GetComponent <SteamVR_TrackedObject>();

            // getting the models for the  controllers.
            leftModel  = leftHand.transform.GetChild(0).gameObject;
            rightModel = transform.GetChild(0).gameObject;

            //setting up left model
            leftRender = leftModel.GetComponent <SteamVR_RenderModel>();

            // getting the VRTK_TransformFollow components
            leftFollow  = leftHand.GetComponent <VRTK_TransformFollow>();
            rightFollow = GetComponent <VRTK_TransformFollow>();

            // getting cameraRig and childing the right hand.
            cameraRig = transform.parent.gameObject;
            ChildToObject(this.gameObject, false, leftHand);
        }
    }
 private void PerformGrab()
 {
     if (grabOwner != 0)
     {
         PhotonView parentpv = PhotonView.Find(grabParent);
         if (parentpv != null)
         {
             Transform newParent = parentpv.transform;
             if (grabAttachPath != null)
             {
                 Transform attach = newParent.Find(grabAttachPath);
                 if (attach != null)
                 {
                     newParent = attach;
                 }
             }
             if (transformFollow == null)
             {
                 transformFollow = gameObject.AddComponent <VRTK_TransformFollow>();
             }
             transformFollow.gameObjectToFollow = newParent.gameObject;
             transformFollow.followsScale       = false;
             transformFollow.enabled            = true;
             if (rigidBody != null)
             {
                 isKinematic           = rigidBody.isKinematic;
                 rigidBody.isKinematic = true;
             }
         }
     }
     else
     {
         if (transformFollow != null)
         {
             transformFollow.enabled = false;
             if (rigidBody != null)
             {
                 rigidBody.isKinematic = isKinematic;
             }
         }
     }
 }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        audioSourceGameObject = GameObject.Find("RS3D_AudioSource");

        //if MS1 Alt
#if ALT
        nearOriginScript = rightHandController.GetComponent <NearOrigin>();

        VRTK_TransformFollow[] theScripts = GetComponents <VRTK_TransformFollow>();

        audioFollowLeft  = theScripts[0];
        audioFollowRight = theScripts[1];
#endif

        audioSource = audioSourceGameObject.GetComponent <RealSpace3D_AudioSource>();

        audioListener = GameObject.FindGameObjectWithTag("Ears");

        // getting densData
        densData = GetComponent <DataReader>().densData;
    }
        protected virtual void FixOculus()
        {
#if VRTK_DEFINE_SDK_OCULUS
            string     oculusPath = "[VRTK_SDKManager]/[VRTK_SDKSetups]/Oculus";
            GameObject oculusSDK  = GameObject.Find(oculusPath);

            if (oculusSDK == null || oculusSDK.GetComponentInChildren <OVRManager>() != null)
            {
                Debug.Log("No Oculus Repaired Required");
                return;
            }

            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 = null;
            GameObject ovrCameraRigToInstantiate = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Oculus/VR/Prefabs/OVRCameraRig.prefab", typeof(GameObject));
            if (ovrCameraRigToInstantiate != null)
            {
                ovrCameraRig = Instantiate(ovrCameraRigToInstantiate) as GameObject;
            }
            if (ovrCameraRig != null)
            {
                ovrCameraRig.name = ovrCameraRig.name.Replace("(Clone)", "");
                ovrCameraRig.transform.SetParent(oculusSDK.transform);
                ovrCameraRig.SetActive(true);
                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");
                Debug.Log("Successfully repaired Oculus OVRCameraRig prefab");
            }

            GameObject ovrAvatar = null;
            GameObject ovrAvatarToInstantiate = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Oculus/Avatar/Content/Prefabs/LocalAvatar.prefab", typeof(GameObject));
            if (ovrAvatarToInstantiate != null)
            {
                ovrAvatar = Instantiate(ovrAvatarToInstantiate) as GameObject;
            }

            if (ovrAvatar == null)
            {
                //legacy location
                ovrAvatarToInstantiate = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/OvrAvatar/Content/Prefabs/LocalAvatar.prefab", typeof(GameObject));
                if (ovrAvatarToInstantiate != null)
                {
                    ovrAvatar = Instantiate(ovrAvatarToInstantiate) as GameObject;
                }
            }
            if (ovrAvatar != null)
            {
                OvrAvatar avatarScript = ovrAvatar.GetComponent <OvrAvatar>();
                avatarScript.StartWithControllers = true;
                ovrAvatar.name = ovrAvatar.name.Replace("(Clone)", "");
                ovrAvatar.transform.SetParent(oculusSDK.transform);
                ovrAvatar.SetActive(true);
                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
        }
예제 #7
0
 private void Start()
 {
     TransformFollow = MessageWindow.GetComponent <VRTK_TransformFollow>();
     ChangeActiveFollower(ActiveFollower);
     StartCoroutine(FindDevices());
 }