public OpenCloseStateBuilder(FeatureStateActiveMode featureStateActiveMode, FingerFeature fingerFeature) { _mode = featureStateActiveMode; _fingerFeature = fingerFeature; _states = FingerFeatureProperties.FeatureDescriptions[_fingerFeature].FeatureStates; }
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; } }
/// <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)); }
public bool GetCurrentState(HandFinger finger, FingerFeature fingerFeature, out string currentState) { if (!IsDataValid()) { currentState = default; return(false); } else { currentState = GetCurrentFingerFeatureState(finger, fingerFeature); return(currentState != default); } }
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); } }
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); } }
private string GetCurrentFingerFeatureState(HandFinger finger, FingerFeature fingerFeature) { return(_state.GetStateProvider(finger).GetCurrentFeatureState(fingerFeature)); }