# Name :pressure_multi_spray # Description: Creates Dumb Particle spray on collision based on pressure of the colliding particle in multiple spray emiters. # # Author : Richard Sutherland based off of original script by Joshua AM def onSimulationStep(): pass def onSimulationFrame(): from random import random #Emitters, add/uncomment as needed. water = scene.getEmitter("water") #Name of the main fluid emitter. spray = scene.getEmitter("spray") #name of the spray emitter #sprayb = scene.getEmitter("sprayb") #name of the spray emitter #sprayc = scene.getEmitter("sprayc") #name of the spray emitter #sprayd = scene.getEmitter("sprayd") #name of the spray emitter #spraye = scene.getEmitter("spraye") #name of the spray emitter #sprayf = scene.getEmitter("sprayf") #name of the spray emitter #sprayg = scene.getEmitter("sprayg") #name of the spray emitter #sprayh = scene.getEmitter("sprayh") #name of the spray emitter #Control Variables spray_pressure=10000 #The maximum pressure of the colliding particle to create spray (More = Less Spray) spray_parts = 2 #number of spray particles per collision/emitter coll_skip=4 #how many collisions to skip spray_rand=15 #how random the direction is, this depends on the speed of the particles. If you expect them to be #going very fast, or want a wider cone of spray then increase this spray_speed_rand=3 #how much extra speed is added to the particles in the existing velocity vector #housekeeping h_spray_rand=spray_rand/2 part_count=0 #loop through Particles find collision's and emit spray. particles = water.getParticlesColliding() for particle in particles: part_count=part_count+1 if(part_count % coll_skip == 0): press=particle.getPressure() if(press < spray_pressure): pos = particle.getPosition() vel = particle.getVelocity() tx=vel.getX() ty=vel.getY() tz=vel.getZ() for i in range(spray_parts): vel.setX(tx * (1 + (random() * spray_speed_rand)) + (random() * spray_rand) -h_spray_rand) vel.setY(ty * (1 + (random() * spray_speed_rand)) + (random() * spray_rand) -h_spray_rand) vel.setZ(tz * (1 + (random() * spray_speed_rand)) + (random() * spray_rand) -h_spray_rand) spray.addParticle(pos, vel) ##uncomment / copy one of these for EACH spay emitter. #for i in range(spray_parts): # vel.setX(tx * (1 + (random() * spray_speed_rand)) + (random() * spray_rand) -h_spray_rand) # vel.setY(ty * (1 + (random() * spray_speed_rand)) + (random() * spray_rand) -h_spray_rand) # vel.setZ(tz * (1 + (random() * spray_speed_rand)) + (random() * spray_rand) -h_spray_rand) ##SET THE NAME BELOW TO sprayc, d, e, etc # sprayb.addParticle(pos, vel) def onSimulationBegin(): pass def onSimulationEnd(): pass def onChangeToFrame(): pass