Top Banner
CVVR Lab.@ National Dong Hwa Univ. 國國國國國國 VRML Virtual Reality Modeling Lang Virtual Reality Modeling Lang uage uage http://www.parallelgraphics.com/products/cor http://www.parallelgraphics.com/products/cor tona/ tona/
115

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

Jan 04, 2016

Download

Documents

Juniper Blair
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

VRML

Virtual Reality Modeling LanguageVirtual Reality Modeling Language

http://www.parallelgraphics.com/products/cortona/http://www.parallelgraphics.com/products/cortona/

Page 2: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

VRML

• In addition to HTML (HyperText Markup Language), that has become a standard authoring tool for the creation of home pages, VRML provides 3D worlds with integrated hyperlinks on the Web.

• Home pages become home spaces.

Page 3: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• A text file format • A simple language for describing 3-D shapes and interactive environments • A web standard

• VRML is endorsed by most 3-D graphics vendors and most web browser vendors

• Virtual environments are realized by a player (browser) that interprets, executes, and presents VRML files

1. What is VRML

Page 4: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

You can write VRML files using: • Any text editor • Many world builder applications

You can view VRML files using: • A VRML browser • A VRML plug-in to an HTML browser

such as Cortona Player or Cosmo Player

Writing and Viewing VRML Files

Page 5: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

VRML Example boink-penrose.wrl

Page 6: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

VRML files contain:

• Header • Comments - notes to yourself • Nodes - nuggets of scene information • Fields - node attributes you can change • Field Values - attribute values • Node Names - names for reusable nodes

• Nodes have field and field values that describe their attributes. Shape nodes are used to define shapes with appearance and geometry.

VRML File Format

Page 7: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Nodes can be named, and used repeatedly

DEF MyCylinder Shape { . . . } . . .

USE MyCylinder . . . USE MyCylinder

Defining Names for Nodes

Page 8: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Shapes are the building blocks of a VRML world •Primitive Shapes are standard building blocks:

• Box • Cone • Cylinder • Sphere

Example: prim.wrl

2. Building Primitive Shapes

Page 9: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Understanding Shapes

• Shape nodes describe:

• geometry - form, or structure • appearance - color and texture

Shape { geometry . . . appearance . . . }

Page 10: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Shape geometry is built with geometry nodes

• Standard, primitive geometry nodes include:

• Box { . . . } • Cone { . . . } • Cylinder { . . . } • Sphere { . . . }

Specifying Geometry

Page 11: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Geometry node fields control dimensions

Box { size 2.0 0.5 3.0 } Cone { height 3.0 bottomRadius 0.75 } Cylinder { height 2.0 radius 1.5 } Sphere { radius 1.0 }

• Dimensions are usually in meters, but they can be anything

Setting Geometry Dimension

Page 12: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

#VRML V2.0 utf8 # A Cylinder Shape { appearance Appearance { material Material { } } geometry Cylinder { height 2.0 radius 1.5 } }

Examples: cylinder.wrl

A Sample Primitive Shapes

Page 13: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• children - a list of member nodes for the group

Group { children [ Shape { . . . }, Shape { . . . }, . . . ] }

Understanding Groups

Page 14: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

A Sample GroupExample: space.wrl

Page 15: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Text Shapes build text in a VRML world

• Signs, notes, annotation, control panels

• Text shapes are flat and have no thickness

• You can choose the font family, style, size, etc.

3. Building Text Shapes

Page 16: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Text geometry nodes describe:

•text strings - the text to build •font style - how to build the text

Shape { geometry Text { string . . . fontStyle . . . } }

Understanding Text

Page 17: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Text strings list the text to build

• Each string is built on its own line or column

Text { string [ "SIGGRAPH 96", "Conference" ] }

Building Text Strings

Page 18: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Font styles have: •family - serif, sans, or typewriter •style - bold, italic, both, or none •size and spacing- character size and spacing

FontStyle { family "SERIF" style "BOLD" size 1.0 spacing 1.0 }

Specifying Font Style

Page 19: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Font styles also have: •justification - begin, middle, end •direction - left/right, up/down

FontStyle { justify "BEGIN" horizontal TRUE leftToRight TRUE topToBottom TRUE }

Specifying Font Direction

Page 20: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Shape { . . . geometry Text { string [ "SIGGRAPH 96", "Conference" ] fontStyle FontStyle { style "BOLD" } } }

Examples: sigtext.wrl

A Sample Text Shape

Page 21: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

4. Transform Shapes

• By default, all shapes are built at the center of the world

• A transform enables you to

1. Translate shapes

2. Rotate shapes

3. Scale shapes

Page 22: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•A VRML file builds components for a world

•A file's world components are built in the file's world coordinate system

Understanding Coordinate System

Page 23: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

A transform creates a coordinate system that is translated, rotated, scaled relative to a parent coordinate system

Shapes built in the new coordinate system are translated, rotated, and scaled along with it

Understanding Coordinate System Transform

Page 24: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

A Transform group node controls: •translation - position •rotation - orientation •scale - size

Transform { translation . . . rotation . . . scale . . . children [ . . . ] }

Specifying Transform

Page 25: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Translating positions a coordinate system in X, Y, and Z

Transform { # X Y Z translation 2.0 0.0 0.0 children [ . . . ] }

Translating

Page 26: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Rotating orients a coordinate system about a rotation axis by a rotation angle

•Angles are measured in radians

Transform { # X Y Z Angle rotation 0.0 0.0 1.0 0.52 children [ . . . ] }

Rotating

Page 27: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• A rotation axis defines a pole to rotate around

• Like the Earth's North-South pole

• Typical rotations are about the X, Y, or Z axes:

• Rotate about Axis X-Axis 1.0 0.0 0.0 Y-Axis 0.0 1.0 0.0 Z-Axis 0.0 0.0 1.0

Understanding Rotating Axis

Page 28: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Using the Right Hand Rule

Page 29: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Scaling grows or shrinks a coordinate system by a scaling factor in X, Y, and Z

Transform { # X Y Z scale 0.5 0.5 0.5 children [ . . . ] }

Scaling

Page 30: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Scale, Rotate, and Translate a coordinate system, one after the other

Transform { translation 2.0 0.0 0.0 rotation 0.0 0.0 1.0 0.52 scale 0.5 0.5 0.5 children [ . . . ] }

Scaling, Rotating & Translating

Page 31: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Transform { translation 4.0 0.0 0.0 rotation 0.0 1.0 0.0 0.785 scale 0.5 0.5 0.5 children [ . . . ] }

Examples: archs.wrl

A Sample Transform Group

Page 32: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

5. Controlling Appearance with Material

•The primitive shapes have a default emissive (glowing) white appearance

•You can control a shape's

Shading color Glow color Transparency

Page 33: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

The appearance of a surface is defined by setting properties that define the material from which it is made. A texture can also be defined to improve the appearance of a surface.

•material properties - color, transparency, etc.

Shape { appearance Appearance { material . . . } geometry . . . }

Understanding Appearance

Page 34: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•A Material node controls: •diffuse color - main shading color •emissive color - glowing color •transparency - opaque or not

Material { diffuseColor . . . emissiveColor . . . transparency . . . }

Understanding Materials

Page 35: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Three types of Material Reflection

•diffuseColor Color of reflected light from diffuse reflection (light scattered randomly) •ambientIntensity Amount of background light the surface reflects •specularColor Color of reflected light from specular reflection (light reflected in a regular manner)

Page 36: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Colors specify: •A mixture of red, green, and blue light •Values between 0.0 (none) and 1.0 (lots)

•Color Red Green Blue

White 1.0 1.0 1.0 Black 0.0 0.0 0.0 Yellow 1.0 1.0 0.0 Magenta 1.0 0.0 1.0 Brown 0.5 0.2 0.0

Understanding Colors

Page 37: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Shape { appearance Appearance { material Material { diffuseColor 1.0 1.0 1.0 } } geometry . . . }

Example: slabs.wrl

A Sample World using Appearance

Page 38: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Making a Shape Shining

• By specifying "high" values for the Material node's shininess field, direct light will cause a specular hilight (or shiny spot) on a shape

• By specifying a value for the Material node's specularColor field, you can control the color of specular hilights (or shiny spots) on a shape

Page 39: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

A Sample of Shape Shining

Page 40: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

6. Grouping Nodes

•Shapes can be grouped to compose more complex shapes

•VRML has several grouping nodes, including: Group { . . . } Switch { . . . } Transform { . . . } Billboard { . . . }

Page 41: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The Group node creates a basic group

•Every child node in the group is displayed

Group { children [ . . . ] }

Understanding Basic Groups

Page 42: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The Transform group node creates a group with its own coordinate system

•Every child node in the group is displayed

Transform { translation . . . rotation . . . scale . . . children [ . . . ] }

Understanding Transform Groups

Page 43: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The Switch group node creates a switched group

•Only one child node in the group is displayed

•You select which child

Switch { whichChoice 0 choice [ . . . ] }

Understanding Switching Groups

Page 44: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• The Billboard group node creates a group with a special coordinate system

• Every child node in the group is displayed

• Coordinate system is turned to face viewer

Billboard { axisOfRotation . . . children [ . . . ] }

Understanding Billboard Groups

Page 45: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•A rotation axis defines a pole to rotate round

•Similar to a Transform node's rotation field, but no angle (auto computed)

Billboard Rotation Axes

Page 46: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Group { children [ Billboard { axisOfRotation 0.0 1.0 0.0 children [ ... ] }, Transform { . . . } ] }

Example: robobill.wrl

A Sample Billboard Group

Page 47: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Inlining World Components

• VRML files describe components of a world: tables, chairs, lamps, walls, floors, doors

• Inlining combines files to build larger components: rooms, buildings, neighborhoods

Page 48: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The Inline node creates a special group

•Children are read from a VRML file selected by a URL

•Every child node in the group is displayed

Inline { url "table.wrl" }

Understanding Inlining

Page 49: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

. . . Inline { url "table.wrl" }, . . . Transform { translation . . . children [ Inline { url "chair.wrl" } ] }, . . .

Example: dinette.wrl

A Sample Inlined File

Page 50: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Adding Anchors to Your World

•Any shape or group of shapes can be an anchor

•Selecting the anchor jumps to a new VRML world •Like the <a href="page.html"> syntax of HTML

Page 51: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• The Anchor node creates a group

• Every child node in the group is displayed

• Selecting any child jumps to VRML file specified by URL

• The anchor can have a description string

Understanding Anchors

Page 52: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

A Sample Anchor

Anchor { url "stairway.wrl" description "Floating Stairs" children [ . . . ] }

Example: anchor.wrl

Page 53: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

7. Coordinate based Geometry: Points, Lines, and Faces

•Create more complex shapes than primitives

•Generate more efficient VRML worlds

•Have more control and flexibility than primitives

Page 54: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Hard to build using primitives• There's a more flexible way to describe

shapes...

Page 55: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

(1) Specifying Coordinates (Define location of "dots“)• Location of dots (points) using Coordinate node Coordinate { point [ 2.0 1.0 3.0, 4.0 2.5 5.3, . . . ] }

(2) Creating Geometry Using Coordinates (Connect the dots )• Three nodes have a coord field which accepts a Co

ordinate node • PointSet • IndexedLineSet • IndexedFaceSet

Describe Geometry in two steps

Page 56: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

PointSet Node

•A dot is drawn at each point PointSet { coord Coordinate { point [ . . . ] } color Color { color [ . . . ] }}

•No control over size of dot

•Also supports color field for Color node

Example: ptplot.wrl

Page 57: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Straight lines are drawn between points

IndexedLineSet { coord Coordinate { point [ . . . ] } coordIndex [ 1, 0, 3, -1, . . . ] }

Example: lnplot.wrl

IndexedLineSet Node

Page 58: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

coordIndex [ 1, 0, 3, -1, . . . ]

•Indexes reference ordered points of coord field •Index order is arbitrary (eg: 1, 0) •Indexes are Zero-based (eg: 0) •Can skip coordinates (eg: 0, 3) •Poly-line can be many points (eg: 1, 0, 3) •End of poly-line (eg: -1) •Multiple poly-lines (eg: . . .)

CoordIndex Value

Page 59: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

IndexedFaceSet Node

•Faces are drawn within perimeter of points

IndexedFaceSet { coord Coordinate { point [ . . . ] } coordIndex [ 1, 0, 3, -1, . . . ] }

Example: vase1.wrl

Page 60: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

8. Binding Color to Coordinate based Geometry

•Override Material node (overall color)

•Better color control for IndexedFaceSet, IndexedLineSet, PointSet, and ElevationGrid nodes

•Apply color per-face or per-vertex

Page 61: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The Color node is used as the color field value of IndexedFaceSet, IndexedLineSet, PointSet or ElevationGrid nodes

•The Color node contains a list of RGB values

Color { color [ 1.0 0.0 0.0, . . . ] }

Color Node

Page 62: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

IndexedFaceSet { coord Coordinate { . . . } coordIndex [ . . . ] color Color { color [ 1.0 0.0 0.0, . . . ] } colorIndex [ 3, 0, 1, . . . ] colorPerVertex TRUE }

IndexedFaceSet using a color node

Page 63: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•In IndexedFaceSet, IndexedLineSet nodes

•When colorPerVertex is TRUE, specify one color index per coordinate index (don't forget to account for the -1's !)

•When colorPerVertex is FALSE, specify one color index per face or line (eg. per -1)

ColorPerVertexField

Page 64: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Colored triangles: per-face and per-vertex

•Example: color_face.wrl, color_vertex.wrl

A sample Color Binding

Page 65: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

9. Mapping Texture

•Wrap images around shapes •Apply an image as an opaque "decal" •Apply an image with transparent "holes"

•Wrap a movie's images around shapes

•Add realistic appearance to shapes

Page 66: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Texture color overrides Material node color

•Appearance node's texture field wraps an image around geometry

•The texture can be an ImageTexture, MovieTexture, or PixelTexture

Texture Property

Page 67: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Appearance { material Material {} texture ImageTexture { url "myimage.jpg" } }

ImageTexture Node

Page 68: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Appearance { texture MovieTexture { url "mymovie.mpg" speed 1 loop FALSE } }

MovieTexture Node

Page 69: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The PixelTexture node contains data stored as width, height, number of channels, followed by width*height hex values representing the image

•Example: A 2x4 RGB image

PixelTexture { image 2 4 3 0xFF0000 0x00FF00 0 0 0 0 0xFFFFFF 0xFFFF00 }

PixelTexture Node

Page 70: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

A sample Texture Mapping

Example: can.wrl

Page 71: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

10. Texture Control

When applying a texture, you sometimes need to control:

• What piece of a texture is extracted from an image

• How the piece of texture is applied to a face

Page 72: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

I. Build cookie cutter of desired size and shape

II. Set position, rotation and scale over sheet

III. Extract a piece of dough from sheet, and apply extracted piece of dough onto shape

Three steps to apply a piece of texture

Page 73: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

texCoord TextureCoordinate { point [ 0.2 0.2, 0.8 0.2, 0.8 0.8, 0.2 0.8 ] }

• Note: texCoord is a field of IndexedFaceSet, ElevationGrid nodes

I. Build Cookie Cutter Shape

Page 74: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Appearance node's textureTransform field sets position, rotation and scale of cutter over the dough

TextureTransform { translation 0.5 0.5 rotation 0.0 scale 2.0 2.0 }

II. Texture Transform

Page 75: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• IndexedFaceSet extracts and applies the piece of texture to faces

IndexedFaceSet { coord Coordinate { . . . } coordIndex [ . . . ] texCoord TextureCoordinate { . . . } texCoordIndex [ . . . ] }

III. Extract and Apply Texture

Page 76: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Texture Transform: Scale

TextureTransform { scale 3.0 3.0 }

Page 77: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Texture Transform: Transform

TextureTransform { translation 0.166 0.0 } # 1/6

Page 78: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Texture Transform: Rotation

TextureTransform { rotation 0.785 # 45 degrees }

Page 79: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

11. Shading Control using Normals

•Normals define the direction of faces

•Faces used to approximate smooth surfaces, but normals can be used to control whether a surface is flat or smoothly shaded

•Default Normals are often good enough !

Page 80: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•To control shading of ElevationGrid, and IndexedFaceSet nodes

•Specify normal, normalIndex, and normalPerVertex field values or…

•Set the creaseAngle field to automatically generate normals

Shading Control Tools

Page 81: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•The normal field specifies face direction

Normal { vector [ 1.0 0.0 0.0, 0.0 1.0 0.0, 0.0 0.0 1.0, . . . ] }

Normal Node

Page 82: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

CreaseAngle Field

•If angle between adjacent faces is larger than creaseAngle, then faces are flat shaded.•If angle between adjacent faces is smaller than creaseAngle, then faces are smoothly shaded.

Page 83: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Shading

Flat• Surface colored uniformly according to its orientation towards light sources • Faceted appearance

Smooth (Gouraud)• Each vertex is assigned a color according to its orientation towards light sources and intermediate points are a blend of the surrounding vertex colors • Smooth shading • Can be too smooth (can smooth away detail)

Page 84: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

12. Lights

•Light sources illuminate and effect shading of faces

•Several types of lights available for maximum control •Lights do not cast shadows

Page 85: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Three different light nodes

•PointLight, DirectionalLight, SpotLight

•Standard fields (common to all 3) and defaults:

•on TRUE •intensity 1.0 •ambientIntensity 0.0 •color 1.0 1.0 1.0

Light Node

Page 86: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Point lights have a location and glow radially

PointLight { # Standard fields, plus: location 0.0 0.0 0.0 radius 1.0 #specifies the maximum distance for the light rays to travel

attenuation 1.0 0.0 0.0 }

PointLight Node

2

1

cdbdafactornattenuatio

Page 87: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Directional lights point in a specified direction

DirectionalLight { # Standard fields, plus: direction 1.0 0.0 0.0 }

Directional Light

Page 88: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Spot lights point in a direction and focus in a cone

SpotLight { # Standard fields, plus: location 0.0 0.0 0.0 direction 1.0 0.0 0.0 cutOffAngle 0.785 radius 1.0 attenuation 1.0 0.0 0.0 }

Spot Light

Page 89: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Backgrounds add realism to VRML worlds

•Backgrounds are cheaper than using geometry •Backgrounds always stay "infinitely distant"

13. Background

Page 90: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Two types of background (can be combined)

•Backdrop: Sky and Ground color gradients(Mapped to inside of a sphere)

•Panorama: Surrounding images(Mapped to inside faces of a cube)

Backdrop vs. Panorama

Page 91: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•xxxColor specifies color values

•xxxAngle specifies angles in radians (0 .. PI)

Background { groundColor [ .14 .28 0, .09 .11 0, 0, 0, 0 ] groundAngle [ .785, 1.57 ] skyColor [ .02 0 .26, .02 0 .65, 0, 0, 0 ] skyAngle [ .785, 1.57 ] }

Example: m_bkgd1.wrl

Specifying Backdrop

Page 92: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Specifying Panorama

•xxxUrl fields specify images

•Images overlay backdrop (if any)(backdrop shows through transparent regions)

Background { frontUrl "f_image.jpg" backUrl "b_image.jpg" leftUrl "l_image.jpg" rightUrl "r_image.jpg" }

Example: m_bkgd2.wrl

Page 93: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Fog is a "special effect" for added realism

•Exact effects (if any) are browser dependent

•Colors "fade" to a specified value over distance

14. Fog

Page 94: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

VRML Fog Example#VRML V2.0 utf8 Group { children [ ... Fog { color 1.0 1.0 1.0 fogType "EXPONENTIAL" visibilityRange 30.0 } ] }

Fog Node

Page 95: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Fog can be used to provide a depth cue, add atmosphere, and increase realism

•Colors fade to value specified in color field.

•visibilityRange specifies distance at which fog color predominates. Value 0 disables node.

Example: fog1.wrl, fog2.wrl, fog4.wrl

Fog Example

Page 96: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

15. Level of Detail

•LOD (Level Of Detail):

•Can reduce "upfront" download time(have simpler models loaded first)

•Can improve frame rate(use simpler models for far away objects)

•Useful as a depth cue

Page 97: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• An object is rendered with more detail when a user is close to it than when the user is far away

• An object can have several levels of detail, each valid for a different range of distances

• Hardware assist the transition between levels of detail to make them as smooth as possible

Levels of Detail

Page 98: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Range specifies distance from center of LOD to viewer (for each transition between levels) •Grouping node (one child displayed at a time).

LOD { range [ . . . ] center 0 0 0 level [ . . . ] }

LOD Node

Page 99: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Using Ranges

•List range values in increasing order.

•Define children in order of highest to lowest detail.

•For N ranges, provide N+1 children

range [ 20, 100 ] < 20 m 1st child used >= 20 & < 100 m 2nd child used >= 100 m 3rd child used

Example: m_lod1.wrl, m_lod2.wrl

Page 100: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Making good levels of detail is tricky. •Two or three levels are usually enough. •Remove "details" that are easy to remove•Simplify geometry if appropriate

•Everything is a hint!(Browser decides which level to display.) •LOD can get large, use Inline for some kids.

•Don't use LOD to simulate behavior. •center is not a translation.

Optimizing Strategy

Page 101: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Primarily used to define named camera positions

•Browser will usually present a list of viewpoints using their description strings.

•Browser may animate between viewpoints.

16. Controlling the View Point

Page 102: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Using Viewpoint

• Orientation defines direction of view and "up" direction (relative to default orientation). Rotation

Viewpoint { position 0 0 9 orientation 0 0 1 0 description "DefaultView" }

Example:m_vwpts1.wrl

Page 103: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

• Sound adds realism and allows special effects • General uses:

1. Continuous background (traffic, muzak, ...) 2. Continuous localized (waterfall, monster, ...) 3. Triggered (bumping wall, clicking switch, ...)

17. Adding Sound

Page 104: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•A Signal •AudioClip or MovieTexture Node •Think of this as the "CD player"

•A Location •Sound Node •Think of this as the "speaker"

CD Player vs. Speaker

Page 105: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•AudioClip specifies a signal •Typically .wav or .mid file •Start time, pitch, looping or not

•Sound specifies a place •Location, direction, attenuation region •Intensity, "spatialized" or not

AudioClip vs. Sound

Page 106: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Playback started by: •Setting startTime field

•Setting loop to TRUE

AudioClip { url [ . . . ] loop FALSE startTime 0 }

AudioClip Node

Page 107: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Audible if clip is playing and node is "traversed"

Sound { source AudioClip { . . . } intensity 1 location 0 0 0 direction 0 0 1 spatialize TRUE }

Basic Sound Node

Page 108: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Advanced Sound Node

•Defines two ellipsoids aligned with direction

•Full intensity within inner ellipsoid

•Intensity drops to zero between inner and outer

Sound { . . . minFront 1 maxFront 10 minBack 1 maxBack 10 }

Page 109: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Page 110: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•In AudioClip node set •loop field to TRUE (Will start on entering world)

•In Sound node set •minFront and minBack to large values. •spatialize to FALSE (stereo clip will play as stereo)

Example: m_sound1.wrl

Continuous Background Sound

Page 111: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•Set AudioClip node same as previous. •In Sound node set

•position and direction •minFront, maxFront, ... values •spatialize to TRUE (clip will play as monaural)

Example: m_sound2.wrl

Continuous Localized Sound

Page 112: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

•In AudioClip node set •loop field to FALSE (for a "one shot") •startTime each time sound should play (discussed later)

•In Sound node set •location, direction, ... •spatialize to TRUE (usually)

Example: m_sound3.wrl

Triggered Sound

Page 113: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

18. Fields and Events

• Each node has specific fields and events

1. Field : A stored value (parameter), eg. url 2. EventIn : An event node can receive, eg. set_url 3. EventOut : An event node can send, eg. url_changed

• Event: A message that contains a data value

Page 114: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

Routes

•Route: Connects an EventOut to an EventIn

•A Route is not a node!

•Output type must match input type exactly

•Output may connect to multiple inputs (fan-out)

•Multiple outputs may connect to single input (fan-in)

•Nodes must be named in order to use Routes

Page 115: CVVR Lab.@ National Dong Hwa Univ. 國立東華大學 VRML Virtual Reality Modeling Language

CVVR Lab.@ National Dong Hwa Univ. 國立東華大學

DEF NODE1 Collision { . . . } DEF NODE2 AudioClip { . . . } ROUTE NODE1.CollideTime TO NODE2.startTime

Example: m_route.wrl

Route Example