===== VRML driver of GEANT4 and G4VRMLView =====
----- How to visualize GEANT4 simulation -----
----- with VRML driver and g4vrmlview -----
1st version: August 19, 1997
2nd version: December 16, 1997
2rd version: Feb 21, 1998
4rd version: November 09, 1998
Satoshi Tanaka and Yasuhide Sawada
Fukui University, Japan
tanaka@i1nws1.fuis.fukui-u.ac.jp
========================
Chapter 1: Introduction
========================
This is a document to explain how to perform GEANT4
visualization with VRML. You can visualize GEANT4
simulation on your WWW browser.
You have to prepare the following softwares:
(1) GEANT4 with VRML driver.
(2) g4vrmlview, a small Java application included in GEANT4 package
geant4alpha/prototype/visualization/utils/g4vrmlview/
or you can obtain it from our ftp site:
ftp://rhodes.fuis.fukui-u.ac.jp/pub/graphics
/fukui_graphics_system/g4vrmlview_1.00.tar.gz
(3) VRML browser
===================================
Chapter 2: VRML driver in GEANT4
===================================
----------------------------------
Section 2.1: What is VRML driver?
----------------------------------
VRML driver is included in visualization category of
the GEANT4 package:
prototype/visualization/VRML/
VRML driver works as follows:
(1) Convert 3D scene data of GEANT4 into VRML codes
with help of classes G4VisManager and G4Polyhedron.
(2) Send the VRML codes to another process of "g4vrmlview",
running at either local or remote host.
----------------------------------------------------------------
Section 2.2: How to incorporate VRML driver in compiling GEANT4
----------------------------------------------------------------
Set an environmental variable as follows
% setenv G4VIS_BUILD_VRML_DRIVER 1
% setenv G4VIS_USE_VRML 1
----------------------------------------------------------------
Section 2.3: Environmental variables to customize VRML driver
----------------------------------------------------------------
You can customize VRML driver by setting environmental
variables at GEANT4 host, i.e., the host where GEANT4 runs:
GEANT4_host % setenv G4VRML_PORT port_number
GEANT4_host % setenv G4VRML_HOST_NAME host_name
The default port number is 40801, and the default host name
is "localhost". You need not define the environmental
variables if you use the default values.
You can customize the default values at run time of GEANT4.
=======================
Chapter 3: g4vrmlview
=======================
---------------------------------
Section 3.1: What is g4vrmlview?
---------------------------------
The g4vrmlview is a small Java application.
It works as follows:
(1) Receive VRML codes from VRML driver of GEANT4
via local or wide-area network.
(2) Save the VRML codes to a local file named "g4.wrl" etc.
(3) Invoke VRML viewer specified at the command line in the invokement
of g4vrmlview
--------------------------------------
Section 3.2: How to install g4vrmlview
--------------------------------------
You need JDK version 1.1 or later to install g4vrmlview.
The installation can be done by doing the following steps:
(1) % gzip -dc g4vrmlview_1.0.tar.gz | tar xvf -
% cd g4vrmlview_1.0
(2) Edit Makefile and set a proper directory name to variable
"INSTALL_DIR". The default setting is:
INSTALL_DIR = "/usr/local/javaclass"
Java classes (g4vrmlview.class etc) will be installed
to this directory.
(3) Set the environmental variable "CLASSPATH" in .cshrc etc.
For example, if JDK1.1 is installed in the directory
"/usr/local/dev/jdk1.1" and you want to install g4vrmlview
into "/usr/local/javaclass", then the variable CLASSPATH
should be defined as:
# java in Unix (.cshrc)
setenv CLASSPATH .:/usr/local/dev/jdk1.1/lib/classes.zip:\
/usr/local/javaclass
Similarly, in Windows NT/95, if JDK 1.1 is installed in
the directory "C:\jdk1.1" and you want to install g4vrmlview
into C:\dev\javaclass, you should add the following lines to
AUTOEXEC.BAT:
# java in Windows NT/95 (autoexec.bat)
SET CLASSPATH = .;C:\jdk1.1\lib\classes.zip;C:\dev\javaclass
(4) % make clean
(5) % make
(6) Perform a test of created Java classes using g4mini.
You can do it using two separate windows,
instead of using two separate hosts.
Here we assume that we use windows named "window_1"
and "window_2", and use VRML browser "vrweb".
window_1 % java g4vrmlview vrweb
Waiting for requests at port 40801 ...
window_2 % java g4mini
Usage: java g4mini src_file server_hostname
window_2 % java g4mini sample.wrl localhost
The test is successful if you see pictures on the VRML browser.
(5) Install Java classes to the directory specified by INSTALL_DIR.
(You may have to become a root if you do not have permission
to INSTALL_DIR.)
You can do it by simply doing as follows:
% make install
If the directory does not exist, it will be created automatically.
---------------------------------------
Section 3.3: More notes on g4vrmlview
---------------------------------------
(1) Format of invoking g4vrmlview:
% java g4vrmlview VRML_browser_name [port_number]
VRML_browser_name:
"netscape", "vrweb", etc,
or "NONE" to suppress invoking VRML browser
port_number:
The default port number is 40801.
If you are setting the environmental variable
"G4VRML_PORT" at GEANT4 host,
you have to give the same port number at g4vrmlview host.
For example,
GEANT4_host % setenv G4VRML_PORT 40802
g4vrmlview_host % java g4vrmlview netscape 40802
(2) Auto increment of port number:
If the port number 40801 is already in use, it is
automatically incremented one by one up to 40810.
(3) Multiple thread:
g4vrmlview is a multi-thread application.
It can accept data from plural GEANT4 at the same time.
(4) Saving VRML codes to files:
VRML codes sent from GEANT4 is saved to a file named
"g4.wrl". If g4.wrl already exists, the file name is
incremented to g4_2.wrl. Similarly the file name is
incremented to g4_3.wrl, g4_4.wrl, etc.
The files are created in the directory where you invoked
g4vrmlview.
==========================================================================
Chapter 4: How to use VRML driver and g4vrmlview for GEANT4 visualization
==========================================================================
(1) Invoke g4vrmlview at the g4vrmlview host, i.e. the host where you
want to run g4vrmlview. For example,
g4vrmlview_host% java g4vrmlview netscape
where the last argument is a name of your favorite VRML browser.
The g4vrmlview host may be different from the GEANT4 host.
(2) Set the environmental variable at GEANT host:
GEANT4_host % setenv G4VRML_HOST_NAME g4vrmlview_host
(2) Invoke GEANT4 at the GEANT4 host:
For example,
GEANT4_host% example2
===== End of document =====