forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
53
leenkx/Sources/leenkx/data/Config.hx
Normal file
53
leenkx/Sources/leenkx/data/Config.hx
Normal file
@ -0,0 +1,53 @@
|
||||
package leenkx.data;
|
||||
|
||||
class Config {
|
||||
|
||||
public static var raw: TConfig = null;
|
||||
public static var configLoaded = false;
|
||||
|
||||
public static function load(done: Void->Void) {
|
||||
try {
|
||||
iron.data.Data.getBlob("config.lnx", function(blob: kha.Blob) {
|
||||
configLoaded = true;
|
||||
raw = haxe.Json.parse(blob.toString());
|
||||
done();
|
||||
});
|
||||
}
|
||||
catch (e: Dynamic) { done(); }
|
||||
}
|
||||
|
||||
public static function save() {
|
||||
var path = iron.data.Data.dataPath + "config.lnx";
|
||||
var bytes = haxe.io.Bytes.ofString(haxe.Json.stringify(raw));
|
||||
#if kha_krom
|
||||
Krom.fileSaveBytes(path, bytes.getData());
|
||||
#elseif kha_kore
|
||||
sys.io.File.saveBytes(path, bytes);
|
||||
#end
|
||||
}
|
||||
|
||||
// public static function reset() {}
|
||||
}
|
||||
|
||||
typedef TConfig = {
|
||||
@:optional var debug_console: Null<Bool>;
|
||||
@:optional var window_mode: Null<Int>; // window, fullscreen
|
||||
@:optional var window_w: Null<Int>;
|
||||
@:optional var window_h: Null<Int>;
|
||||
@:optional var window_resizable: Null<Bool>;
|
||||
@:optional var window_maximizable: Null<Bool>;
|
||||
@:optional var window_minimizable: Null<Bool>;
|
||||
@:optional var window_vsync: Null<Bool>;
|
||||
@:optional var window_msaa: Null<Int>;
|
||||
@:optional var window_scale: Null<Float>;
|
||||
@:optional var rp_supersample: Null<Float>;
|
||||
@:optional var rp_shadowmap_cube: Null<Int>; // size
|
||||
@:optional var rp_shadowmap_cascade: Null<Int>; // size for single cascade
|
||||
@:optional var rp_ssgi: Null<Bool>;
|
||||
@:optional var rp_ssr: Null<Bool>;
|
||||
@:optional var rp_ssrefr: Null<Bool>;
|
||||
@:optional var rp_bloom: Null<Bool>;
|
||||
@:optional var rp_motionblur: Null<Bool>;
|
||||
@:optional var rp_gi: Null<Bool>; // voxelao
|
||||
@:optional var rp_dynres: Null<Bool>; // dynamic resolution scaling
|
||||
}
|
23
leenkx/Sources/leenkx/data/ConstData.hx
Normal file
23
leenkx/Sources/leenkx/data/ConstData.hx
Normal file
File diff suppressed because one or more lines are too long
1
leenkx/Sources/leenkx/import.hx
Normal file
1
leenkx/Sources/leenkx/import.hx
Normal file
@ -0,0 +1 @@
|
||||
import leenkx.system.Assert.*;
|
16
leenkx/Sources/leenkx/logicnode/ActionNameNode.hx
Normal file
16
leenkx/Sources/leenkx/logicnode/ActionNameNode.hx
Normal file
@ -0,0 +1,16 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ActionNameNode extends LogicNode {
|
||||
|
||||
public var value: String;
|
||||
|
||||
public function new(tree: LogicTree, value = "") {
|
||||
super(tree);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (inputs.length > 0) return inputs[0].get();
|
||||
return value;
|
||||
}
|
||||
}
|
10
leenkx/Sources/leenkx/logicnode/ActiveCameraNode.hx
Normal file
10
leenkx/Sources/leenkx/logicnode/ActiveCameraNode.hx
Normal file
@ -0,0 +1,10 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ActiveCameraNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic { return iron.Scene.active.camera; }
|
||||
}
|
10
leenkx/Sources/leenkx/logicnode/ActiveSceneNode.hx
Normal file
10
leenkx/Sources/leenkx/logicnode/ActiveSceneNode.hx
Normal file
@ -0,0 +1,10 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ActiveSceneNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic { return iron.Scene.active.raw.name; }
|
||||
}
|
33
leenkx/Sources/leenkx/logicnode/AddGroupNode.hx
Normal file
33
leenkx/Sources/leenkx/logicnode/AddGroupNode.hx
Normal file
@ -0,0 +1,33 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import kha.arrays.Float32Array;
|
||||
import iron.object.Object;
|
||||
|
||||
class AddGroupNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var groupName: String = inputs[1].get();
|
||||
var objects: Array<Object> = inputs[2].get();
|
||||
var raw = iron.Scene.active.raw;
|
||||
var object_names = [];
|
||||
|
||||
// Already exists
|
||||
for (g in raw.groups) {
|
||||
if (g.name == groupName) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(objects != null)
|
||||
for(o in objects)
|
||||
object_names.push(o.name);
|
||||
|
||||
raw.groups.push({ name: groupName, object_refs: object_names, instance_offset: new Float32Array(3)});
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
20
leenkx/Sources/leenkx/logicnode/AddObjectToGroupNode.hx
Normal file
20
leenkx/Sources/leenkx/logicnode/AddObjectToGroupNode.hx
Normal file
@ -0,0 +1,20 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
class AddObjectToGroupNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var groupName: String = inputs[1].get();
|
||||
var object: Object = inputs[2].get();
|
||||
|
||||
iron.Scene.active.getGroup(groupName).push(object);
|
||||
|
||||
runOutput(0);
|
||||
|
||||
}
|
||||
}
|
114
leenkx/Sources/leenkx/logicnode/AddPhysicsConstraintNode.hx
Normal file
114
leenkx/Sources/leenkx/logicnode/AddPhysicsConstraintNode.hx
Normal file
@ -0,0 +1,114 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
#if lnx_physics
|
||||
import leenkx.trait.physics.PhysicsConstraint;
|
||||
import leenkx.trait.physics.bullet.PhysicsConstraint.ConstraintType;
|
||||
#end
|
||||
|
||||
class AddPhysicsConstraintNode extends LogicNode {
|
||||
|
||||
public var property0: String;//Type
|
||||
public var object: Object;
|
||||
public var rb1: Object;
|
||||
public var rb2: Object;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var pivotObject: Object = inputs[1].get();
|
||||
rb1 = inputs[2].get();
|
||||
rb2 = inputs[3].get();
|
||||
|
||||
if (pivotObject == null || rb1 == null || rb2 == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
|
||||
var disableCollisions: Bool = inputs[4].get();
|
||||
var breakable: Bool = inputs[5].get();
|
||||
var breakingThreshold: Float = inputs[6].get();
|
||||
var type: ConstraintType = 0;
|
||||
|
||||
var con: PhysicsConstraint = pivotObject.getTrait(PhysicsConstraint);
|
||||
if (con == null) {
|
||||
switch (property0) {
|
||||
case "Fixed": type = Fixed;
|
||||
case "Point": type = Point;
|
||||
case "Hinge": type = Hinge;
|
||||
case "Slider": type = Slider;
|
||||
case "Piston": type = Piston;
|
||||
case "Generic Spring": type = Generic;
|
||||
}
|
||||
|
||||
if (!breakable) breakingThreshold = 0.0;
|
||||
|
||||
if (type != Generic) {
|
||||
|
||||
con = new PhysicsConstraint(rb1, rb2, type, disableCollisions, breakingThreshold);
|
||||
|
||||
switch (type) {
|
||||
case Hinge:
|
||||
var setLimit: Bool = inputs[7].get();
|
||||
var low: Float = inputs[8].get();
|
||||
var up: Float = inputs[9].get();
|
||||
con.setHingeConstraintLimits(setLimit, low, up);
|
||||
|
||||
case Slider:
|
||||
var setLimit: Bool = inputs[7].get();
|
||||
var low: Float = inputs[8].get();
|
||||
var up: Float = inputs[9].get();
|
||||
con.setSliderConstraintLimits(setLimit, low, up);
|
||||
|
||||
case Piston:
|
||||
var setLinLimit: Bool = inputs[7].get();
|
||||
var linLow: Float = inputs[8].get();
|
||||
var linUp: Float = inputs[9].get();
|
||||
var setAngLimit: Bool = inputs[10].get();
|
||||
var angLow: Float = inputs[11].get();
|
||||
var angUp: Float = inputs[12].get();
|
||||
con.setPistonConstraintLimits(setLinLimit, linLow, linUp, setAngLimit, angLow, angUp);
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
else {
|
||||
var spring: Bool = false;
|
||||
var prop: PhysicsConstraintNode;
|
||||
|
||||
for (inp in 7...inputs.length) {
|
||||
prop = inputs[inp].get();
|
||||
if (prop == null) continue;
|
||||
if (prop.isSpring) {
|
||||
spring = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (spring) {
|
||||
con = new PhysicsConstraint(rb1, rb2, GenericSpring, disableCollisions, breakingThreshold);
|
||||
}
|
||||
else {
|
||||
con = new PhysicsConstraint(rb1, rb2, Generic, disableCollisions, breakingThreshold);
|
||||
}
|
||||
|
||||
for (inp in 7...inputs.length) {
|
||||
prop = inputs[inp].get();
|
||||
if (prop == null) continue;
|
||||
|
||||
if (prop.isSpring) {
|
||||
con.setSpringParams(prop.isSpring, prop.value1, prop.value2, prop.axis, prop.isAngular);
|
||||
}
|
||||
else {
|
||||
con.setGenericConstraintLimits(true, prop.value1, prop.value2, prop.axis, prop.isAngular);
|
||||
}
|
||||
}
|
||||
}
|
||||
pivotObject.addTrait(con);
|
||||
}
|
||||
#end
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
100
leenkx/Sources/leenkx/logicnode/AddRigidBodyNode.hx
Normal file
100
leenkx/Sources/leenkx/logicnode/AddRigidBodyNode.hx
Normal file
@ -0,0 +1,100 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
#if lnx_physics
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
import leenkx.trait.physics.bullet.RigidBody.Shape;
|
||||
#end
|
||||
|
||||
|
||||
class AddRigidBodyNode extends LogicNode {
|
||||
|
||||
public var property0: String; //Shape
|
||||
public var property1: Bool; //Advanced
|
||||
public var object: Object;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
object = inputs[1].get();
|
||||
if (object == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
|
||||
var mass: Float = inputs[2].get();
|
||||
var active: Bool = inputs[3].get();
|
||||
var animated: Bool = inputs[4].get();
|
||||
var trigger: Bool = inputs[5].get();
|
||||
var friction: Float = inputs[6].get();
|
||||
var bounciness: Float = inputs[7].get();
|
||||
var ccd: Bool = inputs[8].get();
|
||||
|
||||
var margin: Bool = false;
|
||||
var marginLen: Float = 0.0;
|
||||
var linDamp: Float = 0.0;
|
||||
var angDamp: Float = 0.0;
|
||||
var angFriction: Float = 0.0;
|
||||
var useDeactiv: Bool = false;
|
||||
var linearVelThreshold: Float = 0.0;
|
||||
var angVelThreshold: Float = 0.0;
|
||||
var group: Int = 1;
|
||||
var mask: Int = 1;
|
||||
|
||||
var shape: Shape = 1;
|
||||
|
||||
if (property1) {
|
||||
margin = inputs[9].get();
|
||||
marginLen = inputs[10].get();
|
||||
linDamp = inputs[11].get();
|
||||
angDamp = inputs[12].get();
|
||||
angFriction = inputs[13].get();
|
||||
useDeactiv = inputs[14].get();
|
||||
linearVelThreshold = inputs[15].get();
|
||||
angVelThreshold = inputs[16].get();
|
||||
group = inputs[17].get();
|
||||
mask = inputs[18].get();
|
||||
}
|
||||
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
if ((group < 0) || (group > 32)) group = 1; //Limiting max groups to 32
|
||||
if ((mask < 0) || (mask > 32)) mask = 1; //Limiting max masks to 32
|
||||
if (rb == null) {
|
||||
switch (property0) {
|
||||
case "Box": shape = Box;
|
||||
case "Sphere": shape = Sphere;
|
||||
case "Capsule": shape = Capsule;
|
||||
case "Cone": shape = Cone;
|
||||
case "Cylinder": shape = Cylinder;
|
||||
case "Convex Hull": shape = ConvexHull;
|
||||
case "Mesh": shape = Mesh;
|
||||
}
|
||||
|
||||
rb = new RigidBody(shape, mass, friction, bounciness, group, mask);
|
||||
rb.animated = animated;
|
||||
rb.staticObj = !active;
|
||||
rb.isTriggerObject(trigger);
|
||||
|
||||
if (property1) {
|
||||
rb.linearDamping = linDamp;
|
||||
rb.angularDamping = angDamp;
|
||||
rb.angularFriction = angFriction;
|
||||
if (margin) rb.collisionMargin = marginLen;
|
||||
if (useDeactiv) {
|
||||
rb.setUpDeactivation(true, linearVelThreshold, angVelThreshold, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
object.addTrait(rb);
|
||||
}
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Object {
|
||||
return object;
|
||||
}
|
||||
}
|
79
leenkx/Sources/leenkx/logicnode/AddTorrentNode.hx
Normal file
79
leenkx/Sources/leenkx/logicnode/AddTorrentNode.hx
Normal file
@ -0,0 +1,79 @@
|
||||
package leenkx.logicnode;
|
||||
import leenkx.system.Event;
|
||||
#if js
|
||||
import leenkx.network.Leenkx;
|
||||
#end
|
||||
import iron.object.Object;
|
||||
|
||||
class AddTorrentNode extends LogicNode {
|
||||
public var title: String;
|
||||
public var values: Array<Dynamic>;
|
||||
public var net_Url: String;
|
||||
public var data: Dynamic;
|
||||
public var runner: Bool = false;
|
||||
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
public function promiseResult(connection,torrentid,net_Url){
|
||||
#if js
|
||||
if (runner == false){
|
||||
values = [];
|
||||
var script = 'var torrentId = "' + torrentid + '";
|
||||
lx_' + net_Url +'.wt.add(torrentId, function (torrent) {
|
||||
leenkx.network.Leenkx.torrent.set("' + net_Url +'", torrent.files);
|
||||
torrent.on("done", function () {
|
||||
leenkx.network.Leenkx.connections.h["' + net_Url +'"].ontorrentdone();
|
||||
})
|
||||
});
|
||||
';
|
||||
js.Syntax.code('(1, eval)({0})', script.toString());
|
||||
runner = true;
|
||||
promiseResult(connection,torrentid,net_Url);
|
||||
return;
|
||||
}else{
|
||||
try{
|
||||
values = leenkx.network.Leenkx.torrent.get(net_Url);
|
||||
if(values.length > 0){
|
||||
runOutput(0);
|
||||
runner = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(error){
|
||||
haxe.Timer.delay(function () {
|
||||
promiseResult(connection,torrentid,net_Url);
|
||||
return;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
override function run(from:Int) {
|
||||
var connection = inputs[1].get();
|
||||
if (connection == null) return;
|
||||
var torrentid = inputs[2].get();
|
||||
if (torrentid == null) return;
|
||||
#if js
|
||||
net_Url = connection._url;
|
||||
promiseResult(connection,torrentid,net_Url);
|
||||
#end
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
#if js
|
||||
return switch (from) {
|
||||
case 1: Leenkx.id.get(net_Url);
|
||||
case 2: leenkx.network.Leenkx.torrent.get(net_Url);
|
||||
default: throw "Unreachable";
|
||||
}
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/AddTraitNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/AddTraitNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
class AddTraitNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var traitName: String = inputs[2].get();
|
||||
|
||||
assert(Error, object != null, "Object should not be null");
|
||||
assert(Error, traitName != null, "Trait name should not be null");
|
||||
|
||||
var cname = Type.resolveClass(Main.projectPackage + "." + traitName);
|
||||
if (cname == null) cname = Type.resolveClass(Main.projectPackage + ".node." + traitName);
|
||||
assert(Error, cname != null, 'No trait with the name "$traitName" found, make sure that the trait is exported!');
|
||||
assert(Warning, object.getTrait(cname) == null, 'Object already has the trait "$traitName" applied');
|
||||
|
||||
var trait = Type.createInstance(cname, []);
|
||||
object.addTrait(trait);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
17
leenkx/Sources/leenkx/logicnode/AlertNode.hx
Normal file
17
leenkx/Sources/leenkx/logicnode/AlertNode.hx
Normal file
@ -0,0 +1,17 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class AlertNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
#if kha_html5
|
||||
js.Browser.window.alert(inputs[1].get());
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
18
leenkx/Sources/leenkx/logicnode/AlternateNode.hx
Normal file
18
leenkx/Sources/leenkx/logicnode/AlternateNode.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class AlternateNode extends LogicNode {
|
||||
|
||||
var i = 0;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
if(i >= outputs.length) i = 0;
|
||||
runOutput(i);
|
||||
++i;
|
||||
|
||||
}
|
||||
}
|
69
leenkx/Sources/leenkx/logicnode/AnimActionNode.hx
Normal file
69
leenkx/Sources/leenkx/logicnode/AnimActionNode.hx
Normal file
@ -0,0 +1,69 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import kha.FastFloat;
|
||||
import iron.object.ObjectAnimation;
|
||||
import iron.object.Object;
|
||||
import iron.object.Animation;
|
||||
#if lnx_skin
|
||||
import iron.object.BoneAnimation;
|
||||
#end
|
||||
import iron.math.Mat4;
|
||||
|
||||
|
||||
class AnimActionNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
public var sampler: ActionSampler;
|
||||
var object: Object;
|
||||
#if lnx_skin
|
||||
var animationBone: BoneAnimation;
|
||||
#end
|
||||
var animationObject: ObjectAnimation;
|
||||
var ready = false;
|
||||
var func:Dynamic = null;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
|
||||
tree.notifyOnUpdate(init);
|
||||
}
|
||||
|
||||
function init(){
|
||||
sampler = new ActionSampler(inputs[1].get(), 1.0, inputs[2].get());
|
||||
object = inputs[0].get();
|
||||
assert(Error, object != null, "The object input not be null");
|
||||
if(object.animation == null) {
|
||||
#if lnx_skin
|
||||
animationBone = object.getBoneAnimation(object.uid);
|
||||
animationBone.registerAction(property0, sampler);
|
||||
func = sampleBonaAction;
|
||||
#end
|
||||
}
|
||||
else{
|
||||
animationObject = cast(object.animation, ObjectAnimation);
|
||||
animationObject.registerAction(property0, sampler);
|
||||
func = sampleObjectAction;
|
||||
}
|
||||
|
||||
ready = true;
|
||||
tree.removeUpdate(init);
|
||||
}
|
||||
|
||||
#if lnx_skin
|
||||
public function sampleBonaAction(animMats: Array<Mat4>){
|
||||
animationBone.sampleAction(sampler, animMats);
|
||||
}
|
||||
#end
|
||||
|
||||
public function sampleObjectAction(animMats: Map<String, FastFloat>) {
|
||||
animationObject.sampleAction(sampler, animMats);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
if(!ready) init();
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
}
|
19
leenkx/Sources/leenkx/logicnode/AnimTreeNode.hx
Normal file
19
leenkx/Sources/leenkx/logicnode/AnimTreeNode.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class AnimTreeNode extends LogicNode {
|
||||
|
||||
public var value: Dynamic;
|
||||
|
||||
public function new(tree: LogicTree, value: Dynamic = null) {
|
||||
super(tree);
|
||||
this.value = value == null ? {} : value;
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return value;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
43
leenkx/Sources/leenkx/logicnode/AnimationStateNode.hx
Normal file
43
leenkx/Sources/leenkx/logicnode/AnimationStateNode.hx
Normal file
@ -0,0 +1,43 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Animation;
|
||||
import iron.object.Object;
|
||||
|
||||
class AnimationStateNode extends LogicNode {
|
||||
|
||||
var object: Object;
|
||||
var animation: Animation;
|
||||
var sampler: ActionSampler;
|
||||
public var property0: String;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
tree.notifyOnUpdate(init);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
object = inputs[0].get();
|
||||
assert(Error, object != null, "Object input cannot be null");
|
||||
animation = object.animation;
|
||||
if (animation == null) animation = object.getBoneAnimation(object.uid);
|
||||
assert(Error, animation != null, "Object does not have animations");
|
||||
sampler = animation.activeActions.get(property0);
|
||||
if(sampler == null) return;
|
||||
sampler.notifyOnComplete(function (){runOutput(0);});
|
||||
tree.removeUpdate(init);
|
||||
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if(sampler == null) return null;
|
||||
return switch (from) {
|
||||
case 1: sampler.actionDataInit;
|
||||
case 2: sampler.action;
|
||||
case 3: sampler.offset;
|
||||
case 4: sampler.paused;
|
||||
case 5: sampler.speed;
|
||||
case 6: sampler.totalFrames;
|
||||
default: null;
|
||||
}
|
||||
}
|
||||
}
|
30
leenkx/Sources/leenkx/logicnode/AppendTransformNode.hx
Normal file
30
leenkx/Sources/leenkx/logicnode/AppendTransformNode.hx
Normal file
@ -0,0 +1,30 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Mat4;
|
||||
#if lnx_physics
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
#end
|
||||
|
||||
class AppendTransformNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var matrix: Mat4 = inputs[2].get();
|
||||
|
||||
if (object == null || matrix == null) return;
|
||||
|
||||
object.transform.multMatrix(matrix);
|
||||
|
||||
#if lnx_physics
|
||||
var rigidBody = object.getTrait(RigidBody);
|
||||
if (rigidBody != null) rigidBody.syncTransform();
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
38
leenkx/Sources/leenkx/logicnode/ApplyForceAtLocationNode.hx
Normal file
38
leenkx/Sources/leenkx/logicnode/ApplyForceAtLocationNode.hx
Normal file
@ -0,0 +1,38 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Quat;
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyForceAtLocationNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var force: Vec4 = inputs[2].get();
|
||||
var localForce: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
var location: Vec4 = new Vec4().setFrom(inputs[4].get());
|
||||
var localLoc: Bool = inputs.length > 5 ? inputs[5].get() : false;
|
||||
|
||||
if (object == null || force == null || location == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
if (!localLoc) {
|
||||
location.sub(object.transform.world.getLoc());
|
||||
}
|
||||
|
||||
!localForce ? rb.applyForce(force, location) : rb.applyForce(object.transform.worldVecToOrientation(force), location);
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
31
leenkx/Sources/leenkx/logicnode/ApplyForceNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/ApplyForceNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyForceNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var force: Vec4 = inputs[2].get();
|
||||
var local: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
|
||||
if (object == null || force == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
!local ? rb.applyForce(force) : rb.applyForce(object.transform.worldVecToOrientation(force));
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyImpulseAtLocationNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var impulse: Vec4 = inputs[2].get();
|
||||
var localImpulse: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
var location: Vec4 = new Vec4().setFrom(inputs[4].get());
|
||||
var localLoc: Bool = inputs.length > 5 ? inputs[5].get() : false;
|
||||
|
||||
if (object == null || impulse == null || location == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
if (!localLoc) {
|
||||
location.sub(object.transform.world.getLoc());
|
||||
}
|
||||
|
||||
!localImpulse ? rb.applyImpulse(impulse, location) : rb.applyImpulse(object.transform.worldVecToOrientation(impulse), location);
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
31
leenkx/Sources/leenkx/logicnode/ApplyImpulseNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/ApplyImpulseNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyImpulseNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var impulse: Vec4 = inputs[2].get();
|
||||
var local: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
|
||||
if (object == null || impulse == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
!local ? rb.applyImpulse(impulse) : rb.applyImpulse(object.transform.worldVecToOrientation(impulse));
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
31
leenkx/Sources/leenkx/logicnode/ApplyTorqueImpulseNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/ApplyTorqueImpulseNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyTorqueImpulseNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var torque: Vec4 = inputs[2].get();
|
||||
var local: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
|
||||
if (object == null || torque == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
!local ? rb.applyTorqueImpulse(torque) : rb.applyTorqueImpulse(object.transform.worldVecToOrientation(torque));
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
31
leenkx/Sources/leenkx/logicnode/ApplyTorqueNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/ApplyTorqueNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyTorqueNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var torque: Vec4 = inputs[2].get();
|
||||
var local: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
|
||||
if (object == null || torque == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
!local ? rb.applyTorque(torque) : rb.applyTorque(object.transform.worldVecToOrientation(torque));
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
49
leenkx/Sources/leenkx/logicnode/ArrayAddNode.hx
Normal file
49
leenkx/Sources/leenkx/logicnode/ArrayAddNode.hx
Normal file
@ -0,0 +1,49 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayAddNode extends LogicNode {
|
||||
|
||||
var ar: Array<Dynamic>;
|
||||
var array: Array<Dynamic>;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
ar = inputs[1].get();
|
||||
|
||||
if (ar == null) return;
|
||||
|
||||
// "Modify Original" == `false` -> Copy the input array
|
||||
if (!inputs[2].get()) {
|
||||
ar = ar.copy();
|
||||
}
|
||||
|
||||
array = ar.map(item -> Std.string(item));
|
||||
|
||||
if (inputs.length > 5) {
|
||||
for (i in 5...inputs.length) {
|
||||
var value: Dynamic = inputs[i].get();
|
||||
|
||||
// "Unique Values" options only supports primitive data types
|
||||
// for now, a custom indexOf() or contains() method would be
|
||||
// required to compare values of other types
|
||||
|
||||
//meanwhile an efficient comparison method is defined, it can be compared as a string representation.
|
||||
var type: Bool = value is Bool || value is Float || value is Int || value is String;
|
||||
|
||||
if (!inputs[3].get() || (type ? ar.indexOf(value) : array.indexOf(Std.string(value))) == -1) {
|
||||
if (inputs[4].get())
|
||||
ar.unshift(value);
|
||||
else ar.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return ar;
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayBooleanNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayBooleanNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayBooleanNode extends LogicNode {
|
||||
|
||||
public var value: Array<Bool> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Bool = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
29
leenkx/Sources/leenkx/logicnode/ArrayColorNode.hx
Normal file
29
leenkx/Sources/leenkx/logicnode/ArrayColorNode.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Vec4;
|
||||
|
||||
class ArrayColorNode extends LogicNode {
|
||||
|
||||
public var value: Array<Vec4> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Vec4 = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
16
leenkx/Sources/leenkx/logicnode/ArrayCompareNode.hx
Normal file
16
leenkx/Sources/leenkx/logicnode/ArrayCompareNode.hx
Normal file
@ -0,0 +1,16 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayCompareNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar1: Array<Dynamic> = inputs[0].get();
|
||||
var ar2: Array<Dynamic> = inputs[1].get();
|
||||
|
||||
return ar1.toString() == ar2.toString() ? true : false;
|
||||
|
||||
}
|
||||
}
|
18
leenkx/Sources/leenkx/logicnode/ArrayConcatNode.hx
Normal file
18
leenkx/Sources/leenkx/logicnode/ArrayConcatNode.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayConcatNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar1: Array<Dynamic> = inputs[0].get();
|
||||
var ar2: Array<Dynamic> = inputs[1].get();
|
||||
|
||||
var ar = ar1.concat(ar2);
|
||||
|
||||
return from == 0 ? ar : ar.length;
|
||||
|
||||
}
|
||||
}
|
33
leenkx/Sources/leenkx/logicnode/ArrayCountNode.hx
Normal file
33
leenkx/Sources/leenkx/logicnode/ArrayCountNode.hx
Normal file
@ -0,0 +1,33 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayCountNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
var values: Array<Dynamic> = [];
|
||||
var values_list: Array<Dynamic> = [];
|
||||
var count: Array<Int> = [];
|
||||
var val_count: Array<Dynamic> = [];
|
||||
|
||||
for(item in ar){
|
||||
if(values.indexOf(Std.string(item)) == -1){
|
||||
values_list.push(item);
|
||||
values.push(Std.string(item));
|
||||
count.push(1);
|
||||
}
|
||||
else {
|
||||
count[values.indexOf(Std.string(item))] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(i in 0...values_list.length)
|
||||
val_count.push([values_list[i], count[i]]);
|
||||
|
||||
return val_count;
|
||||
}
|
||||
}
|
31
leenkx/Sources/leenkx/logicnode/ArrayDisplayNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/ArrayDisplayNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayDisplayNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
var separator: String = inputs[1].get();
|
||||
|
||||
var prop: String = null;
|
||||
|
||||
if(property0 != 'Item')
|
||||
prop = inputs[2].get();
|
||||
|
||||
if(property0 == 'Item')
|
||||
return ar.join(separator);
|
||||
else if(property0 == 'Item Field')
|
||||
return [for (v in ar) Reflect.field(v, prop)].join(separator);
|
||||
else if(property0 == 'Item Property')
|
||||
return [for (v in ar) Reflect.field(v.properties.h, prop)].join(separator);
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayDistinctNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayDistinctNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayDistinctNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
var ar_list: Array<Dynamic> = [];
|
||||
var distinct: Array<Dynamic> = [];
|
||||
var duplicated: Array<Dynamic> = [];
|
||||
|
||||
for(item in ar)
|
||||
if(ar_list.indexOf(Std.string(item)) == -1){
|
||||
ar_list.push(Std.string(item));
|
||||
distinct.push(item);
|
||||
}
|
||||
else
|
||||
duplicated.push(item);
|
||||
|
||||
return from == 0 ? distinct: duplicated;
|
||||
|
||||
}
|
||||
}
|
137
leenkx/Sources/leenkx/logicnode/ArrayFilterNode.hx
Normal file
137
leenkx/Sources/leenkx/logicnode/ArrayFilterNode.hx
Normal file
@ -0,0 +1,137 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Vec4;
|
||||
|
||||
class ArrayFilterNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
public var property1: String;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
var type: Dynamic;
|
||||
|
||||
if(property0 == 'Item')
|
||||
type = inputs[1].get();
|
||||
else
|
||||
type = inputs[2].get();
|
||||
|
||||
var prop: String = inputs[1].get();
|
||||
|
||||
var arr: Array<Dynamic> = null;
|
||||
|
||||
if(property0 == 'Item'){
|
||||
if(Std.isOfType(type, Vec4)){
|
||||
var value: Vec4 = inputs[1].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> item.equals(value));
|
||||
case 'Not Equal': arr = ar.filter(item -> !item.equals(value));
|
||||
case 'Between': {
|
||||
var value2: Vec4 = inputs[2].get();
|
||||
arr = ar.filter(item -> value.x <= item.x && value.y <= item.y && value.z <= item.z && item.x <= value2.x && item.y <= value2.y && item.z <= value2.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Std.isOfType(type, String)){
|
||||
var value: String = inputs[1].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> item == value);
|
||||
case 'Not Equal': arr = ar.filter(item -> item != value);
|
||||
case 'Contains': arr = ar.filter(item -> item.indexOf(value) >= 0);
|
||||
case 'Starts With': arr = ar.filter(item -> StringTools.startsWith(item, value));
|
||||
case 'Ends With': arr = ar.filter(item -> StringTools.endsWith(item, value));
|
||||
}
|
||||
}
|
||||
else{
|
||||
var value = inputs[1].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> item == value);
|
||||
case 'Not Equal': arr = ar.filter(item -> item != value);
|
||||
case 'Between': { var value2 = inputs[2].get(); arr = ar.filter(item -> value <= item && item <= value2); }
|
||||
case 'Less': arr = ar.filter(item -> item < value);
|
||||
case 'Less Equal': arr = ar.filter(item -> item <= value);
|
||||
case 'Greater': arr = ar.filter(item -> item > value);
|
||||
case 'Greater Equal': arr = ar.filter(item -> item >= value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(property0 == 'Item Field'){
|
||||
if(Std.isOfType(type, Vec4)){
|
||||
var value: Vec4 = inputs[2].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> Reflect.field(item, prop).equals(value));
|
||||
case 'Not Equal': arr = ar.filter(item -> !Reflect.field(item, prop).equals(value));
|
||||
case 'Between': {
|
||||
var value2: Vec4 = inputs[2].get();
|
||||
arr = ar.filter(item -> value.x <= Reflect.field(item, prop).x && value.y <= Reflect.field(item, prop).y && value.z <= Reflect.field(item, prop).z && Reflect.field(item, prop).x <= value2.x && Reflect.field(item, prop).y <= value2.y && Reflect.field(item, prop).z <= value2.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Std.isOfType(type, String)){
|
||||
var value: String = inputs[2].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> Reflect.field(item, prop) == value);
|
||||
case 'Not Equal': arr = ar.filter(item -> Reflect.field(item, prop) != value);
|
||||
case 'Contains': arr = ar.filter(item -> Reflect.field(item, prop).indexOf(value) >= 0);
|
||||
case 'Starts With': arr = ar.filter(item -> StringTools.startsWith(Reflect.field(item, prop), value));
|
||||
case 'Ends With': arr = ar.filter(item -> StringTools.endsWith(Reflect.field(item, prop), value));
|
||||
}
|
||||
}
|
||||
else{
|
||||
var value: Dynamic = inputs[2].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> Reflect.field(item, prop) == value);
|
||||
case 'Not Equal': arr = ar.filter(item -> Reflect.field(item, prop) != value);
|
||||
case 'Between': { var value2: Dynamic = inputs[2].get(); arr = ar.filter(item -> value <= Reflect.field(item, prop) && Reflect.field(item, prop) <= value2); }
|
||||
case 'Less': arr = ar.filter(item -> Reflect.field(item, prop) < value);
|
||||
case 'Less Equal': arr = ar.filter(item -> Reflect.field(item, prop) <= value);
|
||||
case 'Greater': arr = ar.filter(item -> Reflect.field(item, prop) > value);
|
||||
case 'Greater Equal': arr = ar.filter(item -> Reflect.field(item, prop) >= value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(property0 == 'Item Property'){
|
||||
if(Std.isOfType(type, Vec4)){
|
||||
var value: Vec4 = inputs[2].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop).equals(value));
|
||||
case 'Not Equal': arr = ar.filter(item -> !Reflect.field(item.properties.h, prop).equals(value));
|
||||
case 'Between': {
|
||||
var value2: Vec4 = inputs[2].get();
|
||||
arr = ar.filter(item -> value.x <= Reflect.field(item.properties.h, prop).x && value.y <= Reflect.field(item.properties.h, prop).y && value.z <= Reflect.field(item.properties.h, prop).z && Reflect.field(item.properties.h, prop).x <= value2.x && Reflect.field(item.properties.h, prop).y <= value2.y && Reflect.field(item.properties.h, prop).z <= value2.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Std.isOfType(type, String)){
|
||||
var value: String = inputs[2].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) == value);
|
||||
case 'Not Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) != value);
|
||||
case 'Contains': arr = ar.filter(item -> Reflect.field(item.properties.h, prop).indexOf(value) >= 0);
|
||||
case 'Starts With': arr = ar.filter(item -> StringTools.startsWith(Reflect.field(item.properties.h, prop), value));
|
||||
case 'Ends With': arr = ar.filter(item -> StringTools.endsWith(Reflect.field(item.properties.h, prop), value));
|
||||
}
|
||||
}
|
||||
else{
|
||||
var value: Dynamic = inputs[2].get();
|
||||
switch(property1){
|
||||
case 'Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) == value);
|
||||
case 'Not Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) != value);
|
||||
case 'Between': { var value2: Dynamic = inputs[2].get(); arr = ar.filter(item -> value <= Reflect.field(item.properties.h, prop) && Reflect.field(item.properties.h, prop) <= value2); }
|
||||
case 'Less': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) < value);
|
||||
case 'Less Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) <= value);
|
||||
case 'Greater': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) > value);
|
||||
case 'Greater Equal': arr = ar.filter(item -> Reflect.field(item.properties.h, prop) >= value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayFloatNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayFloatNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayFloatNode extends LogicNode {
|
||||
|
||||
public var value: Array<Float> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Float = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
26
leenkx/Sources/leenkx/logicnode/ArrayGetNextNode.hx
Normal file
26
leenkx/Sources/leenkx/logicnode/ArrayGetNextNode.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayGetNextNode extends LogicNode {
|
||||
|
||||
var i = 0;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
if (ar == null) return null;
|
||||
|
||||
var value = ar[i];
|
||||
|
||||
if (i < ar.length - 1)
|
||||
i++;
|
||||
else
|
||||
i = 0;
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
}
|
29
leenkx/Sources/leenkx/logicnode/ArrayGetNode.hx
Normal file
29
leenkx/Sources/leenkx/logicnode/ArrayGetNode.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayGetNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
if (ar == null) return null;
|
||||
|
||||
var i: Int = inputs[1].get();
|
||||
|
||||
if (i < 0) i = ar.length + i;
|
||||
if (i < 0 || i > ar.length - 1) {
|
||||
|
||||
var className = Type.getClassName(Type.getClass(tree));
|
||||
var traitName = className.substring(className.lastIndexOf(".") + 1);
|
||||
var objectName = tree.object.name;
|
||||
|
||||
trace('Logic error (object: $objectName, trait: $traitName): Array Get - index out of range');
|
||||
|
||||
return null;
|
||||
}
|
||||
return ar[i];
|
||||
}
|
||||
}
|
33
leenkx/Sources/leenkx/logicnode/ArrayGetPreviousNextNode.hx
Normal file
33
leenkx/Sources/leenkx/logicnode/ArrayGetPreviousNextNode.hx
Normal file
@ -0,0 +1,33 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayGetPreviousNextNode extends LogicNode {
|
||||
|
||||
var i = 0;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
var direction: Bool = inputs[1].get();
|
||||
|
||||
if (ar == null) return null;
|
||||
|
||||
if(direction)
|
||||
if (i < ar.length - 1)
|
||||
i++;
|
||||
else
|
||||
i = 0;
|
||||
else
|
||||
if (i <= 0)
|
||||
i = ar.length-1;
|
||||
else
|
||||
i--;
|
||||
|
||||
var value = ar[i];
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
}
|
16
leenkx/Sources/leenkx/logicnode/ArrayInArrayNode.hx
Normal file
16
leenkx/Sources/leenkx/logicnode/ArrayInArrayNode.hx
Normal file
@ -0,0 +1,16 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayInArrayNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var array: Array<Dynamic> = inputs[0].get();
|
||||
array = array.map(item -> Std.string(item));
|
||||
var value: Dynamic = inputs[1].get();
|
||||
|
||||
return array.indexOf(Std.string(value)) != -1;
|
||||
}
|
||||
}
|
17
leenkx/Sources/leenkx/logicnode/ArrayIndexNode.hx
Normal file
17
leenkx/Sources/leenkx/logicnode/ArrayIndexNode.hx
Normal file
@ -0,0 +1,17 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayIndexNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var array: Array<Dynamic> = inputs[0].get();
|
||||
array = array.map(item -> Std.string(item));
|
||||
var value: Dynamic = inputs[1].get();
|
||||
var from: Int = inputs[2].get();
|
||||
|
||||
return array.indexOf(Std.string(value), from);
|
||||
}
|
||||
}
|
26
leenkx/Sources/leenkx/logicnode/ArrayInsertNode.hx
Normal file
26
leenkx/Sources/leenkx/logicnode/ArrayInsertNode.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayInsertNode extends LogicNode {
|
||||
|
||||
var ar: Array<Dynamic>;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
ar = inputs[1].get();
|
||||
var index: Int = inputs[2].get();
|
||||
var value: Dynamic = inputs[3].get();
|
||||
|
||||
if (ar == null || value == null) return;
|
||||
|
||||
ar.insert(index, value);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return ar;
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayIntegerNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayIntegerNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayIntegerNode extends LogicNode {
|
||||
|
||||
public var value: Array<Int> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Int = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
13
leenkx/Sources/leenkx/logicnode/ArrayLengthNode.hx
Normal file
13
leenkx/Sources/leenkx/logicnode/ArrayLengthNode.hx
Normal file
@ -0,0 +1,13 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayLengthNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
return ar != null ? ar.length : 0;
|
||||
}
|
||||
}
|
40
leenkx/Sources/leenkx/logicnode/ArrayLoopNode.hx
Normal file
40
leenkx/Sources/leenkx/logicnode/ArrayLoopNode.hx
Normal file
@ -0,0 +1,40 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayLoopNode extends LogicNode {
|
||||
|
||||
var value: Dynamic;
|
||||
var index: Int;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
index = -1;
|
||||
for (val in ar) {
|
||||
value = val;
|
||||
index++;
|
||||
runOutput(0);
|
||||
|
||||
if (tree.loopBreak) {
|
||||
tree.loopBreak = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tree.loopContinue) {
|
||||
tree.loopContinue = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
runOutput(3);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (from == 1)
|
||||
return value;
|
||||
return index;
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayNode extends LogicNode {
|
||||
|
||||
public var value: Array<Dynamic> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Dynamic = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
29
leenkx/Sources/leenkx/logicnode/ArrayObjectNode.hx
Normal file
29
leenkx/Sources/leenkx/logicnode/ArrayObjectNode.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
class ArrayObjectNode extends LogicNode {
|
||||
|
||||
public var value: Array<Object> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Object = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
15
leenkx/Sources/leenkx/logicnode/ArrayPopNode.hx
Normal file
15
leenkx/Sources/leenkx/logicnode/ArrayPopNode.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayPopNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
if (ar == null) return null;
|
||||
|
||||
return ar.pop();
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayRemoveNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayRemoveNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayRemoveNode extends LogicNode {
|
||||
|
||||
var removedValue: Dynamic = null;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
var i: Int = inputs[2].get();
|
||||
if (i < 0) i = ar.length + i;
|
||||
|
||||
removedValue = ar[i];
|
||||
ar.splice(i, 1);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return removedValue;
|
||||
}
|
||||
}
|
26
leenkx/Sources/leenkx/logicnode/ArrayRemoveValueNode.hx
Normal file
26
leenkx/Sources/leenkx/logicnode/ArrayRemoveValueNode.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayRemoveValueNode extends LogicNode {
|
||||
|
||||
var removedValue: Dynamic = null;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
var val: Dynamic = inputs[2].get();
|
||||
|
||||
removedValue = val;
|
||||
ar.remove(val);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return removedValue;
|
||||
}
|
||||
}
|
19
leenkx/Sources/leenkx/logicnode/ArrayResizeNode.hx
Normal file
19
leenkx/Sources/leenkx/logicnode/ArrayResizeNode.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayResizeNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
var len = inputs[2].get();
|
||||
|
||||
ar.resize(len);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
19
leenkx/Sources/leenkx/logicnode/ArrayReverseNode.hx
Normal file
19
leenkx/Sources/leenkx/logicnode/ArrayReverseNode.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayReverseNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
var arr = ar.copy();
|
||||
|
||||
arr.reverse();
|
||||
|
||||
return arr;
|
||||
|
||||
}
|
||||
}
|
23
leenkx/Sources/leenkx/logicnode/ArraySampleNode.hx
Normal file
23
leenkx/Sources/leenkx/logicnode/ArraySampleNode.hx
Normal file
@ -0,0 +1,23 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArraySampleNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
var sample = inputs[1].get();
|
||||
var remove = inputs[2].get();
|
||||
|
||||
if (ar == null || sample == 0) return null;
|
||||
|
||||
var n = Std.int(Math.min(sample, ar.length));
|
||||
var copy = remove ? ar : ar.copy(), result = [];
|
||||
for (i in 0...n)
|
||||
result.push(copy.splice(Std.random(copy.length), 1)[0]);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
21
leenkx/Sources/leenkx/logicnode/ArraySetNode.hx
Normal file
21
leenkx/Sources/leenkx/logicnode/ArraySetNode.hx
Normal file
@ -0,0 +1,21 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArraySetNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
var i: Int = inputs[2].get();
|
||||
var value: Dynamic = inputs[3].get();
|
||||
|
||||
if (i < 0) ar[ar.length + i] = value;
|
||||
else ar[i] = value;
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
15
leenkx/Sources/leenkx/logicnode/ArrayShiftNode.hx
Normal file
15
leenkx/Sources/leenkx/logicnode/ArrayShiftNode.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayShiftNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
if (ar == null) return null;
|
||||
|
||||
return ar.shift();
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayShuffleNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayShuffleNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayShuffleNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
|
||||
var t = [], array = [];
|
||||
|
||||
for(i in 0...ar.length)
|
||||
t.push(i);
|
||||
|
||||
while (t.length > 0) {
|
||||
var pos = Std.random(t.length), index = t[pos];
|
||||
t.splice(pos, 1);
|
||||
array.push(ar[index]);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
|
27
leenkx/Sources/leenkx/logicnode/ArraySliceNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArraySliceNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArraySliceNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
if (ar == null) return null;
|
||||
|
||||
var i: Int = inputs[1].get();
|
||||
var end: Int = inputs[2].get();
|
||||
|
||||
if (i < 0) i = ar.length + i;
|
||||
if (i < 0 || i > ar.length - 1) {
|
||||
var className = Type.getClassName(Type.getClass(tree));
|
||||
var traitName = className.substring(className.lastIndexOf(".") + 1);
|
||||
var objectName = tree.object.name;
|
||||
trace('Logic error (object: $objectName, trait: $traitName): Array Get - index out of range');
|
||||
return null;
|
||||
}
|
||||
|
||||
return ar.slice(i, end);
|
||||
}
|
||||
}
|
22
leenkx/Sources/leenkx/logicnode/ArraySortNode.hx
Normal file
22
leenkx/Sources/leenkx/logicnode/ArraySortNode.hx
Normal file
@ -0,0 +1,22 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArraySortNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var ar: Array<Dynamic> = inputs[0].get();
|
||||
var desc: Bool = inputs[1].get();
|
||||
|
||||
var arr = ar.copy();
|
||||
|
||||
arr.sort(Reflect.compare);
|
||||
|
||||
if (desc) arr.reverse();
|
||||
|
||||
return arr;
|
||||
|
||||
}
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/ArraySpliceNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/ArraySpliceNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArraySpliceNode extends LogicNode {
|
||||
|
||||
var splice: Array<Dynamic>;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var ar: Array<Dynamic> = inputs[1].get();
|
||||
if (ar == null) return;
|
||||
|
||||
var i = inputs[2].get();
|
||||
var len = inputs[3].get();
|
||||
|
||||
splice = ar.splice(i, len);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
return splice;
|
||||
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/ArrayStringNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/ArrayStringNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ArrayStringNode extends LogicNode {
|
||||
|
||||
public var value: Array<String> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: String = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
29
leenkx/Sources/leenkx/logicnode/ArrayVectorNode.hx
Normal file
29
leenkx/Sources/leenkx/logicnode/ArrayVectorNode.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Vec4;
|
||||
|
||||
class ArrayVectorNode extends LogicNode {
|
||||
|
||||
public var value: Array<Vec4> = [];
|
||||
var initialized = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (inp in inputs) {
|
||||
var val: Vec4 = inp.get();
|
||||
value.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return from == 0 ? value : value.length;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
19
leenkx/Sources/leenkx/logicnode/AudioDSPFilterNode.hx
Normal file
19
leenkx/Sources/leenkx/logicnode/AudioDSPFilterNode.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package leenkx.logicnode;
|
||||
import aura.Aura;
|
||||
import aura.dsp.Filter;
|
||||
|
||||
class AudioDSPFilterNode extends LogicNode {
|
||||
public var property0: Dynamic;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var DSPFilter = new Filter(property0);
|
||||
DSPFilter.setCutoffFreq(inputs[2].get(), All);
|
||||
Aura.mixChannels[inputs[1].get()].addInsert(DSPFilter);
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
17
leenkx/Sources/leenkx/logicnode/AudioDSPHaasEffectNode.hx
Normal file
17
leenkx/Sources/leenkx/logicnode/AudioDSPHaasEffectNode.hx
Normal file
@ -0,0 +1,17 @@
|
||||
package leenkx.logicnode;
|
||||
import aura.Aura;
|
||||
import aura.dsp.HaasEffect;
|
||||
|
||||
class AudioDSPHaasEffectNode extends LogicNode {
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var DSPHaasEffect = new HaasEffect(inputs[2].get());
|
||||
Aura.mixChannels[inputs[1].get()].addInsert(DSPHaasEffect);
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
40
leenkx/Sources/leenkx/logicnode/AudioHRTFPannerNode.hx
Normal file
40
leenkx/Sources/leenkx/logicnode/AudioHRTFPannerNode.hx
Normal file
@ -0,0 +1,40 @@
|
||||
package leenkx.logicnode;
|
||||
import aura.Aura;
|
||||
import aura.Types;
|
||||
import aura.types.HRTFData;
|
||||
import aura.dsp.panner.HRTFPanner;
|
||||
|
||||
class AudioHRTFPannerNode extends LogicNode {
|
||||
public var property0: String;
|
||||
public var audio: Dynamic;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
audio = inputs[1].get();
|
||||
if (audio == null){
|
||||
return;
|
||||
}
|
||||
var mhr_file = "Default_mhr";
|
||||
if (property0 == "Custom"){
|
||||
mhr_file = inputs[5].get();
|
||||
}
|
||||
new HRTFPanner(audio, Aura.getHRTF(mhr_file));
|
||||
|
||||
var camera = inputs[2].get();
|
||||
Aura.listener.set(camera.worldPosition, camera.look, camera.right);
|
||||
|
||||
audio.panner.setLocation(inputs[3].get());
|
||||
|
||||
audio.panner.update3D();
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from:Int): Dynamic {
|
||||
return audio;
|
||||
}
|
||||
|
||||
}
|
77
leenkx/Sources/leenkx/logicnode/AudioLoadNode.hx
Normal file
77
leenkx/Sources/leenkx/logicnode/AudioLoadNode.hx
Normal file
@ -0,0 +1,77 @@
|
||||
package leenkx.logicnode;
|
||||
import iron.data.Data;
|
||||
import aura.Aura;
|
||||
import aura.Assets;
|
||||
|
||||
class AudioLoadNode extends LogicNode {
|
||||
public var property1: String;
|
||||
public var audio: Dynamic;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
//kha.SystemImpl.mobileAudioPlaying = false;
|
||||
Aura.init();
|
||||
}
|
||||
|
||||
|
||||
override function get(from:Int): Dynamic {
|
||||
|
||||
|
||||
if (audio != null){
|
||||
return audio;
|
||||
} else {
|
||||
var name = inputs[1].get();
|
||||
if (name == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
//var sound = aura.Assets.Sound(name, Uncompress);
|
||||
//var anotherSound = aura.Assets.Sound("AnotherSoundFile", KeepCompressed);
|
||||
//var hrtf = aura.Assets.HRTF("myHRTF_mhr");
|
||||
|
||||
Data.getSound(name, function (data) {
|
||||
//audio = Aura.createUncompBufferChannel(data,inputs[2].get(),Aura.mixChannels[inputs[0].get()]);
|
||||
var assetList = [
|
||||
data,
|
||||
//anotherSound,
|
||||
//hrtf,
|
||||
];
|
||||
|
||||
aura.Assets.startLoading(assetList,
|
||||
|
||||
(asset: aura.Assets.Asset, numLoaded: Int, numTotalAssets: Int) -> {
|
||||
trace('Loaded $numLoadedAssets of $totalNumAssets: ${asset.name}');
|
||||
audio = Aura.createUncompBufferChannel(asset,inputs[2].get(),Aura.mixChannels[inputs[0].get()]);
|
||||
if (numLoaded == totalNumAssets) {
|
||||
trace("Loaded all assets");
|
||||
}
|
||||
},
|
||||
|
||||
(asset: aura.Assets.Asset, error: kha.AssetError) -> {
|
||||
trace('Failed to load asset ${asset.name}. Reason: $error');
|
||||
return AbortLoading;
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
//Data.getSound(name, function (data) {
|
||||
// audio = Aura.createUncompBufferChannel(data,inputs[2].get(),Aura.mixChannels[inputs[0].get()]);
|
||||
//});
|
||||
|
||||
return audio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
In addition to the above change:
|
||||
- `aura.types.HRTF` was renamed to `aura.types.HRTFData`
|
||||
- `aura.dsp.panner.HRTFPanner.new()` now expects an `aura.Assets.HRTF` object instead of an `aura.types.HRTFData` object as its second parameter
|
||||
- `Aura.getSound()` now returns `Null<aura.Assets.Sound>` instead of `Null<kha.Sound>`
|
||||
- `Aura.getHRTF()` now returns `Null<aura.Assets.HRTF>` instead of `Null<aura.types.HRTFData>`
|
||||
- `Aura.createUncompBufferChannel()` and `Aura.createCompBufferChannel()` now take an `aura.Assets.Sound` as their first parameter instead of a `kha.Sound`
|
22
leenkx/Sources/leenkx/logicnode/AudioPauseNode.hx
Normal file
22
leenkx/Sources/leenkx/logicnode/AudioPauseNode.hx
Normal file
@ -0,0 +1,22 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
|
||||
class AudioPauseNode extends LogicNode {
|
||||
public var audio: Dynamic;
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
override function run(from: Int) {
|
||||
audio = inputs[1].get();
|
||||
if (audio == null){
|
||||
return;
|
||||
}
|
||||
audio.pause();
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from:Int): Dynamic {
|
||||
return audio;
|
||||
}
|
||||
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/AudioPlayNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/AudioPlayNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
|
||||
class AudioPlayNode extends LogicNode {
|
||||
public var audio: Dynamic;
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
override function run(from: Int) {
|
||||
audio = inputs[1].get();
|
||||
if (audio == null){
|
||||
return;
|
||||
}
|
||||
if(inputs[2].get() == true){
|
||||
audio.play(true);
|
||||
|
||||
}else{
|
||||
audio.play();
|
||||
}
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from:Int): Dynamic {
|
||||
return audio;
|
||||
}
|
||||
|
||||
}
|
45
leenkx/Sources/leenkx/logicnode/AudioStereoPannerNode.hx
Normal file
45
leenkx/Sources/leenkx/logicnode/AudioStereoPannerNode.hx
Normal file
@ -0,0 +1,45 @@
|
||||
package leenkx.logicnode;
|
||||
import aura.Types;
|
||||
import aura.dsp.panner.StereoPanner;
|
||||
|
||||
class AudioStereoPannerNode extends LogicNode {
|
||||
public var property0: String;
|
||||
public var audio: Dynamic;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
audio = inputs[1].get();
|
||||
if (audio == null){
|
||||
return;
|
||||
}
|
||||
|
||||
var panner = new StereoPanner(audio);
|
||||
|
||||
switch(property0){
|
||||
case "CENTER":
|
||||
panner.setBalance(Balance.CENTER);
|
||||
case "LEFT":
|
||||
panner.setBalance(Balance.LEFT);
|
||||
case "RIGHT":
|
||||
panner.setBalance(Balance.RIGHT);
|
||||
case "Degrees":
|
||||
var int = inputs[2].get();
|
||||
if(int > 89){
|
||||
panner.setBalance(Deg(89));
|
||||
}else if(int < -89){
|
||||
panner.setBalance(Deg(-89));
|
||||
}else{
|
||||
panner.setBalance(Deg(int));
|
||||
}
|
||||
}
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from:Int): Dynamic {
|
||||
return audio;
|
||||
}
|
||||
|
||||
}
|
22
leenkx/Sources/leenkx/logicnode/AudioStopNode.hx
Normal file
22
leenkx/Sources/leenkx/logicnode/AudioStopNode.hx
Normal file
@ -0,0 +1,22 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
|
||||
class AudioStopNode extends LogicNode {
|
||||
public var audio: Dynamic;
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
override function run(from: Int) {
|
||||
audio = inputs[1].get();
|
||||
if (audio == null){
|
||||
return;
|
||||
}
|
||||
audio.stop();
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from:Int): Dynamic {
|
||||
return audio;
|
||||
}
|
||||
|
||||
}
|
33
leenkx/Sources/leenkx/logicnode/BitwiseMathNode.hx
Normal file
33
leenkx/Sources/leenkx/logicnode/BitwiseMathNode.hx
Normal file
@ -0,0 +1,33 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class BitwiseMathNode extends LogicNode {
|
||||
|
||||
/** The operation to perform. **/
|
||||
public var property0: String;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
final op1: Int = inputs[0].get();
|
||||
|
||||
if (property0 == "negation") {
|
||||
return ~op1;
|
||||
}
|
||||
|
||||
final op2: Int = inputs[1].get();
|
||||
|
||||
return switch (property0) {
|
||||
case "and": op1 & op2;
|
||||
case "or": op1 | op2;
|
||||
case "xor": op1 ^ op2;
|
||||
|
||||
case "left_shift": op1 << op2;
|
||||
case "right_shift": op1 >> op2;
|
||||
case "unsigned_right_shift": op1 >>> op2;
|
||||
|
||||
default: 0;
|
||||
}
|
||||
}
|
||||
}
|
83
leenkx/Sources/leenkx/logicnode/BlendActionNode.hx
Normal file
83
leenkx/Sources/leenkx/logicnode/BlendActionNode.hx
Normal file
@ -0,0 +1,83 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import kha.FastFloat;
|
||||
import iron.object.ObjectAnimation;
|
||||
import iron.object.Animation;
|
||||
#if lnx_skin
|
||||
import iron.object.BoneAnimation;
|
||||
#end
|
||||
import iron.math.Mat4;
|
||||
import iron.object.Object;
|
||||
|
||||
class BlendActionNode extends LogicNode {
|
||||
|
||||
var object: Object;
|
||||
#if lnx_skin
|
||||
var animationBone: BoneAnimation;
|
||||
#end
|
||||
var animationObject: ObjectAnimation;
|
||||
var tempMats: Dynamic;
|
||||
var ready = false;
|
||||
var func: Dynamic = null;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
public function init(){
|
||||
object = inputs[0].get();
|
||||
assert(Error, object != null, "The object input not be null");
|
||||
if(object.animation == null) {
|
||||
#if lnx_skin
|
||||
animationBone = object.getBoneAnimation(object.uid);
|
||||
tempMats = animationBone.initMatsEmpty();
|
||||
func = blendBones;
|
||||
#end
|
||||
}
|
||||
else {
|
||||
animationObject = cast(object.animation, ObjectAnimation);
|
||||
tempMats = animationObject.initTransformMap();
|
||||
func = blendObject;
|
||||
}
|
||||
ready = true;
|
||||
}
|
||||
|
||||
public function blendObject(animMats: Map<String, FastFloat>) {
|
||||
inputs[1].get()(animMats);
|
||||
inputs[2].get()(tempMats);
|
||||
animationObject.blendActionObject(animMats, tempMats, animMats, inputs[3].get());
|
||||
|
||||
}
|
||||
|
||||
#if lnx_skin
|
||||
public function blendBones(animMats: Array<Mat4>) {
|
||||
var boneLayer = inputs[4].get();
|
||||
var factor = inputs[3].get();
|
||||
if(boneLayer < 0){
|
||||
boneLayer = null;
|
||||
if(factor < 0.05) {
|
||||
|
||||
inputs[1].get()(animMats);
|
||||
return;
|
||||
}
|
||||
if(factor > 0.95) {
|
||||
|
||||
inputs[2].get()(animMats);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
inputs[1].get()(animMats);
|
||||
inputs[2].get()(tempMats);
|
||||
animationBone.blendAction(animMats, tempMats, animMats, factor, boneLayer);
|
||||
|
||||
}
|
||||
#end
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if(!ready) init();
|
||||
|
||||
return func;
|
||||
|
||||
}
|
||||
}
|
96
leenkx/Sources/leenkx/logicnode/BlendSpaceNode.hx
Normal file
96
leenkx/Sources/leenkx/logicnode/BlendSpaceNode.hx
Normal file
@ -0,0 +1,96 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
#if lnx_skin
|
||||
import leenkx.object.AnimationExtension;
|
||||
import kha.FastFloat;
|
||||
import iron.math.Mat4;
|
||||
import iron.math.Vec3;
|
||||
import iron.math.Vec2;
|
||||
import iron.object.Object;
|
||||
import iron.object.Animation;
|
||||
import iron.object.BoneAnimation;
|
||||
#end
|
||||
|
||||
class BlendSpaceNode extends LogicNode {
|
||||
|
||||
|
||||
public var property0: Array<Float>;
|
||||
public var property1: Array<Bool>;
|
||||
public var property2: Bool;
|
||||
#if lnx_skin
|
||||
var value: Dynamic;
|
||||
var object: Object;
|
||||
var animationBone: BoneAnimation;
|
||||
var tempMats: Array<Mat4>;
|
||||
var tempMats2: Array<Mat4>;
|
||||
var ready = false;
|
||||
var func: Dynamic = null;
|
||||
static var totalAnims = 10;
|
||||
#end
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_skin
|
||||
public function init(){
|
||||
object = inputs[0].get();
|
||||
assert(Error, object != null, "The object input not be null");
|
||||
animationBone = object.getBoneAnimation(object.uid);
|
||||
tempMats = animationBone.initMatsEmpty();
|
||||
tempMats2 = animationBone.initMatsEmpty();
|
||||
func = blendBones;
|
||||
ready = true;
|
||||
}
|
||||
|
||||
public function getBlendWeights(): Map<Int, FastFloat> {
|
||||
var vecs = [];
|
||||
var sampleVec = new Vec2();
|
||||
|
||||
for(i in 0...totalAnims){
|
||||
|
||||
if(property1[i]) vecs.push(new Vec2(property0[i * 2], property0[i * 2 + 1]));
|
||||
}
|
||||
|
||||
if(property2) {
|
||||
sampleVec.set(property0[2 * totalAnims], property0[2 * totalAnims + 1]);
|
||||
}
|
||||
else {
|
||||
sampleVec.set(inputs[2].get(), inputs[3].get());
|
||||
}
|
||||
|
||||
return AnimationExtension.getBlend2DWeights(vecs, sampleVec);
|
||||
|
||||
}
|
||||
|
||||
public function blendBones(animMats: Array<Mat4>) {
|
||||
var anims = inputs[1].get();
|
||||
var weightsIndex = getBlendWeights();
|
||||
|
||||
var indices: Array<Int> = [];
|
||||
var weights: Array<FastFloat> = [];
|
||||
|
||||
for(key in weightsIndex.keys()){
|
||||
indices.push(key);
|
||||
weights.push(weightsIndex.get(key));
|
||||
}
|
||||
|
||||
var factor1 = weights[1] / (weights[0] + weights[1]);
|
||||
var factor2 = (weights[0] + weights[1]) / (weights[0] + weights[1] + weights[2]);
|
||||
|
||||
anims[indices[0]](tempMats);
|
||||
anims[indices[1]](tempMats2);
|
||||
anims[indices[2]](animMats);
|
||||
|
||||
animationBone.blendAction(tempMats, tempMats2, tempMats, factor1);
|
||||
animationBone.blendAction(animMats, tempMats, animMats, factor2);
|
||||
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if(!ready) init();
|
||||
|
||||
return blendBones;
|
||||
}
|
||||
#end
|
||||
}
|
18
leenkx/Sources/leenkx/logicnode/BloomGetNode.hx
Normal file
18
leenkx/Sources/leenkx/logicnode/BloomGetNode.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class BloomGetNode extends LogicNode {
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from:Int):Dynamic {
|
||||
return switch (from) {
|
||||
case 0: leenkx.renderpath.Postprocess.bloom_uniforms[0];
|
||||
case 1: leenkx.renderpath.Postprocess.bloom_uniforms[1];
|
||||
case 2: leenkx.renderpath.Postprocess.bloom_uniforms[2];
|
||||
case 3: #if rp_bloom Main.bloomRadius #else 0.0 #end;
|
||||
default: 0.0;
|
||||
}
|
||||
}
|
||||
}
|
21
leenkx/Sources/leenkx/logicnode/BloomSetNode.hx
Normal file
21
leenkx/Sources/leenkx/logicnode/BloomSetNode.hx
Normal file
@ -0,0 +1,21 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class BloomSetNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
leenkx.renderpath.Postprocess.bloom_uniforms[0] = inputs[1].get();
|
||||
leenkx.renderpath.Postprocess.bloom_uniforms[1] = inputs[2].get();
|
||||
leenkx.renderpath.Postprocess.bloom_uniforms[2] = inputs[3].get();
|
||||
|
||||
#if rp_bloom
|
||||
Main.bloomRadius = Math.max(inputs[4].get(), 0.0);
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
52
leenkx/Sources/leenkx/logicnode/BoneFKNode.hx
Normal file
52
leenkx/Sources/leenkx/logicnode/BoneFKNode.hx
Normal file
@ -0,0 +1,52 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Quat;
|
||||
import iron.math.Vec4;
|
||||
import iron.object.Object;
|
||||
import iron.object.BoneAnimation;
|
||||
import iron.math.Mat4;
|
||||
|
||||
class BoneFKNode extends LogicNode {
|
||||
|
||||
#if lnx_skin
|
||||
var object: Object;
|
||||
var animMats: Array<Mat4>;
|
||||
var animation: BoneAnimation;
|
||||
var ready = false;
|
||||
#end
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_skin
|
||||
public function init(){
|
||||
|
||||
object = inputs[0].get();
|
||||
assert(Error, object != null, "The object input not be null");
|
||||
animation = object.getBoneAnimation(object.uid);
|
||||
assert(Error, animation != null, "The object does not have armatureanimation");
|
||||
ready = true;
|
||||
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
return function (animMats: Array<Mat4>) {
|
||||
|
||||
if(! ready) init();
|
||||
|
||||
inputs[1].get()(animMats);
|
||||
var boneName: String = inputs[2].get();
|
||||
var transform = Mat4.identity().setFrom(inputs[3].get());
|
||||
|
||||
// Get bone in armature
|
||||
var bone = animation.getBone(boneName);
|
||||
|
||||
//Set the bone local transform from world transform
|
||||
animation.setBoneMatFromWorldMat(animMats, transform, bone);
|
||||
}
|
||||
|
||||
}
|
||||
#end
|
||||
}
|
79
leenkx/Sources/leenkx/logicnode/BoneIKNode.hx
Normal file
79
leenkx/Sources/leenkx/logicnode/BoneIKNode.hx
Normal file
@ -0,0 +1,79 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import leenkx.object.AnimationExtension;
|
||||
import iron.object.Object;
|
||||
import iron.object.BoneAnimation;
|
||||
import iron.math.Vec4;
|
||||
import iron.math.Mat4;
|
||||
|
||||
class BoneIKNode extends LogicNode {
|
||||
|
||||
public var property0: String; //2 Bone or FABRIK
|
||||
#if lnx_skin
|
||||
var object: Object;
|
||||
var boneName: String;
|
||||
var animMats: Array<Mat4>;
|
||||
var goal: Vec4;
|
||||
var pole: Vec4;
|
||||
var poleEnabled: Bool;
|
||||
var rollAngle: Float;
|
||||
var influence: Float;
|
||||
var layerMask: Null<Int>;
|
||||
var chainLength: Int;
|
||||
var maxIterartions: Int;
|
||||
var precision: Float;
|
||||
var animation: BoneAnimation;
|
||||
var ready = false;
|
||||
#end
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_skin
|
||||
|
||||
public function init(){
|
||||
|
||||
object = inputs[0].get();
|
||||
assert(Error, object != null, "The object input not be null");
|
||||
animation = object.getBoneAnimation(object.uid);
|
||||
assert(Error, animation != null, "The object does not have armatureanimation");
|
||||
ready = true;
|
||||
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
return function (animMats: Array<Mat4>) {
|
||||
|
||||
if(! ready) init();
|
||||
|
||||
inputs[1].get()(animMats);
|
||||
boneName = inputs[2].get();
|
||||
goal = inputs[3].get();
|
||||
poleEnabled = inputs[4].get();
|
||||
pole = inputs[5].get();
|
||||
rollAngle = inputs[6].get();
|
||||
influence = inputs[7].get();
|
||||
layerMask = inputs[8].get();
|
||||
|
||||
var bone = animation.getBone(boneName);
|
||||
|
||||
if(! poleEnabled) pole = null;
|
||||
|
||||
switch (property0) {
|
||||
case "2 Bone":
|
||||
AnimationExtension.solveTwoBoneIKBlend(animation, animMats, bone, goal, pole,
|
||||
rollAngle, influence, layerMask);
|
||||
case "FABRIK":
|
||||
chainLength = inputs[9].get();
|
||||
maxIterartions = inputs[10].get();
|
||||
precision = inputs[11].get();
|
||||
AnimationExtension.solveIKBlend(animation, animMats, bone, goal, precision, maxIterartions,
|
||||
chainLength, pole, rollAngle, influence, layerMask);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
}
|
21
leenkx/Sources/leenkx/logicnode/BooleanNode.hx
Normal file
21
leenkx/Sources/leenkx/logicnode/BooleanNode.hx
Normal file
@ -0,0 +1,21 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class BooleanNode extends LogicNode {
|
||||
|
||||
public var value: Bool;
|
||||
|
||||
public function new(tree: LogicTree, value = false) {
|
||||
super(tree);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (inputs.length > 0) return inputs[0].get();
|
||||
return value;
|
||||
}
|
||||
|
||||
override function set(value: Dynamic) {
|
||||
if (inputs.length > 0) inputs[0].set(value);
|
||||
else this.value = value;
|
||||
}
|
||||
}
|
13
leenkx/Sources/leenkx/logicnode/BranchNode.hx
Normal file
13
leenkx/Sources/leenkx/logicnode/BranchNode.hx
Normal file
@ -0,0 +1,13 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class BranchNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var b: Bool = inputs[1].get();
|
||||
b ? runOutput(0) : runOutput(1);
|
||||
}
|
||||
}
|
35
leenkx/Sources/leenkx/logicnode/CallFunctionNode.hx
Normal file
35
leenkx/Sources/leenkx/logicnode/CallFunctionNode.hx
Normal file
@ -0,0 +1,35 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
class CallFunctionNode extends LogicNode {
|
||||
|
||||
var result: Dynamic;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Dynamic = inputs[1].get();
|
||||
if (object == null) return;
|
||||
|
||||
var funName: String = inputs[2].get();
|
||||
var args: Array<Dynamic> = [];
|
||||
|
||||
for (i in 3...inputs.length) {
|
||||
args.push(inputs[i].get());
|
||||
}
|
||||
|
||||
var func = Reflect.field(object, funName);
|
||||
if (func != null) {
|
||||
result = Reflect.callMethod(object, func, args);
|
||||
}
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return result;
|
||||
}
|
||||
}
|
9
leenkx/Sources/leenkx/logicnode/CallGroupNode.hx
Normal file
9
leenkx/Sources/leenkx/logicnode/CallGroupNode.hx
Normal file
@ -0,0 +1,9 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class CallGroupNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
}
|
34
leenkx/Sources/leenkx/logicnode/CallHaxeStaticNode.hx
Normal file
34
leenkx/Sources/leenkx/logicnode/CallHaxeStaticNode.hx
Normal file
@ -0,0 +1,34 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class CallHaxeStaticNode extends LogicNode {
|
||||
|
||||
var result: Dynamic;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
var path: String = inputs[1].get();
|
||||
if (path != "") {
|
||||
var args: Array<Dynamic> = [];
|
||||
|
||||
for (i in 2...inputs.length) {
|
||||
args.push(inputs[i].get());
|
||||
}
|
||||
|
||||
var dotIndex = path.lastIndexOf(".");
|
||||
var classPath = path.substr(0, dotIndex);
|
||||
var classType = Type.resolveClass(classPath);
|
||||
var funName = path.substr(dotIndex + 1);
|
||||
result = Reflect.callMethod(classType, Reflect.field(classType, funName), args);
|
||||
}
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
return result;
|
||||
}
|
||||
}
|
31
leenkx/Sources/leenkx/logicnode/CallWASMNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/CallWASMNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
import iron.data.Data;
|
||||
import iron.data.Wasm;
|
||||
|
||||
class CallWASMNode extends LogicNode {
|
||||
public var result: Dynamic;
|
||||
public var property1: Bool;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
override function run(from: Int){
|
||||
var wasm = inputs[1].get();
|
||||
var funName = inputs[2].get();
|
||||
var args: Array<Dynamic> = [];
|
||||
|
||||
for (i in 3...inputs.length) {
|
||||
args.push(inputs[i].get());
|
||||
}
|
||||
|
||||
var func = Reflect.field(wasm.exports, funName);
|
||||
if (func != null) {
|
||||
result = Reflect.callMethod(wasm.exports, func, args);
|
||||
}
|
||||
runOutput(0);
|
||||
}
|
||||
override function get(from: Int): Dynamic {
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/CameraGetNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/CameraGetNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class CameraGetNode extends LogicNode {
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from:Int):Dynamic {
|
||||
return switch (from) {
|
||||
case 0: leenkx.renderpath.Postprocess.camera_uniforms[0];//Camera: F-Number
|
||||
case 1: leenkx.renderpath.Postprocess.camera_uniforms[1];//Camera: Shutter time
|
||||
case 2: leenkx.renderpath.Postprocess.camera_uniforms[2];//Camera: ISO
|
||||
case 3: leenkx.renderpath.Postprocess.camera_uniforms[3];//Camera: Exposure Compensation
|
||||
case 4: leenkx.renderpath.Postprocess.camera_uniforms[4];//Fisheye Distortion
|
||||
case 5: leenkx.renderpath.Postprocess.camera_uniforms[5];//DoF AutoFocus §§ If true, it ignores the DoF Distance setting
|
||||
case 6: leenkx.renderpath.Postprocess.camera_uniforms[6];//DoF Distance
|
||||
case 7: leenkx.renderpath.Postprocess.camera_uniforms[7];//DoF Focal Length mm
|
||||
case 8: leenkx.renderpath.Postprocess.camera_uniforms[8];//DoF F-Stop
|
||||
case 9: leenkx.renderpath.Postprocess.camera_uniforms[9];//Tonemapping Method
|
||||
case 10: leenkx.renderpath.Postprocess.camera_uniforms[10];//Distort
|
||||
case 11: leenkx.renderpath.Postprocess.camera_uniforms[11];//Film Grain
|
||||
case 12: leenkx.renderpath.Postprocess.camera_uniforms[12];//Sharpen
|
||||
case 13: leenkx.renderpath.Postprocess.camera_uniforms[13];//Vignette
|
||||
default: 0.0;
|
||||
}
|
||||
}
|
||||
}
|
27
leenkx/Sources/leenkx/logicnode/CameraSetNode.hx
Normal file
27
leenkx/Sources/leenkx/logicnode/CameraSetNode.hx
Normal file
@ -0,0 +1,27 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class CameraSetNode extends LogicNode {
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[0] = inputs[1].get();//Camera: F-Number
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[1] = inputs[2].get();//Camera: Shutter time
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[2] = inputs[3].get();//Camera: ISO
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[3] = inputs[4].get();//Camera: Exposure Compensation
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[4] = inputs[5].get();//Fisheye Distortion
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[5] = inputs[6].get();//DoF AutoFocus §§ If true, it ignores the DoF Distance setting
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[6] = inputs[7].get();//DoF Distance
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[7] = inputs[8].get();//DoF Focal Length mm
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[8] = inputs[9].get();//DoF F-Stop
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[9] = inputs[10].get();//Tonemapping Method
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[10] = inputs[11].get();//Distort
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[11] = inputs[12].get();//Film Grain
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[12] = inputs[13].get();//Sharpen
|
||||
leenkx.renderpath.Postprocess.camera_uniforms[13] = inputs[14].get();//Vignette
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/CanvasGetCheckboxNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/CanvasGetCheckboxNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetCheckboxNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function get(from: Int): Dynamic { // Null<Bool>
|
||||
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
if (canvas == null || !canvas.ready) return null;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
return canvas.getHandle(inputs[0].get()).selected;
|
||||
}
|
||||
catch (e: Dynamic) { return null; }
|
||||
}
|
||||
#end
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/CanvasGetInputTextNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/CanvasGetInputTextNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetInputTextNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function get(from: Int) {
|
||||
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
if (canvas == null || !canvas.ready) return null;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
return canvas.getHandle(inputs[0].get()).text;
|
||||
}
|
||||
catch (e: Dynamic) { return null; }
|
||||
}
|
||||
#end
|
||||
}
|
36
leenkx/Sources/leenkx/logicnode/CanvasGetLocationNode.hx
Normal file
36
leenkx/Sources/leenkx/logicnode/CanvasGetLocationNode.hx
Normal file
@ -0,0 +1,36 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetLocationNode extends LogicNode {
|
||||
|
||||
var x: Float;
|
||||
var y: Float;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e == null) return;
|
||||
|
||||
x = e.x;
|
||||
y = e.y;
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (from == 1) return x;
|
||||
else if (from == 2) return y;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
36
leenkx/Sources/leenkx/logicnode/CanvasGetPBNode.hx
Normal file
36
leenkx/Sources/leenkx/logicnode/CanvasGetPBNode.hx
Normal file
@ -0,0 +1,36 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetPBNode extends LogicNode {
|
||||
|
||||
var at: Int;
|
||||
var max: Int;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e == null) return;
|
||||
|
||||
at = canvas.getElement(element).progress_at;
|
||||
max = canvas.getElement(element).progress_total;
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (from == 1) return at;
|
||||
else if (from == 2) return max;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/CanvasGetPositionNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/CanvasGetPositionNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetPositionNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function get(from: Int): Dynamic { // Null<Int>
|
||||
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
if (canvas == null || !canvas.ready) return null;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
return canvas.getHandle(inputs[0].get()).position;
|
||||
}
|
||||
catch (e: Dynamic) { return null; }
|
||||
}
|
||||
#end
|
||||
}
|
33
leenkx/Sources/leenkx/logicnode/CanvasGetRotationNode.hx
Normal file
33
leenkx/Sources/leenkx/logicnode/CanvasGetRotationNode.hx
Normal file
@ -0,0 +1,33 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetRotationNode extends LogicNode {
|
||||
|
||||
var rad: Float;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e == null) return;
|
||||
|
||||
rad = e.rotation;
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (from == 1) return rad;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
36
leenkx/Sources/leenkx/logicnode/CanvasGetScaleNode.hx
Normal file
36
leenkx/Sources/leenkx/logicnode/CanvasGetScaleNode.hx
Normal file
@ -0,0 +1,36 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetScaleNode extends LogicNode {
|
||||
|
||||
var width: Int;
|
||||
var height: Int;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e == null) return;
|
||||
|
||||
height = e.height;
|
||||
width = e.width;
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
if (from == 1) return height;
|
||||
else if (from == 2) return width;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/CanvasGetSliderNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/CanvasGetSliderNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetSliderNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function get(from: Int): Dynamic { // Null<Float>
|
||||
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
if (canvas == null || !canvas.ready) return null;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
return canvas.getHandle(inputs[0].get()).value;
|
||||
}
|
||||
catch (e: Dynamic) { return null; }
|
||||
}
|
||||
#end
|
||||
}
|
28
leenkx/Sources/leenkx/logicnode/CanvasGetTextNode.hx
Normal file
28
leenkx/Sources/leenkx/logicnode/CanvasGetTextNode.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetTextNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function get(from: Int) {
|
||||
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
if (canvas == null || !canvas.ready) return null;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
return canvas.getElement(inputs[0].get()).text;
|
||||
}
|
||||
catch (e: Dynamic) { return null; }
|
||||
}
|
||||
#end
|
||||
}
|
30
leenkx/Sources/leenkx/logicnode/CanvasGetVisibleNode.hx
Normal file
30
leenkx/Sources/leenkx/logicnode/CanvasGetVisibleNode.hx
Normal file
@ -0,0 +1,30 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetVisibleNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function get(from: Int): Dynamic { // Null<Bool>
|
||||
var element: String = inputs[0].get();
|
||||
|
||||
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
if (canvas == null || !canvas.ready) return null;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
return canvas.getElement(element).visible;
|
||||
}
|
||||
catch (e: Dynamic) { return null; }
|
||||
}
|
||||
#end
|
||||
}
|
25
leenkx/Sources/leenkx/logicnode/CanvasSetAssetNode.hx
Normal file
25
leenkx/Sources/leenkx/logicnode/CanvasSetAssetNode.hx
Normal file
@ -0,0 +1,25 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetAssetNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
var asset = Std.string(inputs[2].get());
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e != null) e.asset = asset;
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
42
leenkx/Sources/leenkx/logicnode/CanvasSetCheckBoxNode.hx
Normal file
42
leenkx/Sources/leenkx/logicnode/CanvasSetCheckBoxNode.hx
Normal file
@ -0,0 +1,42 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetCheckBoxNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
var element: String;
|
||||
var value: Bool;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
|
||||
// This Try/Catch hacks around an issue where the handles are
|
||||
// not created yet, even though canvas.ready is true.
|
||||
try {
|
||||
canvas.getHandle(element).selected = value;
|
||||
tree.removeUpdate(update);
|
||||
}
|
||||
catch (e: Dynamic) {}
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
element = inputs[1].get();
|
||||
value = inputs[2].get();
|
||||
|
||||
canvas = CanvasScript.getActiveCanvas();
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
#end
|
||||
}
|
39
leenkx/Sources/leenkx/logicnode/CanvasSetColorNode.hx
Normal file
39
leenkx/Sources/leenkx/logicnode/CanvasSetColorNode.hx
Normal file
@ -0,0 +1,39 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import kha.Color;
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetColorNode extends LogicNode {
|
||||
|
||||
public var property0: String; // Attribute
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var elementName = inputs[1].get();
|
||||
var color: iron.math.Vec4 = inputs[2].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var element = canvas.getElement(elementName);
|
||||
var c = Color.fromFloats(color.x, color.y, color.z, color.w);
|
||||
|
||||
if (element != null) {
|
||||
switch (property0) {
|
||||
case "color": element.color = c;
|
||||
case "color_text": element.color_text = c;
|
||||
case "color_hover": element.color_hover = c;
|
||||
case "color_press": element.color_press = c;
|
||||
case "color_progress": element.color_progress = c;
|
||||
}
|
||||
}
|
||||
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetInputTextFocusNode extends LogicNode {
|
||||
|
||||
var canvas: CanvasScript;
|
||||
var element: String;
|
||||
var focus: Bool;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
var e = canvas.getHandle(element);
|
||||
if (e == null) return;
|
||||
|
||||
canvas.setCanvasInputTextFocus(e, focus);
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
element = inputs[1].get();
|
||||
focus = inputs[2].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
|
||||
}
|
||||
#end
|
||||
}
|
25
leenkx/Sources/leenkx/logicnode/CanvasSetInputTextNode.hx
Normal file
25
leenkx/Sources/leenkx/logicnode/CanvasSetInputTextNode.hx
Normal file
@ -0,0 +1,25 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetInputTextNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
var text = Std.string(inputs[2].get());
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getHandle(element);
|
||||
if (e != null) e.text = text;
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
29
leenkx/Sources/leenkx/logicnode/CanvasSetLocationNode.hx
Normal file
29
leenkx/Sources/leenkx/logicnode/CanvasSetLocationNode.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetLocationNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
var newX = inputs[2].get();
|
||||
var newY = inputs[3].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e != null) {
|
||||
e.x = newX;
|
||||
e.y = newY;
|
||||
}
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
29
leenkx/Sources/leenkx/logicnode/CanvasSetPBNode.hx
Normal file
29
leenkx/Sources/leenkx/logicnode/CanvasSetPBNode.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetPBNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
var newAt = inputs[2].get();
|
||||
var newMax = inputs[3].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e != null) {
|
||||
e.progress_at = newAt;
|
||||
e.progress_total = newMax;
|
||||
}
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import leenkx.trait.internal.CanvasScript;
|
||||
import kha.Color;
|
||||
import iron.math.Vec4;
|
||||
|
||||
@:deprecated("The 'Set Canvas Progress Bar Color' node is deprecated and will be removed in future SDK versions. Please use 'Set Canvas Color' instead.")
|
||||
class CanvasSetProgressBarColorNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if lnx_ui
|
||||
override function run(from: Int) {
|
||||
var element = inputs[1].get();
|
||||
var color: Vec4 = inputs[2].get();
|
||||
|
||||
var canvas = CanvasScript.getActiveCanvas();
|
||||
canvas.notifyOnReady(() -> {
|
||||
var e = canvas.getElement(element);
|
||||
if (e != null) e.color_progress = Color.fromFloats(color.x, color.y, color.z, color.w);
|
||||
runOutput(0);
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user