VRML

Virtual Reality
Modelling Language

3D graphics for the web

Demo0-Juggling

History

• SGI’s Open Inventor — a 3D graphics programming language

• May ’94: First WWW Conference: VRML 1.0 Draft Specification — essentially a subset of Open Inventor.

• May ’95: VRML 1.0 Specification published.

• Aug ’95: First VRML 1.0 browser available.

• Request for Proposals for VRML 2.0.

• Aug ’96: SGI’s Moving Worlds adopted as draft VRML 2.0 spec.

• Aug’97: ISO standard for VRML 97 adopted.

• VRML 97 = VRML 2.0 + minor modifications.

• Implementations now available for PC, Macintosh, various Unixes, BeOS.

• Next version under discussion — VRML-NG.

Applications

•Architecture

•Chemistry — molecular models

•Medicine

•Games, films, entertainment

•GUI interfaces

•Fancy graphics for tarting up web pages

•Mathematics — watch a sphere being turned inside out

•3D graphics interchange format

•Data visualisation

•Anything else…

What is VRML?

A description language for three-dimensional scenes, with:

Ëanimation

Ëinteractivity

Ëprogrammable

behaviour

An open standard.

The scene graph

The scene is represented as a tree.

The leaves hold the geometry nodes: Box, Sphere, IndexedFaceSet, etc.

The other nodes:

•cluster nodes into groups

•apply geometric transformations to groups of nodes (scale, rotate, translate).

#VRML V2.0 utf8Demo1-box.wrl

NavigationInfo {

headlight TRUE

type "EXAMINE"

}

Shape {

geometry Box{}

appearance Appearance {

material Material {

diffuseColor

0.5255 0.7216 0.0431

}

}

}

Geometry nodes

Box { scale 2 2 2 }

Sphere { radius 1 }

Cone { bottomRadius 1
height 2
side TRUE
bottom TRUE }

Cylinder { radius 1
height 2
side TRUE
bottom TRUE
top TRUE }

ElevationGrid { ... }Demo2-map454-45.wrl

IndexedFaceSet { ... }

Extrusion { ... }

IndexedLineSet { ... }

PointSet { ... }

Text { ... }

Material properties

Specified by a Material node.

Reflection from a coloured matt surface:

diffuseColor RGB value

Reflection from a coloured reflective surface:

specularColor RGB value

shininess real number

Luminous objects:

emissiveColor RGB value

Reflection of ambient light.

ambientIntensity real number

Geometric transformation

Transform {

translation x y z

center x y z

rotation x y z theta

scale x y z

scaleOrientation

x y z theta

bboxCenter x y z

bboxSize x y z

children [

...any set of nodes...

]

}

The transformation is applied to all the children nodes.

Transformations can be nested.

Lighting

DirectionalLight

Located infinitely far away.
Illuminates with parallel light rays.

Only affects objects below it in the scene graph

Demo3-sphere.wrl

PointLight

Located at a point in space.
Illuminates everything within a maximum range and which is below it in the scene graph.

Spotlight

Like a PointLight, but the light is confined to a specified cone.

Demo5-truck.wrl

Sound

AudioClip {

description “”

loop FALSE

pitch 1.0

startTime 0

stopTime 0

url []

}

Sound {

location 3D vector

intensity real number

direction 3D vector

maxBack real number

maxFront real number

minBack real number

minFront real number

priority real number

spatialize boolean

source VRML node

}

Re-using nodes: DEF/USE

Any node can be given a name, and later referred to by that name.

# A blue cube at (2,2,1)

Transform {

position 2 2 1

children [

DEF BlueBox Shape {

appearance Appearance {

material Material {

diffuseColor 0 0 1

}

geometry Box{ size 1 1 1 }

}

]

}

# Another blue cube at (-3,0,0)

Transform {

position -3 0 0

children [

USE BlueBox

]

}

Defining new node types

PROTO BlueBox [

field SFVec3f size 1 1 1

] {

appearance Appearance {

material Material {

diffuseColor 0 0 1

}

geometry Box{

size IS size

}

}

# A blue cube at (2,2,1)

Transform {

position 2 2 1

children [

BlueBox { size 1 2 3 }

]

}

# Another blue cube at (-3,0,0)

Transform {

position 3 4 0

children [

BlueBox{size 0.5 0.5 0.5}

]

}

Animation with interpolators

#VRML V2.0 utf8

DEF TheBox Transform {

children [

Shape {

geometry Box{

size 5 5 5

}

appearance Appearance {

material Material {

diffuseColor 0.5255 0.7216 0.0431

}

}

}

]

}

DEF BoxTime TimeSensor {

cycleInterval 4

enabled TRUE

loop TRUE

startTime 0

stopTime -1

}

DEF BoxAngle OrientationInterpolator {

key [ 0 0.25 0.5 0.75 1 ]

keyValue [

1 1 1 0,

1 1 1 1.57079,

1 1 1 3.14159,

1 1 1 4.71238,

1 1 1 6.28318

]

}

ROUTE BoxTime.fraction_changed

TO BoxAngle.set_fraction

ROUTE BoxAngle.value_changed TO TheBox.rotation

Demo5-boxanim.wrl

Demo6-boxanim2.wrl

Sensors

TimeSensor

Emits a continuous stream of events whose value is the time (absolute time, in seconds since the epoch).

Can also perform loops, emitting a continuous stream of events specifying what proportion of the loop has elapsed.

TouchSensor

For detecting mouse-clicks.

CylinderSensor

PlaneSensor

SphereSensor

For dragging things around.

ProximitySensor

Generates an event when the avatar approaches or goes away.

VisibilitySensor

Generates an event when the object becomes visible or invisible to the avatar.

The event model

Each node has various eventIn and eventOut fields.

A ROUTE command connects an eventOut field of one node to an eventIn of another.

Basic rendering cycle of a VRML viewer:

•Determine which Sensors are emitting eventOuts.

•Use the value of each eventOut to set the eventIn field of each node it’s connected to.

•This can cause more eventOuts to be generated. Process these the same way.

•When all events have finished propagating, render the scene.

•Repeat forever.

Time always passes at a fixed rate — one second per second. The faster the machine, the more frames can be drawn per second.

Grouping nodes

Group Groups nodes together.

Transform Applies a geometric transformation to the children nodes.

Anchor Goes to a specified URL when the user clicks on the geometry described by the children nodes.

Collision Generates an event when the avatar collides with the geometry.

Switch Exactly one of the children nodes is visible.

Billboard Makes the geometry described by the children nodes always face the avatar.

Other stuff

NavigationInfo Defines some global information about the world.

Viewpoint Specifies the position and orientation of the avatar. Multiple viewpoints are allowed.

Background Defines background colours for ground and sky.

Fog Causes far away objects to be dimmed.

LOD(“Level Of Detail”) Specifies alternative representations of a node to be used according to the distance of the avatar.

Inline Loads VRML from another file.

Scripting

Arbitrary behaviours can be programmed with Script nodes.

Script nodes can contain code in any supported scripting language.

Script nodes can:

•receive an event and execute an arbitrary piece of code…

•…which can send more events, directly set fields of other nodes, or create new nodes.

Script nodes are part of the VRML97 standard.

BUT:the standard does not require any particular scripting language.

Some VRML viewers support:

•Java

•JavaScript™

•VRMLScript (SGI rebadging of JavaScript)

•ECMAScript (ISO rebadging of VRMLScript)

Java applets can communicate with VRML worlds through the External Application Interface.

Problems with VRML

The event model is obscure. (Multiple events reaching the same place with the same timestamp? How to break cycles? How to deal with lost events?)

Lack of support for data streaming.

Lack of support for multiuser worlds.

Lack of robust, complete, correct implementations.

Lack of support by 3D modelling software.

Impressionism

Choose two:

•3D

•Real time animation

•Photorealism

Real-time 3D graphics has to be impressionistic. Look at games to see the tricks:

•No middle distance

•Texture-mapping

•Rotating trees.

•Restricted view — dungeon games.

•Pre-rendering to 2D video.

•High-res background, low-res animation.

Learn from cartoonists — small details can give the illusion of realism.

Related developments

Java 3d:

A Java package for 3D rendering with many primitives similar to VRML. For programmers who want to put 3D stuff into their program instead of invoking a VRML viewer.

VRML-NG:

The next version, which may be very different from the current version. It will be better, but current VRML browsers will be made obsolete again.

VRML working groups:

data streaming, multiuser worlds, scripting, humanoid animation, etc.

The current state of VRML

•3D graphics for the masses — almost.

•Still a developing standard.

•Lack of stable software.

•High-performance implementations not yet available.

•Features on the horizon:

•Correct, complete, and
efficient implementations

•Better programming interface

•Multi-user worlds

•Where are the killer applications?

Richard Kennaway October 19981