Commit 1f149e18 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬
Browse files

Set default background to black and add option to scale particle radius

parent 73859e02
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# animate_particles.py - Animate HEP events # animate_particles.py - Animate HEP events
# #
# For console only rendering (example): # For console only rendering (example):
# $ blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=1 \ # $ blender -noaudio --background -P animate_particles.py -- -radius=1.2 -duration=1 \
# -datafile="esd-detail.dat" -n_event=0 -simulated_t=0.02 -fps=24 -resolution=100 -transparency=1.2 -stamp_note="Texto no canto"\ # -datafile="esd-detail.dat" -n_event=0 -simulated_t=0.02 -fps=24 -resolution=100 -transparency=1.2 -stamp_note="Texto no canto"\
# -its=1 -tpc=0 -trd=1 -detailed_tpc=1 -emcal=0 -blendersave=0 -tpc_blender_path="/home/files/blender"\ # -its=1 -tpc=0 -trd=1 -detailed_tpc=1 -emcal=0 -blendersave=0 -tpc_blender_path="/home/files/blender"\
# -output_path="/tmp/blender" -bgshade=0.05 # -output_path="/tmp/blender" -bgshade=0.05
...@@ -55,7 +55,7 @@ filename = os.path.join(os.path.basename(bpy.data.filepath), "drivers.py") ...@@ -55,7 +55,7 @@ filename = os.path.join(os.path.basename(bpy.data.filepath), "drivers.py")
exec(compile(open(filename).read(), filename, 'exec')) exec(compile(open(filename).read(), filename, 'exec'))
# Set animation parameters # Set animation parameters
r_part = float(args.r_part) # Particle radius r_part = float(args.r_part) # Particle radius scale
n_event = str(args.n_event) # Event number for video name n_event = str(args.n_event) # Event number for video name
simulated_t = float(args.simulated_t) # in microsseconds simulated_t = float(args.simulated_t) # in microsseconds
duration = int(args.duration) # in seconds duration = int(args.duration) # in seconds
...@@ -89,7 +89,7 @@ driver.configure(duration, fps, simulated_t, outputPath, fileIdentifier, resolut ...@@ -89,7 +89,7 @@ driver.configure(duration, fps, simulated_t, outputPath, fileIdentifier, resolut
### Build scene ### Build scene
init(stamp_note,transp_par,detectors,tpc_blender_path,bgshade) # Cleanup, addCameras, addALICE_TPC, Set background init(stamp_note,transp_par,detectors,tpc_blender_path,bgshade) # Cleanup, addCameras, addALICE_TPC, Set background
particles = driver.getParticles() particles = driver.getParticles()
blender_particles, blender_tracks = createSceneParticles(particles,createTracks = True) # Create blender objects - one sphere per particle blender_particles, blender_tracks = createSceneParticles(particles,r_part,createTracks = True) # Create blender objects - one sphere per particle
#Animate scene using driver #Animate scene using driver
animate(blender_particles,particles,driver) animate(blender_particles,particles,driver)
......
...@@ -279,7 +279,7 @@ def addCameras(): ...@@ -279,7 +279,7 @@ def addCameras():
# Function that creates Blender Objects from input list of particles. # Function that creates Blender Objects from input list of particles.
## Returns a list of blender objects ## Returns a list of blender objects
def createSceneParticles(particles, createTracks = False): def createSceneParticles(particles, r_part=1, createTracks = False):
# Associate particles and colors # Associate particles and colors
particle_types = ["Electron","Pion","Muon","Proton","Kaon","Unknown"] particle_types = ["Electron","Pion","Muon","Proton","Kaon","Unknown"]
clRed = (1, 0, 0) clRed = (1, 0, 0)
...@@ -302,6 +302,13 @@ def createSceneParticles(particles, createTracks = False): ...@@ -302,6 +302,13 @@ def createSceneParticles(particles, createTracks = False):
# Create blender spheres (particles) # Create blender spheres (particles)
blender_particles=[] blender_particles=[]
n_particles=len(particles) n_particles=len(particles)
# Define particle radius based on multiplicity
if n_particles > 15000:
r_part=0.01*r_part
else:
r_part=0.05-(0.04/15000)*n_particles*r_part
for particle in particles: for particle in particles:
this_type=particle.p_type this_type=particle.p_type
print("Adding Sphere - Particle " + str(len(blender_particles)+1)+" of "+str(n_particles)+" - "+this_type) print("Adding Sphere - Particle " + str(len(blender_particles)+1)+" of "+str(n_particles)+" - "+this_type)
...@@ -328,7 +335,7 @@ def createSceneParticles(particles, createTracks = False): ...@@ -328,7 +335,7 @@ def createSceneParticles(particles, createTracks = False):
curveTrack.resolution_u = 2 curveTrack.resolution_u = 2
curveTrack.fill_mode = 'FULL' curveTrack.fill_mode = 'FULL'
curveTrack.bevel_depth = 0.02 curveTrack.bevel_depth = 0.4*r_part # Tracks are 40% the thickness of particles
curveTrack.bevel_resolution = 3 curveTrack.bevel_resolution = 3
......
...@@ -48,7 +48,7 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then ...@@ -48,7 +48,7 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
fi fi
OPTIONS=c:hdau:m:n:t:r: OPTIONS=c:hdau:m:n:t:r:
LONGOPTS=cameras:,mosaic,resolution:,fps:,transparency:,duration:,maxparticles:,\ LONGOPTS=cameras:,mosaic,resolution:,fps:,transparency:,duration:,radius:,maxparticles:,\
minparticles:,numberofevents:,minavgpz:,minavgpt:,help,download,sample,url:,its,\ minparticles:,numberofevents:,minavgpz:,minavgpt:,help,download,sample,url:,its,\
tpc,detailedtpc,trd,emcal,blendersave,picpct:,bgshade: tpc,detailedtpc,trd,emcal,blendersave,picpct:,bgshade:
...@@ -71,6 +71,7 @@ eval set -- "$PARSED" ...@@ -71,6 +71,7 @@ eval set -- "$PARSED"
CAMERAS=Overview CAMERAS=Overview
MOSAIC=false MOSAIC=false
DURATION=10 DURATION=10
RADIUS=1
RESOLUTION=100 RESOLUTION=100
FPS=24 FPS=24
TRANSPARENCY=1 TRANSPARENCY=1
...@@ -90,7 +91,7 @@ TRD=1 ...@@ -90,7 +91,7 @@ TRD=1
EMCAL=1 EMCAL=1
BLENDERSAVE=0 BLENDERSAVE=0
PICPCT=80 PICPCT=80
BGSHADE=0.051 BGSHADE=0
# now enjoy the options in order and nicely split until we see -- # now enjoy the options in order and nicely split until we see --
while true; do while true; do
case "$1" in case "$1" in
...@@ -135,7 +136,11 @@ while true; do ...@@ -135,7 +136,11 @@ while true; do
DURATION="$2" DURATION="$2"
shift 2 shift 2
;; ;;
-r|--resolution) -r|--radius)
RADIUS="$2"
shift 2
;;
--resolution)
RESOLUTION="$2" RESOLUTION="$2"
shift 2 shift 2
;; ;;
...@@ -233,7 +238,10 @@ Usage: ...@@ -233,7 +238,10 @@ Usage:
events with 'boosts' of particles on the xy plane. events with 'boosts' of particles on the xy plane.
-t | --duration VALUE -t | --duration VALUE
Set the animation duration in seconds. Set the animation duration in seconds.
-r | --resolution VALUE -r | --radius VALUE
Scale default particle radius to a given VALUE, greater than zero.
For example, VALUE=2 scales particle to twice its default size.
--resolution VALUE
Set the animation resolution percentage, where Set the animation resolution percentage, where
VALUE must be an integer from 1 to 100. VALUE must be an integer from 1 to 100.
--fps VALUE --fps VALUE
...@@ -299,6 +307,7 @@ else ...@@ -299,6 +307,7 @@ else
echo "Sample: $SAMPLE" echo "Sample: $SAMPLE"
echo "Transparency Parameter: $TRANSPARENCY" echo "Transparency Parameter: $TRANSPARENCY"
echo "Duration: $DURATION" echo "Duration: $DURATION"
echo "Particle Radius Scale: $RADIUS"
echo "Resolution: $RESOLUTION" echo "Resolution: $RESOLUTION"
echo "FPS: $FPS" echo "FPS: $FPS"
echo "Max particles: ${MAX_PARTICLES}" echo "Max particles: ${MAX_PARTICLES}"
...@@ -390,7 +399,7 @@ if [ "$SAMPLE" = "true" ]; then ...@@ -390,7 +399,7 @@ if [ "$SAMPLE" = "true" ]; then
pushd ${BLENDER_SCRIPT_DIR} pushd ${BLENDER_SCRIPT_DIR}
echo "Preparing sample animation in Blender" echo "Preparing sample animation in Blender"
blender -noaudio --background -P animate_particles.py -- -radius=0.05 \ blender -noaudio --background -P animate_particles.py -- -radius=${RADIUS} \
-duration=${DURATION} -cameras="${CAMERAS}" -datafile="d-esd-detail.dat" -simulated_t=0.03\ -duration=${DURATION} -cameras="${CAMERAS}" -datafile="d-esd-detail.dat" -simulated_t=0.03\
-fps=${FPS} -resolution=${RESOLUTION} -transparency=${TRANSPARENCY} \ -fps=${FPS} -resolution=${RESOLUTION} -transparency=${TRANSPARENCY} \
-stamp_note="opendata.cern.ch_record_1102_alice_2010_LHC10h_000139038_ESD_0001_2" -its=${ITS}\ -stamp_note="opendata.cern.ch_record_1102_alice_2010_LHC10h_000139038_ESD_0001_2" -its=${ITS}\
...@@ -640,7 +649,7 @@ elif [ "$SAMPLE" = "false" ]; then ...@@ -640,7 +649,7 @@ elif [ "$SAMPLE" = "false" ]; then
echo " date +\"%y-%m-%d, %T, \$1\"" >> make-event-${EVENT_ID} echo " date +\"%y-%m-%d, %T, \$1\"" >> make-event-${EVENT_ID}
echo "}" >> make-event-${EVENT_ID} echo "}" >> make-event-${EVENT_ID}
echo timestamp \"${UNIQUEID}, ${EVENT_ID}, BLENDER SCENE, STARTING, ${NUMBER_OF_PARTICLES}\" \>\> $PROGRESS_LOG >> make-event-${EVENT_ID} echo timestamp \"${UNIQUEID}, ${EVENT_ID}, BLENDER SCENE, STARTING, ${NUMBER_OF_PARTICLES}\" \>\> $PROGRESS_LOG >> make-event-${EVENT_ID}
echo blender -noaudio --background -P animate_particles.py -- -radius=0.05 \ echo blender -noaudio --background -P animate_particles.py -- -radius=${RADIUS} \
-duration=${DURATION} -datafile=\'${LOCAL_FILE_WITH_DATA}\' \ -duration=${DURATION} -datafile=\'${LOCAL_FILE_WITH_DATA}\' \
-n_event=${EVENT_ID} -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION} \ -n_event=${EVENT_ID} -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION} \
-transparency=${TRANSPARENCY} -stamp_note=\'${EVENT_UNIQUE_ID}\' -its=${ITS} \ -transparency=${TRANSPARENCY} -stamp_note=\'${EVENT_UNIQUE_ID}\' -its=${ITS} \
......
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