millenniumWAVE technologies

Scotty's VRML v1.0 Guide


 
© Michael A. Scott
millenniumWAVE technologies
September 1996
Last update 2001.03.25


Also See:

Quote of the Month

This Month's Quote

 


Scotty's VR WAVE | Scotty's VRML 2.0 Guide to The Code | VRML Presentation | Student Project Sheet: VRML World Building | Scotty's WAVE |

NOTES

This guide has been designed for my students to help them create their virtual world projects in my design courses. VRML is an excellent tool, IMHO, for teaching design and mathematics, but can be used by any subject area. I think VRML is just the beginning of the way things will be in architectural and industrial design, engineering, scientific visualization and business proposals. This particular guide is for version 1 of the modeling language; VRML 1.0. The bible for this version, IMHO, is "The VRML Sourcebook" by Andrea Ames, David Nadeau, and John Moreland, (John Wiley and Sons, ISBN 0-471-14159-3). Check it out for more detailed examples. (Look out for my "Teachers Guide to Virtual Reality", coming out soon as I write it and find a publisher!).

PLEASE NOTE: VRML 1.0 has been supplanted by VRML 2.0, which is a much richer language. However, many newbies might find VRML 2.0 quite complex. VRML 1.0 can be used to create simple or complex worlds for learning purposes before the student strikes out and learns the more complex coding of VRML 2.0. In the meantime, the free Cosmo Player plugin is recommended since it still supports viewing VRML 1.0 files.

Check out the first installment of my STUDENT DESIGN BRIEFS, which I hand to my students to assist them in developing their projects. The pertinent one here is "VRML WORLD BUILDING", given to my electronic design students. Please let me know what you think! (Mail to: mascott@igs.net)

This guide is free for anyone's use, as it should be, all I ask is acknowledgment. Let me know if you do use it in the classroom, or call me for project ideas (such as the Virtual Reality Exquisite Corpse Robot project I use in electronics courses).

The guide is intended to give examples of the codes used to create virtual worlds (.WRL) for use in VRML v1.0 browsers. It includes code snippets and default settings to assist the student in designing their worlds. Please note the following:

  • there may be mistakes (hard to believe, eh?), so please bear with me as I capture them. Please email me at mascott@igs.net if you have any suggestions, I will be most appreciative. This is also the first document I created using Microsoft's Internet Assistant for Word, so it is a test case to see if the formatting comes through. Enjoy!
  • any text editor can be used, save your file as ASCII text with the .WRL extension
  • Since Live3d died a premature death, I highly recommend Cosmo Player as your free VRML viewer plug-in, which is available at http://www.cai.com/cosmo/.
  • VRML is case sensitive, spaces and carriage returns do not count
  • VRML uses the concept of generic units for measurement, any measurement can be described as long as it is consistent. (i.e. meters, miles, angstroms, light years…)
  • angles are measured in radians, radian=(degrees/180)*PI, #180° = 3.14159 rad
  • colors are specified in RGB fractional units from 0.0 to 1.0 (0.0, 0.0, 0.0 = black, 1.0, 1.0, 1.0 = white)
  • the order of fields (property or attribute settings) within a node is unimportant, if using default they can be left out
  • for primitives with a parts option, more than one part can be specified by separating with a pipe symbol ( | )
  • options are shown below as ALL/BOTTOM/TOP for example. ALL is default
  • objects will be automatically joined if created at same space. VRML v1.0 uses the orthogonal system (X, Y, Z coordinates, right hand rule). To place a node other than at 0.0,0.0,0.0, you move and/or rotate the axis first
  • generally, you set properties such as materials or colors, then create the node(s) to use those properties
  • use separation groups to isolate axis and property changes


HEADER (a must for all files)

# VRML V1.0 ascii

COMMENTS

# This line is a comment


PRIMITIVES

Cube
{
width 2.00
height 2.00
depth 2.00
}

Sphere
{
radius 1.00
}

Cylinder
{
height 2.00
radius 1.00
parts ALL/TOP/BOTTOM/SIDES
}

Cone
{
height 2.00
bottomRadius 1.00
parts ALL/SIDES/BOTTOM
}

AsciiText
{
string " "
justification LEFT/RIGHT/CENTER
width 0.0 # width of line of text, 0.0 no compression or expansion
#each line can be changed: width [100.0 200.0 300.0]
spacing 1.0 # spacing factor of each line below the other
}

Font
# Note: set font first, then AsciiText
{
family SERIF/SANS/TYPEWRITER
style NONE/BOLD/ITALIC/BOLD|ITALIC
size 10
}

BACKGROUND COLOR OR IMAGE

DEF BackgroundColor Info
{
string " 0.0 0.0 0.0 " # RGB color
}

DEF BackgroundImage Info
{
string "name_of_image_file" # name of graphic file
}

POSITIONING SHAPES:

AXIS TRANSFORMATIONS

Translation
{
translation 0.0 0.0 0.0
}

Rotation
{
rotation 0.0 0.0 0.0 0.0
#X,Y,Z, amount in radians: rad=(degrees/180)*PI
#180° = 3.14159 rad
}

Scale
{
ScaleFactor 1.0 1.0 1.0
# neg numbers turn objects inside out, less than 1.0 reduce size can be used to squash objects, for example. Retains scaling till changed again
}

Transform
{
translation 0.0 0.0 0.0
rotation 0.0 0.0 0.0 0.0
scaleFactor 1.0 1.0 1.0
scaleOrientation 0.0 0.0 0.0 0.0 # rotation axis and amount of scale factor
center 0.0 0.0 0.0 # X, Y, Z distance
{

MatrixTransform
{
matrix

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

}

EXAMPLE MATRIX TRANSFORMATIONS

RSS (Rotation, Scale Shear)

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

Scale (X, Y, Z)

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

X Rotation C = cosine, S = sine

1.0
0.0
0.0
0.0
0.0
C
S
0.0
0.0
-S
C
0.0
0.0
0.0
0.0
1.0

Y Rotation

C
0.0
S
0.0
0.0
1.0
0.0
0.0
S
0.0
C
0.0
0.0
0.0
0.0
1.0

Z Rotation

C
S
0.0
0.0
-S
C
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

Shear

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

Taper (X, Y, Z), always between -1.0 and 1.0
(better between -0.5 and 0.5)

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

Transform

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

Global Scaling Factor

1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0
0.0
0.0
0.0
0.0
1.0

SHADING NODES

Material
{
diffuseColor 0.0 0.0 0.0 # RGB color
emissiveColor 0.0 0.0 0.0 # "glowing" color
transparency 0.0 # transparency factor (0.0 = opaque, 1.0 = transparent)
ambientColor 0.0 0.0 0.0 # for lighting nodes
specularColor 0.0 0.0 0.0 # for lighting nodes
shininess 0.0 0.0 0.0 # for lighting nodes
}

GROUPING NODES

Group{ }
# groups children together, i.e. parts of a chair, not used much

TransformSeparator { }
# translations, rotations, scales only affect members within the separations, settings restored to previous settings before the separation

Separator { }
# like TransformSeparator, but restores all settings

Separator
{
renderCulling AUTO/ON/OFF
# will not draw shapes if outside view, speeds rendering of nodes
}

Switch
{
whichChild -1
# numbers from 0, 1, 2, 3…etc., tells browser which child node to draw, -1 to draw none, -3 to draw all. Used to easily switch various nodes to try variations, or to DEF a shape without instancing it.
}

SPIN GROUPS
To spin parts of your world. NOTE: WORKED WITH LIVE3D ONLY, may make other browsers crash... not sure where to get viewer....

DEF name_of_group SpinGroup
{
rotation 0 1 0 0.1 # angle and amount
# material, etc and name of node
}

INSTANCING SHAPES
Used to create a node, material or font style, then duplicate original as many times as required

DEF node_name node
# where node_name is your name of object, (no spaces), node is the object itself (primitive, materials, etc.)

USE node_name
#instance the named node, perhaps after translation, etc.

LINKING AND INLINING
You can join several files together by inlining your files, (even across the Internet). Example is inlining a door to another room, or using a furniture file in several rooms, used to create complex worlds and reusing files

WWWAnchor
{
name "" # URL: VRML, HTML site, graphic, sound, etc.
description "" # a text string
map NONE/POINT # mapping type
# mapping is a program that runs on a server to select different links depending on coordinates clicked
}

WWWInline
{
name "" # URL, example: file:table.wrl
bboxSize 0.0 0.0 0.0 # bounding box of file, width, height, depth
bboxCenter 0.0 0.0 0.0 # 3D coordinates, relative to current origin
# bounding box not necessary, but saves time by skipping the reading of file
}

CREATING FACES, LINES, POINTS
Complex shapes can be created by describing vertices of faces, typically triangles. Usually difficult by typing by hand! You use the Coordinate3 node with IndexedFaceSet for faces, IndexedLineSet for polylines, and PointSet for points (like stars) Use for complex shapes, landscapes, grids, patterns, stars, city lights:

Coordinate3
{
point [ # list of XYZ vertices i.e.

1.0 0.0 0.0
-1.0 0.0 0.0
1.0 0.0 0.0
……so on
]
}

IndexedFaceSet
{
coordIndex [ # list of vertices above, use any combination
0, 1, 2
…..
]
}

IndexedFaceSet
{
coordIndex [0,1] # as above
materialIndex -1 # material or color list for each face
normalIndex -1 # normal or perpendicular
textureCoordIndex -1 # texture list
}

IndexedLineSet
{
coordIndex [0, 1] # as above
materialIndex -1 # material or color list for each face
normalIndex -1 # normal or perpendicular
textureCoordIndex -1 # texture list
}

PointSet
{
startIndex 0 # coordinate index
numpoints -1 # number of points to draw

MATERIAL BINDING
Used for shading, coloring, etc. Can shade faces, parts, etc. separately. Can create rainbow effects, shaded or blended colors. Material Binding can be

  • Overall entire shape
  • Per_part different material for each part
  • Per_face different material for each face
  • Per_vertex different material for each vertex

Material
{
diffuseColor [0.0 0.0 0.0 # list of RGB colors
0.0 0.0 0.0
0.0 0.0 0.0]
}

MaterialBinding
{
value DEFAULT
# also use OVERALL, PER_PART, PER_FACE, PER_VERTEX, PER_FACE_INDEXED, PER_VERTEX_INDEXED
}

ADVANCED SHADING TECHNIQUES
Nodes can be shaded and smoothed with techniques involving setting and binding normal vectors, smoothing, and using ShapeHints. See the VRML Source Book for information on these techniques. (Someday I will have time to write this up!)

MAPPING TEXTURES
You can use .GIF, TIF, .JPG, .PCX, .TGA files as patterns or textures on surfaces of nodes, including text. Complex patterns can be put on complex nodes using index lists. The way that patterns wrap on nodes is complex, see the Source Book for details. Easy way is to create only parts of a node, and apply patterns to each part, like the sides of a cylinder for a can, for example.

Texture2Transform
{
translation 0.0 0.0 # S (horizontal), T (vertical) distance
rotation 0 # rotation amount
scaleFactor 1 1 # S, T scale factor
center 0 0 # S, T texture coordinate
{

Texture2
{
filename "" # name of file URL
wrapS REPEAT/CLAMP # horizontal texture wrap type
wrapT REPEAT/CLAMP # vertical texture wrap type
# only filename required
}

LIGHTING

PointLight # point source
{
on TRUE/FALSE
intensity 1 # Light intensity, 0.0 to 1.0
color 1.0 1.0 1.0 # RGB color
location 0.0 0.0 0.0 # X Y Z coordinates
}

DirectionLight # parallel directional light
{
on TRUE/FALSE
intensity 1 # Light intensity, 0.0 to 1.0
color 1.0 1.0 1.0 # RGB color
location 0.0 0.0 0.0 # X Y Z coordinates
}

SpotLight
{
on TRUE/FALSE
intensity 1 # Light intensity, 0.0 to 1.0
color 1.0 1.0 1.0 # RGB color
location 0.0 0.0 0.0 # X Y Z coordinates
direction 0.0 0.0 -1.0 # X Y Z coordinates
dropOffRate 0 # drop off factor
cutOffAngle 0.785 # cone angle, radians, default 45°
}

LOD
Level of detail. You can create different shapes that appear at specified distances from viewer to node. Used to reduce detail at distances to give more perspective clues. Can be used for animation effects too.

LOD
{
range [ ] # range list
center 0.0 0.0 0.0 # x Y Z coordinates (center of shape)
}

CAMERAS
Can be used to predetermine viewer's viewpoint. Can use perspective camera for more realistic view of world, or orthographic camera for unrealistic view, used in mechanical or drafting views. Cameras are used at top of file.

PerspectiveCamera
{
position 0.0 0.0 1.0 # X Y Z position
orientation 0.0 0.0 1.0 0.0 # rotation angle and amount
focalDistance 5 # distance amount
heightAngle 0.789 # angle radians, 90° like fisheye
nearDistance 0.01 # not supported by all browsers
farDistance 5.0 # not supported by all browsers
# near and far distances are for clipping planes
}

OrthographicCamera
{
position 0.0 0.0 1.0 # X Y Z position
orientation 0.0 0.0 1.0 0.0 # rotation angle and amount
focalDistance 5 # distance amount
height 2 # height of viewing volume
nearDistance 0.01 # not supported by all browsers
farDistance 5.0 # not supported by all browsers
# near and far distances are for clipping planes
}

 

© 2001 millenniumWAVE technologies
Please acknowledge author in use of any original material