From GEANT4[8] you can produce HepRep1 or HepRep2 XML files. The standard GEANT4 distribution comes with a visualization driver for HepReps.
To select the HepRep2 driver you need to issue the following commands from the GEANT4 command line:
/vis/scene/create filename.heprep.zip /vis/open HepRepXML
This will open a file with name filename.heprep.zip and put multiple events in it. To store events (and geometry) in this file, you should issue a run command:
/run/beamOn 20
which will write 20 events and geometry.
To only write a geometry:
/vis/viewer/flush
More information on the HepRep drivers can be found in the README in the src/visualization/HepRep directory of the Geant4 distribution.