CMathRemap: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Overview == ... '''Source location : [https://github.com/sreechar/TF2-Source-Code/tree/master/tf2_src/game/server/logicentities.cpp /game/server/logicentities.cpp]''' '''...") |
No edit summary |
||
(17 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
.. | 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: | |||
<syntaxhighlight lang="c++"> | |||
float flRemappedValue = m_flOut1 + (((flValue - m_flInMin) * (m_flOut2 - m_flOut1)) / (m_flInMax - m_flInMin)); | |||
</syntaxhighlight> | |||
'''Source location : [https://github.com/sreechar/TF2-Source-Code/tree/master/tf2_src/game/server/logicentities.cpp /game/server/logicentities.cpp]''' | '''Source location : [https://github.com/sreechar/TF2-Source-Code/tree/master/tf2_src/game/server/logicentities.cpp /game/server/logicentities.cpp]''' | ||
Line 11: | Line 25: | ||
***'''[[CLogicalEntity]]''' | ***'''[[CLogicalEntity]]''' | ||
****'''CMathRemap''' | ****'''CMathRemap''' | ||
== Entity DataMaps == | |||
{| class="wikitable sortable mw-collapsible mw-collapsed" style="margin: 0 auto; width: 100%; padding: 0; | |||
|+CMathRemap | |||
! style="width: 50%; background-color: #303030; color: white" |Name | |||
! style="width: 15%; background-color: #303030; color: white" |Type | |||
! style="width: 35%; background-color: #303030; color: white" |Description | |||
|- | |||
| style="width: 50%;" |'''InputDisable''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''InputEnable''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''InputValue''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''m_OutValue''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''m_bEnabled''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''m_flInMax''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''m_flInMin''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''m_flOut1''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|- | |||
| style="width: 50%;" |'''m_flOut2''' | |||
| style="width: 15%;" | | |||
| style="width: 35%;" | | |||
|} |
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 |