public override void Setup()
    {
        DeviceTestManager TestManager = GameObject.FindGameObjectWithTag("Facilitator").GetComponent <DeviceTestManager>();

        if ((DeviceUnderTest.characteristics & InputDeviceCharacteristics.HeadMounted) == 0)
        {
            // Set up visualizer
            m_Visualizer = Object.Instantiate(TestManager.TrackedDeviceVisualizerRotationPrefab);
            m_Visualizer.transform.SetParent(TestManager.XRRig.transform);
            TrackedDevice Device = m_Visualizer.GetComponent <TrackedDevice>();
            Device.device        = DeviceUnderTest;
            Device.rotationUsage = FeatureUsageUnderTest.As <Quaternion>();

            m_Visualizer.transform.localPosition = Vector3.forward;

            Vector3 trash;
            if (DeviceUnderTest.TryGetFeatureValue(CommonUsages.devicePosition, out trash))
            {
                Device.positionUsage = CommonUsages.devicePosition;
            }
            else if (DeviceUnderTest.TryGetFeatureValue(CommonUsages.colorCameraPosition, out trash))
            {
                Device.positionUsage = CommonUsages.colorCameraPosition;
            }
        }
        else
        {
            m_TextOnFace = TestManager.rotationTextOnFace;
            m_TextOnFace.SetDrivingUsage(DeviceUnderTest, FeatureUsageUnderTest.As <Quaternion>());
        }
    }
コード例 #2
0
        // Use this for initialization
        void Start()
        {
            _trackingToUse = trackingToUse == EUsableTracking.Controller ? ETrackedDeviceClass.Controller : ETrackedDeviceClass.GenericTracker;

            trackerTransforms = new Transform[3];
            trackerTransforms[(int)ERole.HMD]       = HMD;
            trackerTransforms[(int)ERole.LeftHand]  = leftTracker;
            trackerTransforms[(int)ERole.RightHand] = rightTracker;

            int num = System.Enum.GetNames(typeof(ERole)).Length;

            devices = new TrackedDevice[num];

            for (int i = 0; i < num; i++)
            {
                devices[i]         = new TrackedDevice();
                devices[i].index   = new int();
                devices[i].index   = (int)EIndex.None;
                devices[i].isValid = new bool();
                devices[i].isValid = false;

                GetIndex(i);
            }

            bool _useTrackers = trackingToUse == TrackingManager.EUsableTracking.GenericTracker;

            if (_trackingValues.AreArmsSwitched)
            {
                SwitchArms(false);
            }
        }
コード例 #3
0
 public void OnEnable()
 {
     overlay = new Overlay(Key + gameObject.GetInstanceID(), gameObject.name)
     {
         OverlayTexture = OverlayTexture,
         Alpha          = Alpha
     };
     overlay.TrackedDevice = TrackedDevice.GetController(TrackedDevice.ControllerRole.RightHand);
     overlay.Enable();
     overlay.Transform = gameObject.transform;
 }
コード例 #4
0
    public override void Setup()
    {
        DeviceTestManager TestManager = GameObject.FindGameObjectWithTag("Facilitator").GetComponent <DeviceTestManager>();

        // Set up visualizer
        m_Visualizer = Object.Instantiate(TestManager.TrackedDeviceVisualizerPointerPrefab);
        m_Visualizer.transform.SetParent(TestManager.XRRig.transform);
        TrackedDevice Device = m_Visualizer.GetComponent <TrackedDevice>();

        Device.device = DeviceUnderTest;
        //Device.rotationUsage = FeatureUsageUnderTest.As<Quaternion>();

        m_Visualizer.transform.localPosition = Vector3.forward;

        Quaternion checkIfRotationIsPresent;

        if (DeviceUnderTest.TryGetFeatureValue(CommonUsages.deviceRotation, out checkIfRotationIsPresent))
        {
            Device.rotationUsage = CommonUsages.deviceRotation;
        }
        else if (DeviceUnderTest.TryGetFeatureValue(CommonUsages.colorCameraRotation, out checkIfRotationIsPresent))
        {
            Device.rotationUsage = CommonUsages.colorCameraRotation;
        }
        Vector3 checkIfPositionIsPresent;

        if (DeviceUnderTest.TryGetFeatureValue(CommonUsages.devicePosition, out checkIfPositionIsPresent))
        {
            Device.positionUsage = CommonUsages.devicePosition;
        }
        else if (DeviceUnderTest.TryGetFeatureValue(CommonUsages.colorCameraPosition, out checkIfPositionIsPresent))
        {
            Device.positionUsage = CommonUsages.colorCameraPosition;
        }

        // Set up bearings
        m_Bearings = GameObject.FindGameObjectWithTag("Facilitator").GetComponent <DeviceTestManager>().bearings;
        if (m_Bearings != null)
        {
            m_Bearings.EnableAngularAcceleration(DeviceUnderTest, FeatureUsageUnderTest.As <Vector3>());
        }

        m_Graph = GameObject.FindGameObjectWithTag("Facilitator").GetComponent <DeviceTestManager>().graphVector3;
        if (m_Graph != null)
        {
            m_Graph.gameObject.SetActive(true);
            m_Graph.SetActive(DeviceUnderTest, FeatureUsageUnderTest.As <Vector3>(), 10f);
        }
    }
    public override void Setup()
    {
        DeviceTestManager TestManager = GameObject.FindGameObjectWithTag("Facilitator").GetComponent <DeviceTestManager>();

        if ((DeviceUnderTest.characteristics & InputDeviceCharacteristics.HeadMounted) == 0)
        {
            // Set up visualizer
            m_Visualizer = Object.Instantiate(TestManager.TrackedDeviceVisualizerPositionPrefab);
            m_Visualizer.transform.SetParent(TestManager.XRRig.transform);
            TrackedDevice Device = m_Visualizer.GetComponent <TrackedDevice>();
            Device.device        = DeviceUnderTest;
            Device.positionUsage = FeatureUsageUnderTest.As <Vector3>();
        }

        // Show coordinates
        TestManager.bearings.EnableCoordinates = true;
    }
コード例 #6
0
        // Use this for initialization
        void Start()
        {
            pTrackingToUse = trackingToUse == EUsableTracking.Controller ? ETrackedDeviceClass.Controller : ETrackedDeviceClass.GenericTracker;

            trackerTransforms = new Transform[3];
            trackerTransforms[(int)ERole.HMD]       = HMD;
            trackerTransforms[(int)ERole.LeftHand]  = leftTracker;
            trackerTransforms[(int)ERole.RightHand] = rightTracker;

            int num = System.Enum.GetNames(typeof(ERole)).Length;

            devices = new TrackedDevice[num];

            for (int i = 0; i < num; i++)
            {
                devices[i]         = new TrackedDevice();
                devices[i].index   = new int();
                devices[i].index   = (int)EIndex.None;
                devices[i].isValid = new bool();
                devices[i].isValid = false;

                GetIndex(i);
            }

            bool _useTrackers = trackingToUse == TrackingManager.EUsableTracking.GenericTracker;

            // Rotate the offsets of the TrackerOffset when the user is using controllers
            Transform[] trackers = new Transform[2];
            trackers[0] = leftTracker;
            trackers[1] = rightTracker;
            if (!_useTrackers)
            {
                foreach (var trackerOffset in trackers)
                {
                    trackerOffset.localRotation = Quaternion.Euler(90, -180, 0);
                    var currentLocalPos = trackerOffset.localPosition;
                    trackerOffset.localPosition = new Vector3(-currentLocalPos.x, -currentLocalPos.y, -currentLocalPos.z);
                }
            }

            if (_trackingValues.AreArmsSwitched)
            {
                SwitchArms(false);
            }
        }
コード例 #7
0
        void SetDevice(InputDevice device, bool add = true)
        {
            uiController?.SetDevice(device, add);

            switch (device)
            {
            case Mouse mouse:
                m_mouse = add ? mouse : null;
                return;

            case Keyboard keyboard:
                m_keyboard = add ? keyboard : null;
                return;

            case Touchscreen screen:
                m_screen = add ? screen : null;
                return;

            case Gamepad pad:
                m_gamepad = add ? pad : null;
                return;

            case Gyroscope gyroscope:
                m_gyroscpe = add ? gyroscope : null;
                return;

            case TrackedDevice tracker:
                m_tracker = add ? tracker : null;
                return;

#if URS_USE_AR_SUBSYSTEMS
            case HandheldARInputDevice handheld:
                m_handheld = handheld;
                return;
#endif
            }
        }
コード例 #8
0
        public bool Connect(IMoCapClient_ConnectionInfo connectionInfo)
        {
            connected = XRDevice.isPresent;

            if (connected)
            {
                try
                {
                    system = OpenVR.System;
                    if (system == null)
                    {
                        connected = false;
                        Debug.LogWarning("Could not find OpenVR System instance.");
                    }

                    compositor = OpenVR.Compositor;
                    if ((system != null) && (compositor == null))
                    {
                        connected = false;
                        Debug.LogWarning("Could not find OpenVR Compositor instance.");
                    }
                }
                catch (DllNotFoundException)
                {
                    // well, can't do anything about this
                    connected = false;
                }
            }

            if (connected)
            {
                // query refresh rate
                updateRate = XRDevice.refreshRate;
                if (updateRate == 0)
                {
                    updateRate = 60;
                }                                                         // fallback

                // allocate structures
                state     = new VRControllerState_t();
                poses     = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount];
                gamePoses = new TrackedDevicePose_t[0];

                // find HMDs, trackers and controllers
                trackedDevices.Clear();
                int controllerCount = 0;
                int trackerCount    = 0;
                int hmdCount        = 0;
                int inputDeviceIdx  = 0;
                for (int index = 0; index < OpenVR.k_unMaxTrackedDeviceCount; index++)
                {
                    ETrackedDeviceClass deviceClass   = system.GetTrackedDeviceClass((uint)index);
                    TrackedDevice       trackedDevice = null;
                    if (deviceClass == ETrackedDeviceClass.Controller)
                    {
                        controllerCount++;
                        trackedDevice = new TrackedDevice("ViveController" + controllerCount);

                        // controller has 12 input channels and 1 output
                        Device dev = new Device(scene, trackedDevice.name, inputDeviceIdx);
                        dev.channels         = new Channel[13];
                        dev.channels[0]      = new Channel(dev, "button1");                      // fire
                        dev.channels[1]      = new Channel(dev, "button2");                      // menu
                        dev.channels[2]      = new Channel(dev, "button3");                      // grip
                        dev.channels[3]      = new Channel(dev, "button4");                      // touchpad press
                        dev.channels[4]      = new Channel(dev, "axis1");                        // touchpad + press
                        dev.channels[5]      = new Channel(dev, "axis2");
                        dev.channels[6]      = new Channel(dev, "axis1raw");                     // touchpad touch
                        dev.channels[7]      = new Channel(dev, "axis2raw");
                        dev.channels[8]      = new Channel(dev, "right");                        // touchpad as buttons
                        dev.channels[9]      = new Channel(dev, "left");
                        dev.channels[10]     = new Channel(dev, "up");
                        dev.channels[11]     = new Channel(dev, "down");
                        dev.channels[12]     = new Channel(dev, "rumble");                       // rumble output
                        trackedDevice.device = dev;
                    }
                    else if (deviceClass == ETrackedDeviceClass.GenericTracker)
                    {
                        trackerCount++;
                        trackedDevice = new TrackedDevice("ViveTracker" + trackerCount);

                        // tracker has 4 input channels and 1 output channel
                        Device dev = new Device(scene, trackedDevice.name, inputDeviceIdx);
                        dev.channels         = new Channel[5];
                        dev.channels[0]      = new Channel(dev, "input1");                    // pin 3: grip
                        dev.channels[1]      = new Channel(dev, "input2");                    // pin 4: trigger
                        dev.channels[2]      = new Channel(dev, "input3");                    // pin 5: touchpad press
                        dev.channels[3]      = new Channel(dev, "input4");                    // pin 6: menu
                        dev.channels[4]      = new Channel(dev, "output1");                   // pin 1: rumble output
                        trackedDevice.device = dev;
                    }
                    else if (deviceClass == ETrackedDeviceClass.HMD)
                    {
                        hmdCount++;
                        trackedDevice = new TrackedDevice("ViveHMD" + hmdCount);
                    }

                    if (trackedDevice != null)
                    {
                        trackedDevice.controllerIdx = index;
                        trackedDevice.deviceClass   = deviceClass;
                        trackedDevices.Add(trackedDevice);

                        if (trackedDevice.device != null)
                        {
                            inputDeviceIdx++;
                        }
                    }
                }

                // construct scene description
                scene.actors.Clear();
                scene.devices.Clear();
                foreach (TrackedDevice td in trackedDevices)
                {
                    Actor actor = new Actor(scene, td.name);
                    actor.bones    = new Bone[1];
                    actor.bones[0] = new Bone(actor, "root", 0);
                    scene.actors.Add(actor);

                    // is this an input device, too?
                    if (td.device != null)
                    {
                        scene.devices.Add(td.device);
                    }
                }
            }
            return(connected);
        }
コード例 #9
0
 public static NoloDevice GetDevice(TrackedDevice trackedObject)
 {
     return(GetDevice(trackedObject.DeviceType));
 }