Upload files to "leenkx/Sources/leenkx/logicnode"
This commit is contained in:
		
							
								
								
									
										99
									
								
								leenkx/Sources/leenkx/logicnode/AddParticleToObjectNode.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								leenkx/Sources/leenkx/logicnode/AddParticleToObjectNode.hx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,99 @@ | ||||
| package leenkx.logicnode; | ||||
|  | ||||
| import iron.data.SceneFormat.TSceneFormat; | ||||
| import iron.data.Data; | ||||
| import iron.object.Object; | ||||
|  | ||||
| class AddParticleToObjectNode extends LogicNode { | ||||
|  | ||||
| 	public var property0: String; | ||||
|  | ||||
| 	public function new(tree: LogicTree) { | ||||
| 		super(tree); | ||||
| 	} | ||||
|  | ||||
| 	override function run(from: Int) { | ||||
| 		#if lnx_particles | ||||
|  | ||||
| 		if (property0 == 'Scene Active'){		 | ||||
| 			var objFrom: Object = inputs[1].get(); | ||||
| 			var slot: Int = inputs[2].get(); | ||||
| 			var objTo: Object = inputs[3].get(); | ||||
| 	 | ||||
| 			if (objFrom == null || objTo == null) return; | ||||
| 	 | ||||
| 			var mobjFrom = cast(objFrom, iron.object.MeshObject); | ||||
| 	 | ||||
| 			var psys = mobjFrom.particleSystems != null ? mobjFrom.particleSystems[slot] :  | ||||
| 				mobjFrom.particleOwner != null && mobjFrom.particleOwner.particleSystems != null ? mobjFrom.particleOwner.particleSystems[slot] : null; | ||||
|  | ||||
| 			if (psys == null) return; | ||||
| 	 | ||||
| 			var mobjTo = cast(objTo, iron.object.MeshObject); | ||||
| 	 | ||||
| 			mobjTo.setupParticleSystem(iron.Scene.active.raw.name, {name: 'LnxPS', seed: 0, particle: psys.r.name}); | ||||
| 			 | ||||
| 			mobjTo.render_emitter = inputs[4].get(); | ||||
|  | ||||
| 			iron.Scene.active.spawnObject(psys.data.raw.instance_object, null, function(o: Object) { | ||||
| 				if (o != null) { | ||||
| 					var c: iron.object.MeshObject = cast o; | ||||
| 					if (mobjTo.particleChildren == null) mobjTo.particleChildren = []; | ||||
| 					mobjTo.particleChildren.push(c); | ||||
| 					c.particleOwner = mobjTo; | ||||
| 					c.particleIndex = mobjTo.particleChildren.length - 1; | ||||
| 				} | ||||
| 			}); | ||||
| 	 | ||||
| 			var oslot: Int = mobjTo.particleSystems.length-1; | ||||
| 			var opsys = mobjTo.particleSystems[oslot]; | ||||
| 			opsys.setupGeomGpu(mobjTo.particleChildren[oslot], mobjTo); | ||||
| 		 | ||||
| 		} else { | ||||
| 			var sceneName: String = inputs[1].get(); | ||||
| 			var objectName: String = inputs[2].get(); | ||||
| 			var slot: Int = inputs[3].get(); | ||||
|  | ||||
| 			var mobjTo: Object = inputs[4].get(); | ||||
| 			var mobjTo = cast(mobjTo, iron.object.MeshObject); | ||||
|  | ||||
| 			#if lnx_json | ||||
| 				sceneName += ".json"; | ||||
| 			#elseif lnx_compress | ||||
| 				sceneName += ".lz4"; | ||||
| 			#end | ||||
|  | ||||
| 			Data.getSceneRaw(sceneName, (rawScene: TSceneFormat) -> { | ||||
|  | ||||
| 			for (obj in rawScene.objects) { | ||||
| 				if (obj.name == objectName) { | ||||
| 					mobjTo.setupParticleSystem(sceneName, obj.particle_refs[slot]); | ||||
| 					mobjTo.render_emitter = inputs[5].get();					 | ||||
|  | ||||
| 					iron.Scene.active.spawnObject(rawScene.particle_datas[slot].instance_object, null, function(o: Object) { | ||||
| 						if (o != null) { | ||||
| 							var c: iron.object.MeshObject = cast o; | ||||
| 							if (mobjTo.particleChildren == null) mobjTo.particleChildren = []; | ||||
| 							mobjTo.particleChildren.push(c); | ||||
| 							c.particleOwner = mobjTo; | ||||
| 							c.particleIndex = mobjTo.particleChildren.length - 1; | ||||
| 						} | ||||
| 					}, true, rawScene); | ||||
|  | ||||
| 					var oslot: Int = mobjTo.particleSystems.length-1; | ||||
| 					var opsys = mobjTo.particleSystems[oslot]; | ||||
| 					opsys.setupGeomGpu(mobjTo.particleChildren[oslot], mobjTo); | ||||
|  | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			}); | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		#end | ||||
|  | ||||
| 		runOutput(0); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										66
									
								
								leenkx/Sources/leenkx/logicnode/GetParticleDataNode.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								leenkx/Sources/leenkx/logicnode/GetParticleDataNode.hx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,66 @@ | ||||
| package leenkx.logicnode; | ||||
|  | ||||
| import iron.object.Object; | ||||
|  | ||||
| class GetParticleDataNode extends LogicNode { | ||||
|  | ||||
| 	public function new(tree: LogicTree) { | ||||
| 		super(tree); | ||||
| 	} | ||||
|  | ||||
| 	override function get(from: Int): Dynamic { | ||||
| 		var object: Object = inputs[0].get(); | ||||
| 		var slot: Int = inputs[1].get(); | ||||
|  | ||||
| 		if (object == null) return null; | ||||
|  | ||||
| 	#if lnx_particles | ||||
|  | ||||
| 		var mo = cast(object, iron.object.MeshObject); | ||||
|  | ||||
| 		var psys = mo.particleSystems != null ? mo.particleSystems[slot] :  | ||||
| 			mo.particleOwner != null && mo.particleOwner.particleSystems != null ? mo.particleOwner.particleSystems[slot] : null; | ||||
|  | ||||
| 		if (psys == null) return null; | ||||
|  | ||||
| 		return switch (from) { | ||||
| 			case 0: | ||||
| 				psys.r.name; | ||||
| 			case 1: | ||||
| 				psys.r.particle_size; | ||||
| 			case 2: | ||||
| 				psys.r.frame_start; | ||||
| 			case 3: | ||||
| 				psys.r.frame_end; | ||||
| 			case 4: | ||||
| 				psys.lifetime; | ||||
| 			case 5: | ||||
| 				psys.r.lifetime; | ||||
| 			case 6: | ||||
| 				psys.r.emit_from; | ||||
| 			case 7: | ||||
| 				new iron.math.Vec3(psys.alignx*2, psys.aligny*2, psys.alignz*2); | ||||
| 			case 8: | ||||
| 				psys.r.factor_random; | ||||
| 			case 9: | ||||
| 				new iron.math.Vec3(psys.gx, psys.gy, psys.gz); | ||||
| 			case 10: | ||||
| 				psys.r.weight_gravity; | ||||
| 			case 11: | ||||
| 				psys.speed; | ||||
| 			case 12: | ||||
| 				psys.time; | ||||
| 			case 13: | ||||
| 				psys.lap; | ||||
| 			case 14: | ||||
| 				psys.lapTime; | ||||
| 			case 15: | ||||
| 				psys.count; | ||||
| 			default:  | ||||
| 				null; | ||||
| 		} | ||||
| 	#end | ||||
|  | ||||
| 		return null; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										38
									
								
								leenkx/Sources/leenkx/logicnode/GetParticleNode.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								leenkx/Sources/leenkx/logicnode/GetParticleNode.hx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| package leenkx.logicnode; | ||||
|  | ||||
| import iron.object.Object; | ||||
|  | ||||
| class GetParticleNode extends LogicNode { | ||||
|  | ||||
| 	public function new(tree: LogicTree) { | ||||
| 		super(tree); | ||||
| 	} | ||||
|  | ||||
| 	override function get(from: Int): Dynamic { | ||||
| 		var object: Object = inputs[0].get(); | ||||
|  | ||||
| 		if (object == null) return null; | ||||
|  | ||||
| 	#if lnx_particles | ||||
|  | ||||
| 		var mo = cast(object, iron.object.MeshObject); | ||||
| 	 | ||||
| 		switch (from) { | ||||
| 			case 0: | ||||
| 				var names: Array<String> = []; | ||||
| 				if (mo.particleSystems != null) | ||||
| 					for (psys in mo.particleSystems) | ||||
| 						names.push(psys.r.name); | ||||
| 				return names; | ||||
| 			case 1: | ||||
| 				return mo.particleSystems != null ? mo.particleSystems.length : 0; | ||||
| 			case 2: | ||||
| 				return mo.render_emitter; | ||||
| 			default:  | ||||
| 				null; | ||||
| 		} | ||||
| 	#end | ||||
|  | ||||
| 		return null; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,64 @@ | ||||
| package leenkx.logicnode; | ||||
|  | ||||
| import iron.object.Object; | ||||
|  | ||||
| class RemoveParticleFromObjectNode extends LogicNode { | ||||
|  | ||||
| 	public var property0: String; | ||||
|  | ||||
| 	public function new(tree: LogicTree) { | ||||
| 		super(tree); | ||||
| 	} | ||||
|  | ||||
| 	override function run(from: Int) { | ||||
| 		#if lnx_particles | ||||
| 		var object: Object = inputs[1].get(); | ||||
|  | ||||
| 		if (object == null) return; | ||||
|  | ||||
| 		var mo = cast(object, iron.object.MeshObject); | ||||
|  | ||||
| 		if (mo.particleSystems == null) return; | ||||
|  | ||||
| 		if (property0 == 'All'){ | ||||
| 			mo.particleSystems = null; | ||||
| 			for (c in mo.particleChildren) c.remove(); | ||||
| 			mo.particleChildren = null; | ||||
| 			mo.particleOwner = null; | ||||
| 			mo.render_emitter = true; | ||||
| 		}  | ||||
| 		else { | ||||
| 			 | ||||
| 			var slot: Int = -1; | ||||
| 			if (property0 == 'Name'){ | ||||
| 				var name: String = inputs[2].get(); | ||||
| 				for (i => psys in mo.particleSystems){ | ||||
| 					if (psys.r.name == name){ slot = i; break; } | ||||
| 				} | ||||
| 			}  | ||||
| 			else slot = inputs[2].get(); | ||||
| 				 | ||||
| 			if (mo.particleSystems.length > slot){ | ||||
| 				for (i in slot+1...mo.particleSystems.length){ | ||||
| 					var mi = cast(mo.particleChildren[i], iron.object.MeshObject); | ||||
| 					mi.particleIndex = mi.particleIndex - 1; | ||||
| 				} | ||||
| 				mo.particleSystems.splice(slot, 1); | ||||
| 				mo.particleChildren[slot].remove(); | ||||
| 				mo.particleChildren.splice(slot, 1); | ||||
| 			} | ||||
|  | ||||
| 			if (slot == 0){ | ||||
| 				mo.particleSystems = null; | ||||
| 				mo.particleChildren = null; | ||||
| 				mo.particleOwner = null; | ||||
| 				mo.render_emitter = true; | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		#end | ||||
|  | ||||
| 		runOutput(0); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										75
									
								
								leenkx/Sources/leenkx/logicnode/SetParticleDataNode.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								leenkx/Sources/leenkx/logicnode/SetParticleDataNode.hx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,75 @@ | ||||
| package leenkx.logicnode; | ||||
|  | ||||
| import iron.object.Object; | ||||
|  | ||||
| class SetParticleDataNode extends LogicNode { | ||||
|  | ||||
| 	public var property0: String; | ||||
|  | ||||
| 	public function new(tree: LogicTree) { | ||||
| 		super(tree); | ||||
| 	} | ||||
|  | ||||
| 	override function run(from: Int) { | ||||
| 		#if lnx_particles | ||||
| 		var object: Object = inputs[1].get(); | ||||
| 		var slot: Int = inputs[2].get(); | ||||
|  | ||||
| 		if (object == null) return; | ||||
|  | ||||
| 		var mo = cast(object, iron.object.MeshObject); | ||||
|  | ||||
| 		var psys = mo.particleSystems != null ? mo.particleSystems[slot] :  | ||||
| 			mo.particleOwner != null && mo.particleOwner.particleSystems != null ? mo.particleOwner.particleSystems[slot] : null;		if (psys == null) return; | ||||
|  | ||||
| 		switch (property0) { | ||||
| 			case 'Particle Size': | ||||
| 				psys.r.particle_size = inputs[3].get(); | ||||
| 			case 'Frame Start': | ||||
| 				psys.r.frame_start = inputs[3].get(); | ||||
| 				psys.animtime = (psys.r.frame_end - psys.r.frame_start) / psys.frameRate; | ||||
| 				psys.spawnRate = ((psys.r.frame_end - psys.r.frame_start) / psys.count) / psys.frameRate; | ||||
| 			case 'Frame End': | ||||
| 				psys.r.frame_end = inputs[3].get(); | ||||
| 				psys.animtime = (psys.r.frame_end - psys.r.frame_start) / psys.frameRate; | ||||
| 				psys.spawnRate = ((psys.r.frame_end - psys.r.frame_start) / psys.count) / psys.frameRate; | ||||
| 			case 'Lifetime': | ||||
| 				psys.lifetime = inputs[3].get() / psys.frameRate; | ||||
| 			case 'Lifetime Random': | ||||
| 				psys.r.lifetime_random = inputs[3].get(); | ||||
| 			case 'Emit From': | ||||
| 				var emit_from: Int = inputs[3].get(); | ||||
| 				if (emit_from == 0 || emit_from == 1 || emit_from == 2) { | ||||
| 					psys.r.emit_from = emit_from; | ||||
| 					psys.setupGeomGpu(mo.particleChildren != null ? mo.particleChildren[slot] : cast(iron.Scene.active.getChild(psys.data.raw.instance_object), iron.object.MeshObject), mo); | ||||
| 				} | ||||
| 			case 'Velocity': | ||||
| 				var vel: iron.math.Vec3 = inputs[3].get(); | ||||
| 				psys.alignx = vel.x / 2; | ||||
| 				psys.aligny = vel.y / 2; | ||||
| 				psys.alignz = vel.z / 2; | ||||
| 			case 'Velocity Random': | ||||
| 				psys.r.factor_random = inputs[3].get(); | ||||
| 			case 'Weight Gravity': | ||||
| 				psys.r.weight_gravity = inputs[3].get(); | ||||
| 				if (iron.Scene.active.raw.gravity != null) { | ||||
| 					psys.gx = iron.Scene.active.raw.gravity[0] * psys.r.weight_gravity; | ||||
| 					psys.gy = iron.Scene.active.raw.gravity[1] * psys.r.weight_gravity; | ||||
| 					psys.gz = iron.Scene.active.raw.gravity[2] * psys.r.weight_gravity; | ||||
| 				} | ||||
| 				else { | ||||
| 					psys.gx = 0; | ||||
| 					psys.gy = 0; | ||||
| 					psys.gz = -9.81 * psys.r.weight_gravity; | ||||
| 				} | ||||
| 			case 'Speed': | ||||
| 				psys.speed = inputs[3].get(); | ||||
| 			default:  | ||||
| 				null; | ||||
| 		} | ||||
|  | ||||
| 		#end | ||||
|  | ||||
| 		runOutput(0); | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user