Exemplo n.º 1
0
        protected virtual void UpdateVRNodeFingers()
        {
            if (IsTracked() && QuickVRManager._handTrackingMode == QuickVRManager.HandTrackingMode.Controllers)
            {
                //Update the nodes of the fingers
                foreach (QuickHumanFingers f in QuickHumanTrait.GetHumanFingers())
                {
                    List <QuickHumanBodyBones> fingerBones = QuickHumanTrait.GetBonesFromFinger(f, _isLeft);
                    for (int i = 0; i < QuickHumanTrait.NUM_BONES_PER_FINGER; i++)
                    {
                        QuickVRNode nFinger = QuickSingletonManager.GetInstance <QuickVRPlayArea>().GetVRNode(fingerBones[i]);

                        //The finger is tracked.
                        Transform t = _handAnimator[(int)f][i]; // .GetBoneFingerTransform(f, i);
                        nFinger.transform.position = t.position;
                        nFinger.transform.rotation = t.rotation;

                        //Correct the rotation
                        //if (IsLeft())
                        //{
                        //    nFinger.transform.Rotate(Vector3.right, 180, Space.Self);
                        //    nFinger.transform.Rotate(Vector3.up, -90, Space.Self);
                        //}
                        //else
                        //{
                        //    nFinger.transform.Rotate(Vector3.up, 90, Space.Self);
                        //}

                        nFinger.SetTracked(true);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected virtual void UpdateVRNodeTracked()
        {
            if (QuickVRManager._handTrackingMode == QuickVRManager.HandTrackingMode.Hands)
            {
                Transform tObject = _vrNodeHand.GetTrackedObject().transform;
                tObject.localPosition = Vector3.zero;
                tObject.localRotation = Quaternion.identity;

                bool isTrackedPos = OVRPlugin.GetNodePositionTracked(_ovrNodeHand);
                if (isTrackedPos)
                {
                    _vrNodeHand.transform.localPosition = OVRPlugin.GetNodePose(_ovrNodeHand, OVRPlugin.Step.Render).ToOVRPose().position;
                }

                bool isTrackedRot = OVRPlugin.GetNodeOrientationTracked(_ovrNodeHand);
                if (isTrackedRot)
                {
                    _vrNodeHand.transform.localRotation = OVRPlugin.GetNodePose(_ovrNodeHand, OVRPlugin.Step.Render).ToOVRPose().orientation;

                    if (IsLeft())
                    {
                        tObject.LookAt(tObject.transform.position + _vrNodeHand.transform.right, -_vrNodeHand.transform.up);
                    }
                    else
                    {
                        tObject.LookAt(tObject.transform.position - _vrNodeHand.transform.right, _vrNodeHand.transform.up);
                    }
                }

                //vrNode.SetTracked(isTrackedPos || isTrackedRot);
                _vrNodeHand.SetTracked(IsDataHighConfidence);

                UpdateVRNodeFingers();
            }
        }
Exemplo n.º 3
0
        protected virtual void UpdateVRNodeFingers()
        {
            if (IsInitialized())
            {
                if (!_physicsInitialized)
                {
                    CreatePhysics();
                    _physicsInitialized = true;
                }

                if (!_fingersDataInitialized)
                {
                    InitFingersData();
                    _fingersDataInitialized = true;
                }

                //Update the nodes of the fingers
                foreach (QuickHumanFingers f in QuickHumanTrait.GetHumanFingers())
                {
                    _handFingerConfidence[(int)f] = IsDataHighConfidence ? Mathf.Min(_handFingerConfidence[(int)f] + 1, NUM_FRAMES_CONFIDENCE) : 0;

                    for (int i = 0; i < NUM_BONES_PER_FINGER; i++)
                    {
                        int         boneID  = ((int)f) * NUM_BONES_PER_FINGER + i;
                        QuickVRNode nFinger = _vrNodeFingers[boneID]; //_playArea.GetVRNode(fingerBones[i]);

                        if (IsDataHighConfidenceFinger(f))
                        {
                            //The finger is tracked.
                            OVRSkeleton.BoneId ovrBoneID = _ovrFingerBones[boneID];
                            Transform          ovrBone   = GetOVRBoneTransform(ovrBoneID);
                            nFinger.transform.position = ovrBone.position;
                            nFinger.transform.rotation = ovrBone.rotation;

                            //Correct the rotation
                            if (IsLeft())
                            {
                                nFinger.transform.Rotate(Vector3.right, 180, Space.Self);
                                nFinger.transform.Rotate(Vector3.up, -90, Space.Self);
                            }
                            else
                            {
                                nFinger.transform.Rotate(Vector3.up, 90, Space.Self);
                            }


                            //nFinger.SetTracked(true);
                        }
                        else
                        {
                            //The finger is not tracked. Restore the last valid local rotation.
                            //nFinger.SetTracked(false);
                        }

                        nFinger.SetTracked(true);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected virtual void UpdateVRNode(HumanBodyBones role, Transform t)
        {
            QuickVRNode vrNode = _vrPlayArea.GetVRNode(role);

            vrNode.transform.position = t.position;
            vrNode.transform.rotation = t.rotation;
            vrNode.SetTracked(true);
        }