So water + sand = third domain.
Anyway I'm getting a syntax error and don't know why.
Code: Select all
# Get the domain "water_domain" and its particles
dyversoWaterDomain = scene.get_DY_Domain("water_domain")
dyversoSandDomain = scene.get_DY_Domain("sand_domain")
dyversoGelDomain = scene.get_DY_Domain("gel_domain")
dyversoWaterEmitter = scene.get_DY_Emitter("water_emitter")
dyversoSandEmitter = scene.get_DY_Emitter("sand_emitter")
domainWaterParticles = dyversoWaterDomain.getParticles()
domainSandParticles = dyversoSandDomain.getParticles()
searchRadius = 0.2
#create voxelization
dyversoWaterDomain.createVoxelization()
# Loop through every water particle, read out its position
for particle in domainWaterParticles:
particlePos = particle.getPosition()
# Search for neighbors at the particle's position and within the given radius
neighbors = domainWaterParticles.getNeighbors(particlePos, searchRadius)
#loop through the neighbors to see if they are sand
for particle in neighbors:
whichEmitter = particle.getEmitterId()
if (whichEmitter == dyversoSandEmitter.getId()):
#transfer the sand particle to the gel domain if it is close enough to water
dyversoGelDomain.addParticle(particle.getPosition(), particle.getVelocity())
dyversoSandDomain.removeParticle(particle.getId())
I tried to attach a scene file but the website says the board attachment quota has been reached.