armory/Sources/armory/logicnode/MapRangeNode.hx
knowledgenude cc481ea15c fix-nodes
2020-11-19 10:38:46 -03:00

21 lines
527 B
Haxe

package armory.logicnode;
class MapRangeNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): kha.FastFloat {
var value = inputs[0].get();
var fromMin = inputs[1].get();
var fromMax = inputs[2].get();
var toMin = inputs[3].get();
var toMax = inputs[4].get();
if (value == null || fromMin == null || fromMax == null || toMin == null || toMax == null) return null;
return (value - fromMin) * (toMax - fromMax) / (toMin - fromMin) + fromMax;
}
}