![]() |
EGR 199:
Fundamentals of Engineering |
Virtual Reality Modeling Language |
| 01/06/00 19:48 | Prabhaker Mateti | |
| 12/31/99 |
|
|
Executive Summary
Background InformationWhat is VRML?
How To Setup Browsers for VRML?
Details of VRML File Format
Creating Your Own VRML filesProcedures
Appendix A: Acronyms
Appendix B: Further Reading Links
Achievement Test
|
Executive Summary |
This article gives a taste of VRML via examples. It assumes that the student is already familiar with Web, and HTML authoring.
Like HTML, VRML is a language. Code is written in a text file, and its file name is expected to end with .wrl. Each *.wrl file describes a composition of one or more objects such as cylinders, cones, human bodies modeled via geometric entities. The code also describes animation, etc. Just as when an .htm file is loaded the browser shows the text and the pictures according to the descriptions contained in the HTML file, when a .wrl file is loaded into a VRML-enabled browser, it begins to show a virtual reality world. VRML worlds are generally interactive and animated, and include embedded hyperlinks to other Web documents.
#VRML V2.0 ascii
# A Cylinder
Shape {
appearance Appearance {
material Material { }
}
geometry Cylinder {
height 2.0
radius 1.5
}
}
|
At left is the source code of an example: sample.wrl. When clicked, it will display a stationary cylinder placed on its flat bottom, and silver colored.
After the VRML browser window pops up, try the Walk (W), Pan (P), Turn (T), Rotate (R) controls that show up on the left frame of the window. |
The latest versions of Netscape Communicator (4.7x) and Internet Explorer (5.x) contain VRML 2.0 plug-ins if you chose a custom install. If not so, VRML 2.0 browser component must be added. The following are links to two well known VRML plug-ins for both IE and Netscape: Cosmo Player 2.1 and Contact 4.2. Microsoft offers its own Microsoft VRML 2.0 Viewer for IE.
VRML was started by Silicon Graphics. VRML 1.0 was adopted in the Spring of 1995 and provided the basic file format -- but the worlds were static. VRML 2.0 has the following capabilities
The machines in 141 RC have both Netscape and IE5 browsers with VRML plug-ins already in place. The machines in OSIS Lab (429 RC) can boot into 98, NT, or Linux. Boot into NT and login as guest with password guest007, and browse with IE.
After loading the following wrl files, try the Walk (W), Pan (P), Turn (T), Rotate (R) controls that show up on the left frame of the VRML window. To walk closer, press and hold the left mouse button and push the mouse away from you. To walk away, press and hold the left mouse button, and pull the mouse towards you. Similarly, for other actions. If you click on the Study control, you can examine the model in a variety of positions and angles by moving the mouse around.
1.1 Click on gravity3.wrl and play with it. Click on the green panel to let the spherical ball bounce on the gray platform. Click on red panel to stop the ball.
1.2 Spiral.wrl is a 63 KB file. It shows several green and red balls emanate from the top paddle and spiral down and disappear into the bottom paddle. Study it. Were they really paddles?
1.3 sextant.wrl is a sextant model originally done in AutoCAD and exported as a VRML file, about 256KB in size.
1.4 In lod1.wrl you can see the effect of the level of detail (LOD) node. But you must walk further into the world, beyond the entry view.
1.5 Tetrodotoxin (TTX) is an especially potent neurotoxin. ttx.wrl is its molecule.
Since VRML files are simple ASCII text files, you can edit them just like any regular text file. As with HTML, there are WISYWIG editors for VRML. But, in order to understand what goes into a VRML file, we will build a VRML scene using a simple text editor.
The wrl file you are working should be served by a web server. So,
telnet paladin.wright.edu
and login normally. Change directory (cd) to www. Create your example.wrl file in this directory. Make sure you invoke the chweb command on paladin, after creating the example.wrl file, to make your www directory web-ready. Keep this telnet window on your PC open.
Open the IE browser with a URL http://www.wright.edu/~name.7/example.wrl, where name.7 should be replaced with your e-mail name. Keep this browser window on your PC open. Remember that you can copy-and-paste among windows.
You need to do the following at the end of most steps.
SFR == Save File in your www directory on the WSU account, and Reload/Refresh the VRML window of the browser. Do this after each suggested change in the .wrl file being edited.
Glitch Alert: If the browser does not show the effects of your changes to the wrl file, first verify that you have saved your file and that you did not make any typos. Then, close all the browser windows, and re-launch the browser afresh.
2.1 Build a simple scene with a cone.
Using any text editor (e.g., pico), create a file called example.wrl with the following as content. Remember that you can cut-and-paste among windows. SFR.
#VRML V1.0 ascii
Separator {
DirectionalLight {
direction 0 0 -1
}
Cone {
bottomRadius 1
height 2
}
}
A VRML node is an individual object or operation in the 3D model. For example, a node can be a light, an object like a cube, or an operation like a rotation. In the above there are three nodes. The node named Separator contains the nodes DirectionalLight and Cone.
VRML assumes the following values for units of measurement:
The data inside the braces {} can be descriptions of properties for the node or other "nested" nodes: value,
such as the radius of a sphere radius 1.0, or such as a URL name "http://www.anywhere.com"; value1 value2 .... valueN, such as a 3d-location in location 0 1 1; [ value1a value2a value3a, value1b value2b value3b ] such as a list of points in 3D space: e.g., point [ 0 0 0, 0 0 1, 0 -3 0, 1 1 1 ]
2.2 Adding lights: A point light source provides the simplest way to light a scene (see lightedCone.wrl). To add a point light, add the following lines to the head of a VRML file.
PointLight {
location 0 0 1
color 1 1 1
}
This adds, at point (0, 0, 1) in 3D space (Cartesian XYZ coordinate system), a white light (color 1 1 1, full red, green and blue combined) to the scene that illuminates objects in the scene. SFR.
2.3 Change materials of cone: Now we will change the material that the cone is made of using a "Material" node. Insert the material node right after the "PointLight".
The following settings will make the node appear to be a bright red. SFR.
Material {
diffuseColor 0.8 0 0 # r=.8 g=0 b=0
}
Light properties depend on the light.
diffuseColor 1 1 1 SFR
color 0 0 1 SFR
location 10 0 0
2.5 Using the SpotLight: In addition to the parameters available to the PointLight, the parameters of the SpotLight node basically define the dimensions and orientation of a cone using location, direction, and cutOffAngle.
Replace the PointLight node with the following SpotLight node. SFR.
SpotLight{
location 0 4 0 # Above the object by 4 units
direction 0 -1 0 # point downward
cutOffAngle 0.7
}
Texture maps can be used to improve the realism of a relatively simple scene.
A scene graph is a hierarchical description of the objects and operations in the VRML model. The term, graph, comes from the tree-like organization of objects in the model. The effect of operations is restricted only to objects in the same branch of the tree and all of their children.
Begin with the following scene graph. SFR. It displays a red sphere with a green brick ("cube") piercing through it. Study it.
#VRML V1.0 ascii
Separator {
Material { diffuseColor 0.8 0 0 } # dull red
Sphere{ radius 1.0 }
Material { diffuseColor 0 1 0 } # pure green
Cube {
width 1
height 1
depth 1.8
}
}
![]() |
We need to have a texture map image to apply to the surface. From the wallpapers available on windows, select a jpg or gif texture file. If you wish, use the one on the left: droplets.gif. |
Texture2 {
filename "http://www.cs.wright.edu/EGR199/PM/VRML/images/droplets.gif"
}
2.7 Adding Hyperlinks to Objects
To make an object a hyperlink, we encapsulate it with a WWWAnchor as follows, using the sphere node above.WWWAnchor {
name "http://www.cs.wright.edu/EGR199/"
Sphere {
radius 1.0
}
}
SFR. When you reload the scene, you will notice that the the mouse cursor will change to a pointing-hand if you hold the mouse pointer over the sphere. If you click on it, you will go to that URL.
|
A few acronyms and their expansions are collected in the table here. If you are curious about an acronym or term not listed, type it in the input box below, and then press
the button to look it up in the TechEncyclopedia. |
The Procedures section is based on http://bach.ncsa.uiuc.edu/VRML/.
http://www.netscape.com/eng/live3d/howto/vrml_primer_index.html is a good tutorial.
http://home.t-online.de/home/kiwano6/models.htm A collection of simple but interesting VRML models.
![]() |
Cybertown - an excellent virtual community with knockout artwork. There is also a customizable apartment and a demo version of Virtual Home Space Builder. |
http://www.intervista.com/vrml/gallery/index.html is a site that shows how VRML is being put to work in a number of technical and business applications.
http://case.vlc.com.au/VermelGen/ A Free VRML 2.0 Editor Written in Java
http://www.nas.nasa.gov/Services/Education/Resources/webweavers.html VRML Resources
http://www.vrml.org/ The organization for VRML development and standardization.
http://www.web3d.org/vrml/vrml.htm The VRML Repository is an impartial, comprehensive, community resource for the dissemination of information relating to VRML. Maintained by the Web3D Consortium.
The VRML 2.0 Handbook : Building Moving Worlds on the Web by Jed Hartman, Josie Wernecke, by two people from Silicon Graphics company that developed VRML originally.
Vrml 2.0 Sourcebook by Andrea L. Ames, David R. Nadeau, John L. Moreland, a very complete book.
http://www.vrml.org/VRML2.0/FINAL/ The Virtual Reality Modeling Language Specification. May be too hard to digest.
|
Achievement Test |
Turn in the .wrl files that you have at the end of steps 2.4. 2.6, and 2.7 of Procedures.
| 12/31/99 |
| pmateti@cs.wright.edu |