Пример #1
0
 public OpenCloseStateBuilder(FeatureStateActiveMode featureStateActiveMode,
                              FingerFeature fingerFeature)
 {
     _mode          = featureStateActiveMode;
     _fingerFeature = fingerFeature;
     _states        = FingerFeatureProperties.FeatureDescriptions[_fingerFeature].FeatureStates;
 }
Пример #2
0
        protected virtual void Update()
        {
            if (!_initialized)
            {
                return;
            }

            FingerFeature feature  = _featureConfig.Feature;
            bool          isActive = false;

            if (_fingerFeatureState.GetCurrentState(_handFinger, feature,
                                                    out string currentState))
            {
                float?featureVal = _fingerFeatureState.GetFeatureValue(_handFinger, feature);
                isActive = _fingerFeatureState.IsStateActive(_handFinger, feature, _featureConfig.Mode, _featureConfig.State);
                string featureValStr = featureVal.HasValue ? featureVal.Value.ToString("F2") : "--";
                _targetText.text = $"{_handFinger} {feature}" + $"{currentState} ({featureValStr})";
            }
            else
            {
                _targetText.text = $"{_handFinger} {feature}\n";
            }

            if (isActive != _lastActiveValue)
            {
                _material.color  = isActive ? _activeColor : _normalColor;
                _lastActiveValue = isActive;
            }
        }
Пример #3
0
        /// <summary>
        /// Returns the current value of the feature. If the finger joints are not populated with
        /// valid data (for instance, due to a disconnected hand), the method will return NaN.
        /// </summary>
        public float?GetFeatureValue(HandFinger finger, FingerFeature fingerFeature)
        {
            if (!IsDataValid())
            {
                return(null);
            }

            return(_fingerShapes.GetValue(finger, fingerFeature, Hand));
        }
Пример #4
0
 public bool GetCurrentState(HandFinger finger, FingerFeature fingerFeature, out string currentState)
 {
     if (!IsDataValid())
     {
         currentState = default;
         return(false);
     }
     else
     {
         currentState = GetCurrentFingerFeatureState(finger, fingerFeature);
         return(currentState != default);
     }
 }
Пример #5
0
        public bool IsStateActive(HandFinger finger, FingerFeature feature, FeatureStateActiveMode mode, string stateId)
        {
            var currentState = GetCurrentFingerFeatureState(finger, feature);

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

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

            default:
                return(false);
            }
        }
Пример #6
0
        public virtual float GetValue(HandFinger finger, FingerFeature feature, IHand hand)
        {
            switch (feature)
            {
            case FingerFeature.Curl:
                return(GetCurlValue(finger, hand));

            case FingerFeature.Flexion:
                return(GetFlexionValue(finger, hand));

            case FingerFeature.Abduction:
                return(GetAbductionValue(finger, hand));

            case FingerFeature.Opposition:
                return(GetOppositionValue(finger, hand));

            default:
                return(0.0f);
            }
        }
Пример #7
0
 private string GetCurrentFingerFeatureState(HandFinger finger, FingerFeature fingerFeature)
 {
     return(_state.GetStateProvider(finger).GetCurrentFeatureState(fingerFeature));
 }