...
Code Block | ||
---|---|---|
| ||
# Initialize the required values # Get the domain "HY_Domain01" and its particles, get the emitter "HY_Emitter01" # Read out the emitter's "Speed" parameter and the current number of particles 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 is greater than current emitter speed and smallerless than the given speed limit "maxSpeed" if (averageVelocity > emitterSpeed and averageVelocity <= maxSpeed): hybridoEmitter.setParameter("Speed", averageVelocity) |
...