Beispiel #1
0
 protected SteamVrControllerComponent FindController(uint sensorId)
 {
     foreach (SteamVrControllerComponent controller in controllers)
     {
         if (controller != null && controller.trackerId == sensorId)
         {
             return(controller);
         }
     }
     if (SteamVrControllerComponent.IsLeftController(sensorId))
     {
         SteamVRHand leftHand = humanoid.leftHandTarget.steamVR;
         if (leftHand != null && leftHand.steamVrController != null)
         {
             leftHand.steamVrController.trackerId = (int)sensorId;
             // leftHand Controller was not in controller list yet
             controllers.Add(leftHand.steamVrController);
             return(leftHand.steamVrController);
         }
     }
     else
     if (SteamVrControllerComponent.IsRightController(sensorId))
     {
         SteamVRHand rightHand = humanoid.rightHandTarget.steamVR;
         if (rightHand != null && rightHand.steamVrController != null)
         {
             rightHand.steamVrController.trackerId = (int)sensorId;
             // leftHand Controller was not in controller list yet
             controllers.Add(rightHand.steamVrController);
             return(rightHand.steamVrController);
         }
     }
     return(null);
 }
Beispiel #2
0
            protected static void CheckControllerComponent(HandTarget handTarget)
            {
                if (handTarget.steamVR.sensorTransform == null)
                {
                    return;
                }

                SteamVrControllerComponent sensorComponent = handTarget.steamVR.sensorTransform.GetComponent <SteamVrControllerComponent>();

                if (sensorComponent == null)
                {
                    sensorComponent = handTarget.steamVR.sensorTransform.gameObject.AddComponent <SteamVrControllerComponent>();
                }
                sensorComponent.isLeft = handTarget.isLeft;
            }
Beispiel #3
0
        protected virtual void OnNewSensor(uint sensorId)
        {
            Passer.ETrackedDeviceClass deviceClass = Passer.OpenVR.System.GetTrackedDeviceClass(sensorId);
            switch (deviceClass)
            {
            case Passer.ETrackedDeviceClass.HMD:
                hmd = FindHmd(sensorId);
                if (hmd == null)
                {
                    hmd = SteamVrHmdComponent.NewHmd(humanoid, (int)sensorId);
                }
                break;

            case Passer.ETrackedDeviceClass.TrackingReference:
                SubTracker subTracker = FindLighthouse(sensorId);
                if (subTracker == null)
                {
                    subTracker = NewLighthouse(humanoid, sensorId);
                    subTrackers.Add(subTracker);
                }
                break;

            case Passer.ETrackedDeviceClass.Controller:
                SteamVrControllerComponent controller = FindController(sensorId);
                if (controller == null)
                {
                    controller = SteamVrControllerComponent.NewController(humanoid, (int)sensorId);
                    controllers.Add(controller);
                }
                break;

#if hVIVETRACKER
            case Passer.ETrackedDeviceClass.GenericTracker:
                ViveTrackerComponent viveTracker = FindViveTracker(sensorId);
                if (viveTracker == null)
                {
                    viveTracker = ViveTracker.NewViveTracker(humanoid, sensorId);
                    viveTrackers.Add(viveTracker);
                }
                break;
#endif
            default:
                break;
            }
        }
        protected override void CreateSensorTransform()
        {
            if (handTarget.isLeft)
            {
                CreateSensorTransform("Vive Controller", new Vector3(-0.14F, -0.04F, 0.08F), Quaternion.Euler(0, -30, -90));
            }
            else
            {
                CreateSensorTransform("Vive Controller", new Vector3(0.14F, -0.04F, 0.08F), Quaternion.Euler(0, 30, 90));
            }

            SteamVrControllerComponent steamVrController = sensorTransform.GetComponent <SteamVrControllerComponent>();

            if (steamVrController == null)
            {
                steamVrController = sensorTransform.gameObject.AddComponent <SteamVrControllerComponent>();
            }
            steamVrController.isLeft = handTarget.isLeft;
        }
        public override void Start(HumanoidControl _humanoid, Transform targetTransform)
        {
            base.Start(_humanoid, targetTransform);
            tracker = handTarget.humanoid.steam;

            if (tracker == null || !tracker.enabled || !enabled)
            {
                return;
            }

            SetSensor2Target();
            CheckSensorTransform();
            ShowSensor(handTarget.humanoid.showRealObjects && target.showRealObjects);

            if (sensorTransform != null)
            {
                steamVrController = sensorTransform.GetComponent <SteamVrControllerComponent>();
                if (steamVrController != null)
                {
                    steamVrController.StartComponent(tracker.trackerTransform);
                }
            }
        }
        public static SteamVrControllerComponent NewController(HumanoidControl humanoid, int trackerId = -1)
        {
            GameObject trackerPrefab = Resources.Load(resourceName) as GameObject;
            GameObject trackerObject = (trackerPrefab == null) ? new GameObject(resourceName) : Instantiate(trackerPrefab);

            trackerObject.name = resourceName;

            SteamVrControllerComponent trackerComponent = trackerObject.GetComponent <SteamVrControllerComponent>();

            if (trackerComponent == null)
            {
                trackerComponent = trackerObject.AddComponent <SteamVrControllerComponent>();
            }

            if (trackerId != -1)
            {
                trackerComponent.trackerId = trackerId;
            }
            trackerObject.transform.parent = humanoid.steam.trackerTransform;

            trackerComponent.StartComponent(humanoid.steam.trackerTransform);

            return(trackerComponent);
        }
Beispiel #7
0
            //SerializedProperty controllerTypeProp;

            private void OnEnable()
            {
                controllerComponent = (SteamVrControllerComponent)target;

                //controllerTypeProp = serializedObject.FindProperty("controllerType");
            }