...
Code Block | ||
---|---|---|
| ||
hybridoDomain = scene.get_HY_GridDomain("HY_Domain01")
hybridoEmitter = scene.get_HY_Emitter("HY_Emitter01")
hybridoParticles = hybridoDomain.getParticles()
emitterSpeed = hybridoEmitter.getParameter("@ Speed")
numOfParticles = len(hybridoParticles)
currentVelocity = 0.0
maxSpeed = 5.0
# Sum up all velocities
for particle in hybridoParticles:
currentVelocity += particle.getVelocity().module()
# Calculate average velocity and avoid illegal division by zero:
if (numOfParticles > 0):
averageVelocity = currentVelocity / float(numOfParticles)
# Check, if average velocity greater than current emitter speed and smaller than the given speed limit "maxSpeed"
if (averageVelocity > emitterSpeed and averageVelocity <= maxSpeed):
hybridoEmitter.setParameter("@ Speed", averageVelocity) |
...