Commit ccfe2e66 authored by Rafael Pezzi's avatar Rafael Pezzi
Browse files

Removing arguments from driver createParticles

    genDriver configured on construction.
parent 21dbf452
...@@ -31,13 +31,13 @@ renderAnimation = True # True ...@@ -31,13 +31,13 @@ renderAnimation = True # True
saveBlenderFile = False # False saveBlenderFile = False # False
# Create and configure animation driver # Create and configure animation driver
n_particles = 500 # Event Multiplicity n_particles = 100 # Event Multiplicity
driver = genDriver("GaussianGenerator_N"+str(n_particles)+"_") driver = genDriver("GaussianGenerator",n_particles,3.0) # Simple genDriver takes two parameters: number of particles and Gaussian width
driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent) driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent)
### Build scene ### Build scene
init() # Cleanup, addCameras, addALICE_TPC init() # Cleanup, addCameras, addALICE_TPC
particles = driver.createParticles(n_particles,3.0) # Simple genDriver takes two parameters: number of particles and Gaussian width particles = driver.getParticles()
blender_particles = createSceneParticles(particles) # Create blender objects - one sphere per particle blender_particles = createSceneParticles(particles) # Create blender objects - one sphere per particle
#Animate scene using driver #Animate scene using driver
......
...@@ -10,7 +10,7 @@ exec(compile(open(filename).read(), filename, 'exec')) ...@@ -10,7 +10,7 @@ exec(compile(open(filename).read(), filename, 'exec'))
class animationDriver: class animationDriver:
def __init__(self,name): def __init__(self,name):
self.name=name self.name = name
def configure(self, renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent=100): def configure(self, renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent=100):
self.renderCamera=renderCamera self.renderCamera=renderCamera
self.duration=duration # total video duration in seconds self.duration=duration # total video duration in seconds
...@@ -50,19 +50,25 @@ class animationDriver: ...@@ -50,19 +50,25 @@ class animationDriver:
bcsr.filepath = "/tmp/blender/"+output_prefix bcsr.filepath = "/tmp/blender/"+output_prefix
class genDriver(animationDriver): # A driver for particle generators class genDriver(animationDriver): # A driver for particle generators
def createParticles(self, N_particles, par1, x = 0, y = 0, z = 0): # Create particles at given position and return them in a list def __init__(self,name,N_particles, par1):
self.name = name+"_N"+str(n_particles)+"_"
self.N_particles = N_particles
self.par1 = par1
def getParticles(self, x = 0, y = 0, z = 0): # Create particles at given position and return them in a list
particles=[] particles=[]
#loop over particles #loop over particles
for i in range(0, N_particles): for i in range(0, self.N_particles):
charge = random.choice([+1,-1]) charge = random.choice([+1,-1])
part = ParticlePropagator(i,x,y,z) part = ParticlePropagator(i,x,y,z)
part.SetMagneticField() part.SetMagneticField()
part.SetProperties(random.gauss(0,par1),random.gauss(0,par1),random.gauss(0,par1),charge) part.SetProperties(random.gauss(0,self.par1),random.gauss(0,self.par1),random.gauss(0,self.par1),charge)
particles.append(part) particles.append(part)
return particles; return particles;
class dataDriver(animationDriver): # A driver for data from files. Under construction class dataDriver(animationDriver): # A driver for data from files. Under construction
def createParticles(self, filename): # Create particles acording to parameters from file def __init__(self,name,filename):
self.name = name+"_"+filename+"_"
def getParticles(self): # Create particles acording to parameters from file
# TODO: load data into vectors # TODO: load data into vectors
particles=[] particles=[]
x = y = z = 0; x = y = z = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment