Example #1
0
        public Pose PoseFromWrist(HandJointId jointid)
        {
            Pose pose = _posesFromWrist[(int)jointid];

            UpdateWristJoint(jointid, ref pose);
            return(pose);
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            DrawPropertiesExcluding(serializedObject);
            serializedObject.ApplyModifiedProperties();

            HandVisual visual = (HandVisual)target;

            InitializeSkeleton(visual);

            if (Hand == null)
            {
                return;
            }

            if (GUILayout.Button("Auto Map Joints"))
            {
                AutoMapJoints(visual);
                EditorUtility.SetDirty(visual);
                EditorSceneManager.MarkSceneDirty(visual.gameObject.scene);
            }

            EditorGUILayout.LabelField("Joints", EditorStyles.boldLabel);
            HandJointId start = HandJointId.HandStart;
            HandJointId end   = HandJointId.HandEnd;

            for (int i = (int)start; i < (int)end; ++i)
            {
                string jointName = HandJointLabelFromJointId((HandJointId)i);
                visual.Joints[i] = (Transform)EditorGUILayout.ObjectField(jointName,
                                                                          visual.Joints[i], typeof(Transform), true);
            }
        }
Example #3
0
 public void InjectAllJointDistanceActiveState(IHand handA, HandJointId jointIdA, IHand handB, HandJointId jointIdB)
 {
     InjectHandA(handA);
     InjectJointIdA(jointIdA);
     InjectHandB(handB);
     InjectJointIdB(jointIdB);
 }
Example #4
0
 public JointCollection(List <HandJointMap> joints)
 {
     _jointMaps = joints;
     for (int i = 0; i < FingersMetadata.HAND_JOINT_IDS.Length; i++)
     {
         HandJointId boneId = FingersMetadata.HAND_JOINT_IDS[i];
         _jointIndices[i] = joints.FindIndex(bone => bone.id == boneId);
     }
 }
Example #5
0
        /// <summary>
        /// Get the previous frame's pose
        /// </summary>
        /// <param name="joint">The joint for which to retrieve data</param>
        /// <param name="pose">The previous pose</param>
        /// <returns>True if data available</returns>
        public bool GetPrevJointPose(HandJointId joint, out Pose pose)
        {
            UpdateData();

            PoseData poseData = _poseDataCache[joint][PrevDataIndex];

            pose = poseData.Pose;
            return(poseData.IsValid);
        }
 public HandJointPoseMetaData(HandFinger finger,
                              HandJointId joint, int bufferLength)
 {
     Finger            = finger;
     JointId           = joint;
     Velocities        = new List <Vector3>();
     _previousPosition = null;
     _lastWritePos     = -1;
     _bufferLength     = bufferLength;
 }
Example #7
0
 private string FbxBoneNameFromHandJointId(HandVisual visual, HandJointId handJointId)
 {
     if (handJointId >= HandJointId.HandThumbTip && handJointId <= HandJointId.HandPinkyTip)
     {
         return(_fbxHandSidePrefix[(int)Hand.Handedness] + _fbxHandFingerNames[(int)handJointId - (int)HandJointId.HandThumbTip] + "_finger_tip_marker");
     }
     else
     {
         return(_fbxHandBonePrefix + _fbxHandSidePrefix[(int)Hand.Handedness] + _fbxHandBoneNames[(int)handJointId]);
     }
 }
Example #8
0
        public bool GetJointPoseFromWrist(HandJointId handJointId, out Pose pose)
        {
            pose = Pose.identity;
            if (!GetJointPosesFromWrist(out ReadOnlyHandJointPoses jointPosesFromWrist))
            {
                return(false);
            }

            pose = jointPosesFromWrist[(int)handJointId];
            return(true);
        }
Example #9
0
        public bool GetJointPoseLocal(HandJointId handJointId, out Pose pose)
        {
            pose = Pose.identity;
            if (!GetJointPosesLocal(out ReadOnlyHandJointPoses localJointPoses))
            {
                return(false);
            }

            pose = localJointPoses[(int)handJointId];
            return(true);
        }
Example #10
0
        public bool GetJointPose(HandJointId handJointId, out Pose pose)
        {
            pose = Pose.identity;

            if (!IsTrackedDataValid ||
                _jointPosesCache == null ||
                !GetRootPose(out Pose rootPose))
            {
                return(false);
            }
            CheckJointPosesCacheUpdate();
            pose = _jointPosesCache.WorldJointPose(handJointId, rootPose, Scale);
            return(true);
        }
Example #11
0
        private bool GetJointPose(HandJointId handJointId, out Pose pose)
        {
            pose = Pose.identity;
            if (!Hand.IsTrackedDataValid)
            {
                return(false);
            }

            if (!Hand.GetJointPose(handJointId, out pose))
            {
                return(false);
            }

            return(true);
        }
Example #12
0
        private void UpdateWristJoint(HandJointId jointid, ref Pose pose)
        {
            int jointIndex = (int)jointid;

            if ((_dirtyWristJoints & (1 << jointIndex)) != 0)// its dirty
            {
                if (jointid > HandJointId.HandWristRoot)
                {
                    UpdateWristJoint((HandJointId)_originalJoints[jointIndex].parent, ref pose);
                    PoseUtils.Multiply(pose, _localPoses[jointIndex], ref _posesFromWrist[jointIndex]);
                }
                _dirtyWristJoints = _dirtyWristJoints & ~(1 << jointIndex); //set clean
            }
            pose.CopyFrom(_posesFromWrist[jointIndex]);
        }
Example #13
0
        private HandPose TrackedPose()
        {
            if (!_handGrabInteractor.Hand.GetJointPosesLocal(out ReadOnlyHandJointPoses localJoints))
            {
                return(null);
            }
            HandPose result = new HandPose(_handGrabInteractor.Hand.Handedness);

            for (int i = 0; i < FingersMetadata.HAND_JOINT_IDS.Length; ++i)
            {
                HandJointId jointID = FingersMetadata.HAND_JOINT_IDS[i];
                result.JointRotations[i] = localJoints[jointID].rotation;
            }
            return(result);
        }
Example #14
0
        /// <summary>
        /// Get the delta rotation between the previous pose and current pose
        /// </summary>
        /// <param name="joint">The joint for which to retrieve data</param>
        /// <param name="delta">The rotation delta between poses in world space</param>
        /// <returns>True if data available</returns>
        public bool GetRotationDelta(HandJointId joint, out Quaternion delta)
        {
            UpdateData();

            PoseData prevPose = _poseDataCache[joint][PrevDataIndex];
            PoseData curPose  = _poseDataCache[joint][CurDataIndex];

            if (!prevPose.IsValid || !curPose.IsValid)
            {
                delta = Quaternion.identity;
                return(false);
            }

            delta = curPose.Pose.rotation * Quaternion.Inverse(prevPose.Pose.rotation);
            return(true);
        }
Example #15
0
        /// <summary>
        /// Get the delta position between the previous pose and current pose
        /// </summary>
        /// <param name="joint">The joint for which to retrieve data</param>
        /// <param name="delta">The position delta between poses in world space</param>
        /// <returns>True if data available</returns>
        public bool GetPositionDelta(HandJointId joint, out Vector3 delta)
        {
            UpdateData();

            PoseData prevPose = _poseDataCache[joint][PrevDataIndex];
            PoseData curPose  = _poseDataCache[joint][CurDataIndex];

            if (!prevPose.IsValid || !curPose.IsValid)
            {
                delta = Vector3.zero;
                return(false);
            }

            delta = curPose.Pose.position - prevPose.Pose.position;
            return(true);
        }
Example #16
0
        public Pose WorldJointPose(HandJointId jointid, Pose rootPose, float handScale)
        {
            int jointIndex = (int)jointid;

            if ((_dirtyWorldJoints & (1 << jointIndex)) != 0) //its dirty
            {
                Pose wristPose = Pose.identity;
                UpdateWristJoint(jointid, ref wristPose);
                PoseUtils.Multiply(_localPoses[0], wristPose, ref _worldPoses[jointIndex]);
                _worldPoses[jointIndex].position *= handScale;
                _worldPoses[jointIndex].Postmultiply(rootPose);

                _dirtyWorldJoints = _dirtyWorldJoints & ~(1 << jointIndex); //set clean
            }

            return(_worldPoses[jointIndex]);
        }
Example #17
0
 public JointFilter(HandJointId jointId)
 {
     _jointId = jointId;
     _filter  = OneEuroFilter.CreateQuaternion();
 }
Example #18
0
 public void InjectJointIdB(HandJointId jointIdB)
 {
     _jointIdB = jointIdB;
 }
Example #19
0
 public FingerPinchData(HandFinger fingerId)
 {
     _finger = fingerId;
     _tipId  = HandJointUtils.GetHandFingerTip(fingerId);
 }
Example #20
0
 public Pose LocalJointPose(HandJointId jointid)
 {
     return(_localPoses[(int)jointid]);
 }
Example #21
0
 public Transform GetTransformByHandJointId(HandJointId handJointId)
 {
     return(_jointTransforms[(int)handJointId]);
 }
Example #22
0
 public static int HandJointIdToIndex(HandJointId id)
 {
     return((int)id - (int)HandJointId.HandThumb0);
 }
Example #23
0
        // force aliased enum values to the more appropriate value
        private static string HandJointLabelFromJointId(HandJointId handJointId)
        {
            switch (handJointId)
            {
            case HandJointId.HandWristRoot:
                return("HandWristRoot");

            case HandJointId.HandForearmStub:
                return("HandForearmStub");

            case HandJointId.HandThumb0:
                return("HandThumb0");

            case HandJointId.HandThumb1:
                return("HandThumb1");

            case HandJointId.HandThumb2:
                return("HandThumb2");

            case HandJointId.HandThumb3:
                return("HandThumb3");

            case HandJointId.HandIndex1:
                return("HandIndex1");

            case HandJointId.HandIndex2:
                return("HandIndex2");

            case HandJointId.HandIndex3:
                return("HandIndex3");

            case HandJointId.HandMiddle1:
                return("HandMiddle1");

            case HandJointId.HandMiddle2:
                return("HandMiddle2");

            case HandJointId.HandMiddle3:
                return("HandMiddle3");

            case HandJointId.HandRing1:
                return("HandRing1");

            case HandJointId.HandRing2:
                return("HandRing2");

            case HandJointId.HandRing3:
                return("HandRing3");

            case HandJointId.HandPinky0:
                return("HandPinky0");

            case HandJointId.HandPinky1:
                return("HandPinky1");

            case HandJointId.HandPinky2:
                return("HandPinky2");

            case HandJointId.HandPinky3:
                return("HandPinky3");

            case HandJointId.HandThumbTip:
                return("HandThumbTip");

            case HandJointId.HandIndexTip:
                return("HandIndexTip");

            case HandJointId.HandMiddleTip:
                return("HandMiddleTip");

            case HandJointId.HandRingTip:
                return("HandRingTip");

            case HandJointId.HandPinkyTip:
                return("HandPinkyTip");

            default:
                return("HandUnknown");
            }
        }
Example #24
0
 public void InjectJointIdA(HandJointId jointIdA)
 {
     _jointIdA = jointIdA;
 }
 public void InjectJointToTest(HandJointId jointToTest)
 {
     _jointToTest = jointToTest;
 }
 public void InjectAllColliderContainsHandJointActiveState(IHand hand, Collider[] entryColliders,
                                                           Collider[] exitColliders, HandJointId jointToTest)
 {
     InjectHand(hand);
     InjectEntryColliders(entryColliders);
     InjectExitColliders(exitColliders);
     InjectJointToTest(jointToTest);
 }