|
|
Sponsored by Kahuna's 3D Libraries
Last updated on Saturday, 05-Jul-2008 11:03:41 PDT
Virtual Reality Modeling
Language
VRML 2.0 browsers were becoming a standard plugin for web browsers back in the late 90s. A vrml
browser,,, or more accurately a "plugin" installs into your existing web
browser (Netscape or Internet Explorer) and will load a 3D vrml world
into your browser window and navigate through that world using a mouse
or the control bars usually included with the plugin. These worlds when
written in vrml 2.0 script are text driven. The vrml browser parses that
script similar to the way a web browser parses html and turns that
script into either a 3 demensional object or world for the viewer to
make more sense to just display some basic nodes the same way they could appear in a vrml file:
#VRML V2.0 utf8
# The line above this description is necessary to inform the plugin the
# version of the vrml script it is parsing. All other comments following
# a pound sign will not be read by the plugin but are here only to
#inform the reader of the script what is happening.
# in html it is equivalent to <!-- something unseen -->
# in c it is equivalent to // in assembly ;
Group { # all objects begin in a group or a Transform. Case is strict
children [ # this describes the children in a group or
# transform. The children are parts of the object
# that make a whole whether they are a complete world
# or just and object.
NavigationInfo { #this describes the attributes the viewer has in the
#world
avatarSize [
0.25,1.6,0.75 ] # the viewers size in vrml units
type EXAMINE # how the vrml browser lets the viewer look at the
# world.
# EXAMINE = look at the whole world like an object
# WALK = through the world affected by gravity
# FLY = fly unaffected by gravity
# NONE = the viewer cannot move through the world
},
DEF default Background { #the DEF key word precedes the name of
# any node. In this case it defines the
# background node so that it can later be
# changed
groundAngle[ 1.2 , 1.42, 1.72]
groundColor[.2 1 1, .61 .1 .8, .7 .2 .4,.8 .3 .5]
skyAngle [1.2,1.32, 1.37, 1.59]
skyColor [.3 1 1,.4 .8 1, .2 1 .9, .8 .6 .5,1 .7 .8]
},#You can also just put in skyColor r g b
#which will simply change the background color to the values
#specified in the rgb field,,, the example show a gradiated
#sky and ground
Transform{ #only geometry within transforms can be animated or moved
# to desired locations
translation x y z # this moves the geometry to the x y z coordinate
# system which is the same that describes
# cartesian space
rotation x y z radian # this will rotate the geometry on the axis you
# you select to the radian you specify ie:
# rotation 0 1 0 3.14625 will turn the geometry
# around 180 degrees on the y axis like a top
scale x y z # this will change the size of the geometry using
# x y z offsets... valid numbers are 0 to infinity
# .5 has the same effect as reducing the object
# size by 50%
children[
Shape { #This nodes sets up simple geometry
appearance Appearance{ # this node sets up the appearance of the
# preceding geometry
material Material{ # this node discribes the color of that geometry
diffuseColor 1 0 0
}
texture imageTexture{
url "yourtexture location on the server"
} # the texture node allows you to place bit maps on an object.
# this works best if the material node is left out.
} #end of the Appearance node...Remember texture and material nodes
# must be contained in an appearance Appearance node
geometry Sphere{
radius 1
} # the geomtry node allows you to use primitive shapes to create your
# world. Valid shapes are Cone, Box , Cylinder, Box takes 3
# values in the size field,,, x y z, cylinder and cone take a single
# height and radius value see descriptions below.
# the sphere
} # this ends the shape node.
] #this ends the children of the transform node
} #this ends the transform
] # this ends the children of the group node
} # this ends the group
// end of example
The 2.0 language also allows you to do many other nodes that I haven't
the time to describe right now. You can find more complete information
at here . This home page was put
together by the people who wrote the specs. Take your time to use it,,,
it was how I learned. Here is a short list of descriptions that may be
useful in understanding the specs.
Node: referes to a segment of scripts that contains fields and related
nodes and or objects
field: referes to a tag which controls the conditions of the related
objects
Transform: a node that can be moved or animated or changed by sitting
up its translation, rotation , or scale field.
Group: a node which defines a group of objects
translate: to move an object or shape
coordinate: referes to a position on the cartisian plane where
0 0 0 = the absolute center x y z and where x = to
coordinates to the left and right, y = to coordinates
up or down and z forward or backwards. a position value
represents one side of the world and a negative value
represents the other side.
One important thing to remember that reference to nodes and fields are
case sensative, meaning that if the spec shows a capitalized letter and
you ommit it, the parser will throw an error. A lot of errors can be
traces back to this simple syntactical mistake, as well as to misplaced
brackets and DEF discriptions. A Def field can only be used inside of the
children bracket of a node,,, or else as a completely new node itself with
in the script ie:
Group {
children[]
}
DEF anewgroup{
children[]
}
are permissable
Primitive Geometry Specifications
Sphere{
radius radius size in units
}
Box{
size x y and z sizes in units
}
Cylinder{
bottom TRUE or FALSE
height size in units
radius radius size in units
side TRUE or FALSE
}
Cone{
bottomRadius radius size in units
height size in units
side TRUE or FALSE
bottom TRUE or FALSE
}
All the above nodes must be proceeded by the word "geometry" spelled in lower case letters and
limited with a space between the node: geometry Sphere
Good luck, I hope this has been helpful and not too
confusing.
|