Contents Previous Next Geant4 User's Guide
For Application Developers
Visualization
8.10 Making a Movie



These instructions are suggestive only. The following procedures have not been tested on all platforms. There are clearly some instructions that apply only to Unix-like systems with an X-Windows based windowing system. However, it should not be difficult to take the ideas presented here and extend them to other platforms and systems. The procedures described here need graphics drivers that can produce picture files that can be converted to a form suitable for an MPEG encoder. There may be other ways of capturing the screen images and we would be happy to hear about them. Graphics drivers currently capable of producing picture files are:

DriverFile type
DAWNFILEprim then eps using dawn
HepRepFileHepRep1
HepRepHepRep2
OGLXeps
RayTracerjpeg
VRMLFILEvrml

So far, only DAWNFILE, OGLX and RayTracer have been "road tested". Once in a standard format, such as eps, the convert program from ImageMagick can convert to ppm files suitable for mpeg2encode.

8.10.1 OGLX

Make a macro something like this:
/control/verbose 2
/vis/open OGLSX 600x600-0+0
/vis/drawVolume
/vis/viewer/reset
/vis/viewer/set/style surface
/vis/viewer/set/projection perspective 50 deg
/control/alias phi 30
/control/loop movie.loop theta 0 360 1
which invokes movie.loop, which is something like:
/vis/viewer/set/viewpointThetaPhi {theta} {phi}
/vis/viewer/zoom 1.005
/vis/oglx/printEPS
This produces lots of eps files. Then...
make_mpeg2encode_parfile.sh G4OpenGL_*eps
Then edit mpeg2encode.par to specify file type and size, etc.:
$ diff mpeg2encode.par~ mpeg2encode.par
7c7
< 1         /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */
---
> 2         /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */
15,17c15,17
<    /* horizontal_size */
<   /* vertical_size */
< 8         /* aspect_ratio_information 1=square pel, 2=4:3, 3=16:9, 4=2.11:1 */
---
> 600   /* horizontal_size */
> 600  /* vertical_size */
> 1         /* aspect_ratio_information 1=square pel, 2=4:3, 3=16:9, 4=2.11:1 */
Then convert to ppm:
for i in G4OpenGL*eps; do j=`basename $i .eps`; command="convert $i $j.ppm"; echo $command; $command; done
Then
mpeg2encode mpeg2encode.par G4OpenGL.mpg
Then, on Mac, for example:
open G4OpenGL.mpg
opens a QuickTime player.

8.10.2 DAWNFILE

You need to invoke dawn in "direct" mode, which picks up parameters from .DAWN_1.history, and suppress the GUI:
alias dawn='dawn -d'
export DAWN_BATCH=1
Change OGLSX to DAWNFILE in the above set of Geant4 commands and run. Then convert to ppm files as above:
for i in g4_*.eps; do j=`basename $i .eps`; command="convert $i $j.ppm"; echo $command; $command; done
Then make a .par file:
make_mpeg2encode_parfile.sh g4_*ppm
and edit mpeg2encode.par:
$ diff mpeg2encode.par~ mpeg2encode.par
7c7
< 1         /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */
---
> 2         /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */
9c9
< 1         /* number of first frame */
---
> 0         /* number of first frame */
15,16c15,16
<    /* horizontal_size */
<   /* vertical_size */
---
> 482   /* horizontal_size */
> 730  /* vertical_size */
Then encode and play:
mpeg2encode mpeg2encode.par DAWN.mpg
open DAWN.mpg

8.10.3 RayTracerX

/control/verbose 2
/vis/open RayTracerX 600x600-0+0
# (Raytracer doesn't need a scene; smoother not to /vis/drawVolume.)
/vis/viewer/reset
/vis/viewer/set/style surface
/vis/viewer/set/projection perspective 50 deg
/control/alias phi 30
/control/loop movie.loop theta 0 360 1
where movie.loop is as above. This produces lots of jpeg files (but takes 3 days!!!). Then...
make_mpeg2encode_parfile.sh g4RayTracer*jpeg
Then edit mpeg2encode.par to specify file type and size, etc.:
$ diff mpeg2encode.par.orig mpeg2encode.par      
7c7
< 1         /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */
---
> 2         /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */
15,17c15,17
<    /* horizontal_size */
<   /* vertical_size */
< 8         /* aspect_ratio_information 1=square pel, 2=4:3, 3=16:9, 4=2.11:1 */
---
> 600   /* horizontal_size */
> 600  /* vertical_size */
> 1         /* aspect_ratio_information 1=square pel, 2=4:3, 3=16:9, 4=2.11:1 */
Then convert to ppm, encode and play:
for i in g4*jpeg; do j=`basename $i .jpeg`; command="convert $i $j.ppm"; echo $command; $command; done
mpeg2encode mpeg2encode.par g4RayTracer.mpg
open g4RayTracer.mpg


Back to contents