Geant4手册目录
Geant4: 8.10.  Making a Movie

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: More informations about MPEG encoder

Driver File type
DAWNFILE prim then eps using dawn
HepRepFile HepRep1
HepRep HepRep2
OGLX eps
Qt jpeg, eps, ppm, ...
RayTracer jpeg
VRMLFILE vrml

So far, only DAWNFILE, OGLX, OGLQt 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 ppmtompeg available here: http://netpbm.sourceforge.net/

8.10.1.  OGLX

Make a macro something like this:

/control/verbose 2
/vis/open OGL 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/ogl/printEPS

This produces lots of eps files. Then...

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.  Qt

The Qt driver provides one of the easiest ways to make a movie. Of course, you first need to add the Qt libraries and link with Qt, but once you have that, Qt provides a ready-made function to store all updates of the OpenGL frame into the movie format. You then use loops (as defined in OGLX section above) or even move/rotate/zoom you scene by mouse actions to form your movie.

The Qt driver automatically handles all of the movie-making steps described in the OGLX section of this document - storing the files, converting them and assembling the finished movie. You just have to take care of installing an mpeg_encoder.

To make a movie :

  • Right click to display a context menu, "Action"-<"Movie parameters".
  • Select MPEG encoder path if it was not found.
  • Select the name of the output movie.
  • Let go! Hit SPACE to Start/Pause recording, RETURN to STOP

Then, open your movie (on Mac, for example):

open G4OpenGL.mpg

opens a QuickTime player.

8.10.3.  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 OGL 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:

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.4.  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

<-- 8.9. Polylines, Markers and Text  Chapter 9. Analysis --> "