Exemplo n.º 1
0
        private void GameSceneLoaded()
        {
            StageDressing.Logger.Info($"GameSceneLoaded");

            TrackedDeviceManager.instance.LoadTrackedDevices();
            StageManager.instance.CreateGameInstances();

            if (this.trackedGameObjectBehavior == null)
            {
                this.trackedGameObjectBehavior = new GameObject(nameof(TrackedObjectBehavior)).AddComponent <TrackedObjectBehavior>();
            }
            this.trackedGameObjectBehavior.LoadTrackedInstances(gameScene: true);

            if (this.grabbableGameBehavior == null)
            {
                this.grabbableGameBehavior = new GameObject(nameof(GrabbableBehavior)).AddComponent <GrabbableBehavior>();
            }
            this.grabbableGameBehavior.LoadGrabbableInstances(gameScene: true);
        }
Exemplo n.º 2
0
        private void LateMenuSceneLoadedFresh(ScenesTransitionSetupDataSO obj)
        {
            StageDressing.Logger.Info($"LateMenuSceneLoadedFresh");

            TrackedDeviceManager.instance.LoadTrackedDevices();
            StageManager.instance.LoadPrefabs();
            StageManager.instance.RebuildMenuInstances();

            if (this.trackedMenuObjectBehavior == null)
            {
                this.trackedMenuObjectBehavior = new GameObject(nameof(TrackedObjectBehavior)).AddComponent <TrackedObjectBehavior>();
            }
            this.trackedMenuObjectBehavior.LoadTrackedInstances();

            if (this.grabbableMenuBehavior == null)
            {
                this.grabbableMenuBehavior = new GameObject(nameof(GrabbableBehavior)).AddComponent <GrabbableBehavior>();
            }
            this.grabbableMenuBehavior.LoadGrabbableInstances();

            // Debug logging of existing tracked devices
            //var trackedDevices = new List<InputDevice>();
            //InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.TrackedDevice, trackedDevices);
            //Logger.Info("########## Tracked Devices");
            //Logger.Info(string.Join("\r\n", trackedDevices.Select(t => $"{t.manufacturer} {t.name} {t.serialNumber} valid: {t.isValid} characteristics: {t.characteristics}")));

            //List<InputDevice> handControllers = new List<InputDevice>();
            //InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.Controller, handControllers);
            //Logger.Info("########## Controller Hand Devices");
            //Logger.Info(string.Join("\r\n", handControllers.Select(t => $"{t.manufacturer} {t.name} {t.serialNumber} valid: {t.isValid} characteristics: {t.characteristics}")));

            //List<InputDevice> leftControllers = new List<InputDevice>();
            //InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Left, leftControllers);
            //Logger.Info("########## Left Devices");
            //Logger.Info(string.Join("\r\n", leftControllers.Select(t => $"{t.manufacturer} {t.name} {t.serialNumber} valid: {t.isValid} characteristics: {t.characteristics}")));

            //List<InputDevice> rightControllers = new List<InputDevice>();
            //InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.Right, rightControllers);
            //Logger.Info("########## Right Devices");
            //Logger.Info(string.Join("\r\n", rightControllers.Select(t => $"{t.manufacturer} {t.name} {t.serialNumber} valid: {t.isValid} characteristics: {t.characteristics}")));
        }
Exemplo n.º 3
0
        private void Update()
        {
            // Track all instances that have been calibrated and hasn't been grabbed
            foreach (var instance in trackedInstances.Where(i => i.IsCalibrated && !i.IsGrabbed))
            {
                var newInstancePose = TrackedDeviceManager.instance.GetTrackedObjectPoseBySerial(instance.CalibratedTrackerSerial, instance.CalibratedPose, instance.CalibratedTrackerPose);
                if (newInstancePose == null)
                {
                    continue;
                }

                instance.Pose = newInstancePose.Value;
                instance.Instance.transform.position = newInstancePose.Value.position;
                instance.Instance.transform.rotation = newInstancePose.Value.rotation;

                if (instance.GrabbableInGame || instance.GrabbableInMenu)
                {
                    // Also calculate new grabbable bounds in case it is grabbed
                    instance.ExpandedBounds = GrabbableBehavior.CalculateExpandedBounds(instance.Instance);
                }
            }
        }