Handle multiple material params

This commit is contained in:
luboslenco 2018-11-13 22:18:44 +01:00
parent a3436495b0
commit b424b058bb
3 changed files with 14 additions and 27 deletions

View file

@ -8,8 +8,7 @@ class SetMaterialImageParamNode extends LogicNode {
static var registered = false;
static var mat:MaterialData = null;
static var node = "";
static var image:kha.Image = null;
static var map = new Map<String, kha.Image>();
public function new(tree:LogicTree) {
super(tree);
@ -21,21 +20,16 @@ class SetMaterialImageParamNode extends LogicNode {
override function run(from:Int) {
mat = inputs[1].get();
node = inputs[2].get();
if (mat == null || node == null) return;
if (mat == null) return;
var name = inputs[3].get();
iron.data.Data.getImage(name, function(img:kha.Image) {
image = img;
iron.data.Data.getImage(inputs[3].get(), function(image:kha.Image) {
map.set(inputs[2].get(), image);
});
runOutput(0);
}
static function textureLink(object:Object, mat:MaterialData, link:String):kha.Image {
if (link == node) {
return image;
}
return null;
return map.get(link);
}
}

View file

@ -8,6 +8,8 @@ class SetMaterialRgbParamNode extends LogicNode {
static var registered = false;
static var mat:MaterialData = null;
static var map = new Map<String, Vec4>();
static var node = "";
static var col:Vec4 = null;
@ -21,16 +23,12 @@ class SetMaterialRgbParamNode extends LogicNode {
override function run(from:Int) {
mat = inputs[1].get();
node = inputs[2].get();
col = inputs[3].get();
if (mat == null) return;
map.set(inputs[2].get(), inputs[3].get());
runOutput(0);
}
static function vec3Link(object:Object, mat:MaterialData, link:String):iron.math.Vec4 {
if (link == node) {
return col;
}
return null;
return map.get(link);
}
}

View file

@ -8,8 +8,7 @@ class SetMaterialValueParamNode extends LogicNode {
static var registered = false;
static var mat:MaterialData = null;
static var node = "";
static var value:Null<kha.FastFloat> = null;
static var map = new Map<String, Null<kha.FastFloat>>();
public function new(tree:LogicTree) {
super(tree);
@ -21,16 +20,12 @@ class SetMaterialValueParamNode extends LogicNode {
override function run(from:Int) {
mat = inputs[1].get();
node = inputs[2].get();
value = inputs[3].get();
if (mat == null) return;
map.set(inputs[2].get(), inputs[3].get()); // Node name, value
runOutput(0);
}
static function floatLink(object:Object, mat:MaterialData, link:String):Null<kha.FastFloat> {
if (link == node) {
return value;
}
return null;
return map.get(link);
}
}