CMathRemap: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
Accepts an input value which is remapped from it's relationship with the internal min and max input values, to a correlating relationship with the internal min and max output values. | Accepts an input value which is remapped from it's relationship with the internal min and max input values, to a correlating relationship with the internal min and max output values. | ||
For example, here are values used to scale an input: | For example, here are values used to scale an input by 10: | ||
* Input min (m_flInMin) | * Input min (m_flInMin) - 0 | ||
* Input max (m_flInMax) | * Input max (m_flInMax) - 10 | ||
* Output min (m_flOut1) | * Output min (m_flOut1) - 0 | ||
* Output max (m_flOut2) | * Output max (m_flOut2) - 100 | ||
Sending an InValue of 5 will result in an OutValue of 50, an InValue of 10 will produce an OutValue of 100, etc. | Sending an InValue of 5 will result in an OutValue of 50, an InValue of 10 will produce an OutValue of 100, etc. Here is the full formula used in the code, flValue is the input value: | ||
<syntaxhighlight lang="c++"> | <syntaxhighlight lang="c++"> |
Latest revision as of 18:21, 10 July 2022
Overview[edit | edit source]
Accepts an input value which is remapped from it's relationship with the internal min and max input values, to a correlating relationship with the internal min and max output values.
For example, here are values used to scale an input by 10:
- Input min (m_flInMin) - 0
- Input max (m_flInMax) - 10
- Output min (m_flOut1) - 0
- Output max (m_flOut2) - 100
Sending an InValue of 5 will result in an OutValue of 50, an InValue of 10 will produce an OutValue of 100, etc. Here is the full formula used in the code, flValue is the input value:
float flRemappedValue = m_flOut1 + (((flValue - m_flInMin) * (m_flOut2 - m_flOut1)) / (m_flInMax - m_flInMin));
Source location : /game/server/logicentities.cpp
Linked Entity : math_remap
Class Structure[edit | edit source]
- CBaseEntity
- CServerOnlyEntity
- CLogicalEntity
- CMathRemap
- CLogicalEntity
- CServerOnlyEntity
Entity DataMaps[edit | edit source]
Name | Type | Description |
---|---|---|
InputDisable | ||
InputEnable | ||
InputValue | ||
m_OutValue | ||
m_bEnabled | ||
m_flInMax | ||
m_flInMin | ||
m_flOut1 | ||
m_flOut2 |