public void InjectAllTransformRecognizerActiveState(IHand hand, TransformFeatureConfigList transformFeatureList,
                                                     TransformConfig transformConfig)
 {
     InjectHand(hand);
     InjectTransformFeatureList(transformFeatureList);
     InjectTransformConfig(transformConfig);
 }
        public void RegisterNewConfig(TransformConfig transformConfig)
        {
            //Register time provider indirectly in case reference changes
            Func <float> getTime = () => _timeProvider();

            _transformFeatureStateCollection.RegisterConfig(transformConfig, _jointData, getTime);
        }
        /// <summary>
        /// Returns the current value of the feature. If the hand joints are not populated with
        /// valid data (for instance, due to a disconnected hand), the method will return null;
        /// </summary>
        public float?GetFeatureValue(TransformConfig config,
                                     TransformFeature transformFeature)
        {
            if (!IsHandDataValid())
            {
                return(null);
            }

            return(TransformFeatureValueProvider.GetValue(transformFeature,
                                                          _jointData, config));
        }
        public bool GetCurrentState(TransformConfig config, TransformFeature transformFeature,
                                    out string currentState)
        {
            if (!IsHandDataValid())
            {
                currentState = default;
                return(false);
            }

            currentState = GetCurrentFeatureState(config, transformFeature);
            return(currentState != default);
        }
        public bool IsStateActive(TransformConfig config, TransformFeature feature, FeatureStateActiveMode mode, string stateId)
        {
            var currentState = GetCurrentFeatureState(config, feature);

            switch (mode)
            {
            case FeatureStateActiveMode.Is:
                return(currentState == stateId);

            case FeatureStateActiveMode.IsNot:
                return(currentState != stateId);

            default:
                return(false);
            }
        }
        public void GetFeatureVectorAndWristPos(TransformConfig config,
                                                TransformFeature transformFeature, bool isHandVector, ref Vector3?featureVec,
                                                ref Vector3?wristPos)
        {
            featureVec = null;
            wristPos   = null;
            if (!IsHandDataValid())
            {
                return;
            }

            featureVec = isHandVector ?
                         TransformFeatureValueProvider.GetHandVectorForFeature(transformFeature,
                                                                               _jointData, in config) :
                         TransformFeatureValueProvider.GetTargetVectorForFeature(transformFeature,
                                                                                 _jointData, in config);
            wristPos = _jointData.WristPose.position;
        }
        public void RegisterConfig(TransformConfig transformConfig, TransformJointData jointData,
                                   Func <float> timeProvider)
        {
            bool containsKeyAlready = _idToTransformStateInfo.ContainsKey(transformConfig.InstanceId);

            Assert.IsFalse(containsKeyAlready,
                           "Trying to register multiple configs with the same id into " +
                           "TransformFeatureStateCollection.");

            var featureStateProvider = new FeatureStateProvider <TransformFeature, string>
                                       // note that jointData and transformConfig are reference types (classes), because they can change
                                       // during run time
                                           ((feature) => TransformFeatureValueProvider.GetValue(feature, jointData, transformConfig),
                                           feature => (int)feature,
                                           timeProvider);
            TransformStateInfo newTransfState = new TransformStateInfo(transformConfig, featureStateProvider);

            featureStateProvider.InitializeThresholds(transformConfig.FeatureThresholds);
            _idToTransformStateInfo.Add(transformConfig.InstanceId, newTransfState);
        }
        public static float GetValue(TransformFeature transformFeature, TransformJointData transformJointData,
                                     TransformConfig transformConfig)
        {
            TransformProperties transformProps =
                new TransformProperties(transformJointData.CenterEyePose, transformJointData.WristPose,
                                        transformJointData.Handedness, transformJointData.TrackingSystemUp,
                                        transformJointData.TrackingSystemForward);

            switch (transformFeature)
            {
            case TransformFeature.WristDown:
                return(GetWristDownValue(in transformProps, in transformConfig));

            case TransformFeature.WristUp:
                return(GetWristUpValue(in transformProps, in transformConfig));

            case TransformFeature.PalmDown:
                return(GetPalmDownValue(in transformProps, in transformConfig));

            case TransformFeature.PalmUp:
                return(GetPalmUpValue(in transformProps, in transformConfig));

            case TransformFeature.PalmTowardsFace:
                return(GetPalmTowardsFaceValue(in transformProps, in transformConfig));

            case TransformFeature.PalmAwayFromFace:
                return(GetPalmAwayFromFaceValue(in transformProps, in transformConfig));

            case TransformFeature.FingersUp:
                return(GetFingersUpValue(in transformProps, in transformConfig));

            case TransformFeature.FingersDown:
                return(GetFingersDownValue(in transformProps, in transformConfig));

            case TransformFeature.PinchClear:
            default:
                return(GetPinchClearValue(in transformProps, in transformConfig));
            }
        }
 public void InjectTransformConfig(TransformConfig transformConfig)
 {
     _transformConfig = transformConfig;
 }
 public TransformStateInfo(TransformConfig transformConfig,
                           FeatureStateProvider <TransformFeature, string> stateProvider)
 {
     Config        = transformConfig;
     StateProvider = stateProvider;
 }
 private string GetCurrentFeatureState(TransformConfig config,
                                       TransformFeature feature)
 {
     return(_transformFeatureStateCollection.GetStateProvider(config).
            GetCurrentFeatureState(feature));
 }
 public void UnRegisterConfig(TransformConfig transformConfig)
 {
     _transformFeatureStateCollection.UnRegisterConfig(transformConfig);
 }
 public void SetConfig(int configId, TransformConfig config)
 {
     _idToTransformStateInfo[configId].Config = config;
 }
 public FeatureStateProvider <TransformFeature, string> GetStateProvider(
     TransformConfig transformConfig)
 {
     return(_idToTransformStateInfo[transformConfig.InstanceId].StateProvider);
 }
 public void UnRegisterConfig(TransformConfig transformConfig)
 {
     _idToTransformStateInfo.Remove(transformConfig.InstanceId);
 }