CMathRemap: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
* Output max - 100 | * Output max - 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.<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]''' |
Revision as of 18:10, 10 July 2022
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:
- Input min - 0
- Input max - 10
- Output min - 0
- Output max - 100
Sending an InValue of 5 will result in an OutValue of 50, an InValue of 10 will produce an OutValue of 100, etc.
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
- CBaseEntity
- CServerOnlyEntity
- CLogicalEntity
- CMathRemap
- CLogicalEntity
- CServerOnlyEntity
Entity DataMaps
Name | Type | Description |
---|---|---|
InputDisable | ||
InputEnable | ||
InputValue | ||
m_OutValue | ||
m_bEnabled | ||
m_flInMax | ||
m_flInMin | ||
m_flOut1 | ||
m_flOut2 |