Пример #1
0
        protected virtual void Awake()
        {
            foreach (QuickHumanBodyBones role in QuickVRNode.GetTypeList())
            {
                CreateVRNode(role);
            }

            for (HumanBodyBones boneID = HumanBodyBones.LeftThumbProximal; boneID <= HumanBodyBones.RightLittleProximal; boneID++)
            {
                _fingerLength[boneID] = 0;
            }
        }
Пример #2
0
        public virtual void Calibrate()
        {
            //POSSIBLE TRACKER CONFIGURATIONS

            //1     ->  Head
            //3     ->  Head + Hands
            //4     ->  Head + Hands + Hips
            //6     ->  Head + Hands + Hips + Feet
            //10    ->  Head + Hands + Hips + Feet + Elbows + Knees

            _isHandsSwaped = false;
            List <InputDevice> bodyTrackers = GetBodyTrackers();
            int numTrackers = bodyTrackers.Count;

            QuickVRManager.Log("NUM BODY TRACKERS = " + numTrackers);

            //Try to assign the default nodes for Head and Hands
            QuickVRNode nodeHMD       = GetVRNode(HumanBodyBones.Head);
            QuickVRNode nodeLeftHand  = GetVRNode(HumanBodyBones.LeftHand);
            QuickVRNode nodeRightHand = GetVRNode(HumanBodyBones.RightHand);

            nodeHMD._inputDevice       = InputDevices.GetDeviceAtXRNode(XRNode.Head);
            nodeLeftHand._inputDevice  = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
            nodeRightHand._inputDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

            if (numTrackers == 1 || numTrackers == 3 || numTrackers == 4 || numTrackers == 6 || numTrackers == 10)
            {
                if (!nodeHMD._inputDevice.isValid)
                {
                    //The head will always be the upper body tracker
                    nodeHMD._inputDevice = bodyTrackers[0];
                }

                if (numTrackers == 3)
                {
                    //Head + Hands
                    if (!nodeLeftHand._inputDevice.isValid)
                    {
                        nodeLeftHand._inputDevice = bodyTrackers[1];
                    }
                    if (!nodeRightHand._inputDevice.isValid)
                    {
                        nodeRightHand._inputDevice = bodyTrackers[2];
                    }
                }
                //else if (numTrackers == 4)
                //{
                //    //Head + Hands + Hips
                //    //1) Remove the head node from the list
                //    bodyTrackers.RemoveAt(0);

                //    //2) The hips is the node that is "in the middle", i.e., the hands are in opposite sides of the hips node.
                //    InitHipsAndHands(bodyTrackers);
                //}
                //else if (numTrackers == 6)
                //{
                //    //Head + Hands + Hips + Feet
                //    //1) The Feet are the trackers with the lower y
                //    InitVRNode(HumanBodyBones.LeftFoot, bodyTrackers[5]);
                //    InitVRNode(HumanBodyBones.RightFoot, bodyTrackers[4]);

                //    //2) Remove the unnecessary nodes and proceed as in the previous case
                //    bodyTrackers.RemoveAt(5);
                //    bodyTrackers.RemoveAt(4);
                //    bodyTrackers.RemoveAt(0);

                //    InitHipsAndHands(bodyTrackers);
                //}

                //UpdateVRNodes();

                //IsVRNodesSwaped(HumanBodyBones.LeftFoot, HumanBodyBones.RightFoot);
            }
            else
            {
                QuickVRManager.LogWarning("BAD NUMBER OF BODY TRACKERS!!!");
            }

            UpdateVRNodes();
            _isHandsSwaped = IsVRNodesSwaped(HumanBodyBones.LeftHand, HumanBodyBones.RightHand);
            QuickVRManager.Log("handsSwaped = " + _isHandsSwaped);

            foreach (HumanBodyBones t in QuickVRNode.GetTypeList())
            {
                QuickVRNode n = GetVRNode(t);
                if (n)
                {
                    n.Calibrate();
                }
            }
        }