protected override void CreateSensorTransform()
        {
            CreateSensorTransform("SteamVR HMD", headTarget.head2eyes, Quaternion.identity);
            SteamVrHmdComponent steamVrHmd = sensorTransform.GetComponent <SteamVrHmdComponent>();

            if (steamVrHmd == null)
            {
                sensorTransform.gameObject.AddComponent <SteamVrHmdComponent>();
            }
        }
Exemple #2
0
            protected static void CheckHmdComponent(HeadTarget headTarget)
            {
                if (headTarget.steamVR.sensorTransform == null)
                {
                    return;
                }

                SteamVrHmdComponent sensorComponent = headTarget.steamVR.sensorTransform.GetComponent <SteamVrHmdComponent>();

                if (sensorComponent == null)
                {
                    headTarget.steamVR.sensorTransform.gameObject.AddComponent <SteamVrHmdComponent>();
                }
            }
Exemple #3
0
        protected SteamVrHmdComponent FindHmd(uint sensorId)
        {
            if (hmd != null && hmd.trackerId == sensorId)
            {
                return(hmd);
            }

            SteamVRHead steamVrHead = humanoid.headTarget.steamVR;

            if (steamVrHead.steamVrHmd != null)
            {
                steamVrHead.steamVrHmd.trackerId = (int)sensorId;
                hmd = steamVrHead.steamVrHmd;
                return(hmd);
            }
            return(null);
        }
Exemple #4
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;
            }
        }
        public override void Start(HumanoidControl _humanoid, Transform targetTransform)
        {
            base.Start(_humanoid, targetTransform);
            tracker = headTarget.humanoid.steam;

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

            SetSensor2Target();
            CheckSensorTransform();
            sensor2TargetPosition = -headTarget.head2eyes;

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

            trackerObject.name = resourceName;

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

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

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

            trackerComponent.StartComponent(humanoid.steam.trackerTransform);

            return(trackerComponent);
        }
Exemple #7
0
 private void OnEnable()
 {
     sensorComponent = (SteamVrHmdComponent)target;
 }