void UpdateRotation(float value) { var a = BasicMath.Lerp(_rotationAngle0, _rotationAngle1, value); var r = Quaternion.AngleAxis(a, RotationAxis); if (_addToOriginal) { r = _originalRotation * r; } _targetTransform.localRotation = r; }
void UpdateScale(float value) { var a = BasicMath.Lerp(_scaleAmount0, _scaleAmount1, value); var s = ScaleVector * a; if (_addToOriginal) { s += _originalScale; } _targetTransform.localScale = s; }
void UpdatePosition(float value) { var a = BasicMath.Lerp(_translationAmount0, _translationAmount1, value); var p = TranslationVector * a; if (_addToOriginal) { p += _originalPosition; } _targetTransform.localPosition = p; }
void DoKnobUpdate(float inputValue) { const float threshold = 0.5f; if (_eventType == EventType.Value) { // update the target value for the interpolator _value.targetValue = BasicMath.Lerp(_outputValue0, _outputValue1, inputValue); // invoke the event in direct mode if (!_interpolator.enabled) { _valueEvent.Invoke(_value.Step()); } } else if (_lastInputValue < threshold && inputValue >= threshold) { if (_eventType == EventType.Trigger) { _triggerEvent.Invoke(); } else // EventType.Toggle { _toggleState ^= true; if (_toggleState) { _toggleOnEvent.Invoke(); } else { _toggleOffEvent.Invoke(); } } } _lastInputValue = inputValue; }
void InvokeValueEvent(float p) { switch (_outputType) { case OutputType.Bool: _boolEvent.Invoke(p > _threshold); break; case OutputType.Int: var i = BasicMath.Lerp(_intOutput0, _intOutput1, p); _intEvent.Invoke((int)i); break; case OutputType.Float: var f = BasicMath.Lerp(_floatOutput0, _floatOutput1, p); _floatEvent.Invoke(f); break; case OutputType.Vector3: var v = BasicMath.Lerp(_vector3Output0, _vector3Output1, p); _vector3Event.Invoke(v); break; } }
void InvokeEvent(float p) { var f = BasicMath.Lerp(_value0, _value1, p); _valueEvent.Invoke(f); }
float CalculateTargetValue(float knobValue) { var p = _inputCurve.Evaluate(knobValue); return(BasicMath.Lerp(_outputValue0, _outputValue1, p)); }
float MixValues() { return(BasicMath.Lerp(_input1Value, _input2Value, _parameter)); }