Combining Java and VRML

    In order to put VRML to better use, VRML worlds can be linked with Java code to control the environment, objects attributes, world attributes, and camera attributes.  With the ability to do this one can able to create a thread in the java program to act as the timer. At each iteration of the timer thread, the camera can be changed to progress down the spline creating a realtime animation using VRML. In the program for the MQP, we added created a user interface similar to a VCR. Using this interface the user can control the speed and direction that they will travel down the spline. The main advantage of java over AVS visualization is that all the code is contained in the program that the developer writes and uses VRML only as a renderer unlike AVS where you need some AVS modules to create a user interface in addition to the renderer.

    Another interesting aspect of incorporating VRML into java is that you can extract the points and faces of the VRML object and manipulate the VRML object in the java code. To do this you must first parse the VRML file which can be done by using a number of the available VRML file parses available on the web. Parsing the file will give the programmer an array of points and an array of faces that hold the array indexes of the points that make up the face of the triangle. In the Sydney MQP, the VRML object was aligned on the Z-axis and the faces were created at even intervals. This means that the faces were made in rings around the Z-axis, so all the triangles of each ring all had the same Z values. What Kevin Donahue was able to do was to calculate the average of the X and Y values at each interval of Z creating a midpoint spline which had to be given in AVS.

    Java is implemented into VRML by having Java edit the text of the VRML world file. To combine Java with VRML you must use the VRML classes located at:

          C:\Program Files\Netscape\Communicator\Program\Plugins\Npcosmop21.jar for the PC
or      /usr/CosmoPlayer/classes/vrml for IRIX

If you don’t have CosmoPlayer, you can get it at http://www.cosmoplayer.com.
 
 

[Return to cs563 '99 Biomedical Visualization Talk]