81
1 Basic Modelling

1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

Embed Size (px)

Citation preview

Page 1: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

1

Basic Modelling

Page 2: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

2

Lecture ObjectivesLecture Objectives

To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered on a display

To understand how to deliver interactive animated 3D graphics over the Internet

To be able to create interactive 3D graphics applications using industry standard software (OpenGL and VRML)

Page 3: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

3

The BasicsThe Basics

MODELLING– representing objects in 3D– transforming objects and composing scenes

VIEWING– projecting 3D scenes onto a 2D display

surface RENDERING

– illumination– shading– adding realism via textures, shadows

Page 4: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

4

Basic ModellingBasic Modelling

x

y

z

objects representedas set of faces - iepolygons- and facesas a set of points

scenes composedby scaling, rotating,translating objects tocreate a 3D world

Page 5: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

5

ViewingViewing

Clipping– selects a volume of interest– Projection– 3D scene is projected onto a 2D

plane

camera

Page 6: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

6

RenderingRendering

shading:how do we use ourknowledge of illuminationto shade surfaces in ourworld?

illumination:how is light reflectedfrom surfaces?

Page 7: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

7

RenderingRendering

texture

shadows

Page 8: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

8

InternetInternet

VRML– ISO standard for 3D graphics over

the Web– allows modelling of geometry,

appearance and behaviour

Page 9: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

9

Advanced RenderingAdvanced Rendering

ADVANCED RENDERING– direct versus global illumination

methods– ray tracing and radiosity

OTHER ADVANCED FEATURES– curve and surface modelling– image based rendering– non-photorealistic rendering

Page 10: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

10

Advanced RenderingAdvanced Rendering

Advanced Rendering - global illumination– ray tracing

– radiositybased on physics of radioactive heat

transfer between surfaces

light

eye

screen

objects

Page 11: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

11

Before we begin...mathematics!Before we begin...mathematics!

3D Co-ordinate Systems

LEFT RIGHT

x

yz

x

y

z

z points away z points toward

Align thumb with x, first finger with y, then second fingerof appropriate hand gives z direction. Common now touse a RIGHT HANDED system.

Page 12: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

12

Points and VectorsPoints and Vectors

We shall write points as column vectors

xyz

P =

Difference of two points gives a direction vector:D = P2 - P1

x

y

z

P2

P1

x

y

z

P

Note: If P1 and P2are on a plane, thenD lies in the plane

Page 13: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

13

Polygonal RepresentationPolygonal Representation

Any 3D object can be represented as a set of plane, polygonal surfaces

V1

V2V3

V4

V5V8

V7 V6

Note: each vertex part of severalpolygons

Page 14: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

14

Polygonal RepresentationPolygonal Representation

Objects with curved surfaces can be approximated by polygons - improved approximation by more polygons

Page 15: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

15

Scene OrganisationScene Organisation

Scene = list of objects Object = list of surfaces Surface = list of polygons Polygon = list of vertices

scene

objectsurfaces polygons

vertices

Page 16: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

16

Polygon Data StructurePolygon Data Structure

V1

V2V3

V4

V5V8

V7 V6

P1

P2

Object Table

Obj1P1, P2, P3,P4, P5, P6

Object Obj1

Vertex Table

V1X1, Y1, Z1

V2X2, Y2, Z2

. ...

Polygon Table

P1 V1, V2, V3, V4

P2 V1, V5, V6, V2

. ...

Page 17: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

17

Typical PrimitivesTypical Primitives

Graphics systems such as OpenGL typically support:– triangles, triangle strips and fans– quads, quad strips– polygons

Which way is front?– convention is that normal points

towards you if vertices are specified counter-clockwise

Page 18: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

18

Modelling Regular ObjectsModelling Regular Objects

Sweeping

Spinning

2D Profilesweep axis

spinning axis

R1 R2

Page 19: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

19

Sweeping a Circle to Generate a Cylinder as Polygons

Sweeping a Circle to Generate a Cylinder as Polygons

vertices at z=0

vertices at z=depthV1

V2

V3V4

V5

V6 V8

V7

V10

V9

V11

V12V13

V14

V15V16

V17

V18

V1[x] = R; V1[y] = 0; V1[z] = 0V2[x] = R cos ; V2[y] = R sin ; V2[z] = 0 (=/4)Vk[x] = R cos k; Vk[y] = R sin k; Vk[z] = 0wherek = 2 (k - 1 )/8, k=1,2,..8

Page 20: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

20

Complex PrimitivesComplex Primitives

Some systems such as VRML have cylinders, cones, etc as primitives– polygonal representation calculated

automatically OpenGL has a utility library (GLU)

which contains various high-level primitives– again converted to polygons

For conventional graphics hardware:– POLYGONS RULE!

Page 21: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

21

Automatic Generation of Polygonal Objects

Automatic Generation of Polygonal Objects

3D scanners - or laser rangers - are able to generate computer representations of objects– object sits on rotating table– contour outline generated for a

given height– scanner moves up a level and next

contour created– successive contours stitched

together to give polygonal representation

Page 22: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

22

A PuzzleA Puzzle

Page 23: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

23

Modelling Objects and Creating Worlds

Modelling Objects and Creating Worlds

We have seen how boundary boundary representations representations of simple objects can be created

Typically each object is created in its own co-ordinate systemco-ordinate system

To create a world, we need to understand how to transform objects so as to place them in the right place - translationtranslation, at the right size - scalingscaling, in the right orientation- rotationrotation

Page 24: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

24

TransformationsTransformations

The basic linear transformations are:– translation: P = P + T, where T is

translation vector– scaling: P’ = S P, where S is a scaling

matrix– rotation: P’ = R P, where R is a rotation

matrix As in 2D graphics, we use

homogeneoushomogeneous co-ordinates in order to express all transformations as matrices and allow them to be combined easily

Page 25: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

25

Homogeneous Co-ordinatesHomogeneous Co-ordinates

In homogeneous coordinates, a 3D point P = (x,y,z)T

is represented as:P = (x,y,z,1)T

That is, a point in 4D space, with its ‘extra’ co-ordinate equal to 1

NoteNote: in homogeneous co-ordinates, multiplication by a constant leaves point unchanged– ie (x, y, z, 1)T = (wx, wy, wz, w)T

Page 26: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

26

TranslationTranslation

Suppose we want to translate P (x,y,z)T by a distance (Tx, Ty, Tz)T

We express P as (x, y, z, 1)T and form a translation matrix T as below

The translated point is P’

T P

x’y’z’1

P’ =

1 0 0 Tx0 1 0 Ty0 0 1 Tz0 0 0 1

xyz1

= x + Txy + Tyz + Tz1

=

Page 27: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

27

ScalingScaling

Scaling by Sx, Sy, Sz relative to relative to the originthe origin:

x’y’z’1

Sx 0 0 00 Sy 0 00 0 Sz 00 0 0 1

xyz1

P’ = S P

= = Sx . xSy . ySz . z1

Page 28: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

28

RotationRotation

Rotation is specified with with respect to an axis respect to an axis - easiest to start with co-ordinate axes

To rotate about the x-axis:

a positive angle corresponds to counter-clockwise direction lookingat origin from positive position on axis

x’y’z’1

= 1 0 0 00 cos -sin 00 sin cos 00 0 0 1

xyz1

P’ = Rz () P

Page 29: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

29

Composite TransformationsComposite Transformations

The attraction of homogeneous co-ordinates is that a sequence of transformations may be encapsulated as a single matrix

For example, scaling with respect to a with respect to a fixed position (a,b,c) fixed position (a,b,c) can be achieved by:– translate fixed point to origin- say, T(-a,-b,-c)– scale- S– translate fixed point back to its starting

position- T(a,b,c) Thus: P’ = T(a,b,c) S T(-a,-b,-c) P = M P

Page 30: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

30

Rotation about a Specified AxisRotation about a Specified Axis

It is useful to be able to rotate about any axis in 3D space

This is achieved by composing 7 elementary transformations

Page 31: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

31

Rotation through about Specified Axis

Rotation through about Specified Axis

x

y

z

x

y

zrotate throughrequ’d angle,

x

y

z

x

y

z

P2

P1x

y

z

P2

P1x

y

z

initial positiontranslate P1to origin

rotate so that P2 lies on z-axis(2 rotations)

rotate axisto orig orientation

translate back

Page 32: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

32

Inverse TransformationsInverse Transformations

As in this example, it is often useful to calculate the inverse of a transformation– ie the transformation that returns to

original state Translation: T-1 (a, b, c) = T (-a, -

b, -c) Scaling: S-1 ( Sx, Sy, Sz ) =

S ............ Rotation: R-1

z () = Rz (-)

Page 33: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

33

Viewing - Projections

SEN 992 Computer Graphics ISEN 992 Computer Graphics I

Page 34: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

34

ViewingViewing

Graphics display devices are 2D rectangular screens

Hence we need to understand how to transform our 3D world to a 2D surface

This involves:– selecting the observer position observer position (or

camera position)– selecting the view plane view plane (or camera film

plane)– selecting the type of projectionprojection

Page 35: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

35

Perspective ProjectionsPerspective Projections

There are two types of projection: perspectiveperspective and parallelparallel

In a perspectiveperspective projection, object positions are projected onto the view plane along lines which converge at the observerP1

P2

P1’

P2’

view plane

camera

Page 36: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

36

Parallel ProjectionParallel Projection

In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallelP1

P2

view plane

Page 37: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

37

Perspective and Parallel Projection

Perspective and Parallel Projection

Parallel projection preserves the relative proportions of objects, but does not give a realistic view

Perspective projection gives realistic views, but does not preserve proportions– Projections of distant objects are

smaller than projections of objects of the same size which are closer to the view plane

Page 38: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

38

Perspective and Parallel Projection

Perspective and Parallel Projection

perspective parallel

Page 39: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

39

Viewing Coordinate SystemViewing Coordinate System

Viewing is easier if we work in a viewing co-ordinate systemviewing co-ordinate system, where the observer or camera position is on the z-axis, looking along the negative z-direction

xV

yV

zV

Camera is positioned at:(0 , 0, zC)

Page 40: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

40

View PlaneView Plane

We assume the view plane is perpendicular to the viewing direction

The view planeis positioned at:(0, 0, zVP)

Let d = zC - zVP be thedistance between thecamera and the plane

xv

yv

zv

Page 41: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

41

Perspective Projection CalculationPerspective Projection Calculation

xv

yv

zv

zVview plane

Q

camerayV

zCzQ zVP

looking along x-axis

Page 42: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

42

Perspective Projection CalculationPerspective Projection Calculation

zVview plane

Q

camerayV

P

By similar triangles, yP / yQ = (zC - zVP) / (zC - zQ)and soyP = yQ * (zC - zVP) / (zC - zQ)oryP = yQ * d / (zC - zQ)

zCzQ zVP

xP likewise

Page 43: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

43

Transformation Matrix for Perspective

Transformation Matrix for Perspective

1 0 0 0

0 1 0 0

0 0 -zVP/d zVPzC/d

0 0 -1/d zC/d

xQ

yQ

zQ

1

xH

yH

zH

wH

=

Then xP = xH / wH

iexP = xH / ( (zC - zQ) / d )iexP = xQ / ( (zC - zQ) / d )

yP likewise

Page 44: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

44

Note for LaterNote for Later

The original z co-ordinate of points is retained – we need relative depth in the scene

in order to sort out which faces are visible to the camera

Page 45: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

45

Vanishing PointsVanishing Points

When a 3D object is projected onto a view plane using perspective, parallel lines in object NOT parallel to the view plane converge to a vanishing vanishing pointpoint

view plane

vanishing point

one-pointperspectiveprojectionof cube

Page 46: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

46

One- and Two-Point Perspective Drawing

One- and Two-Point Perspective Drawing

Page 47: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

47

One-point PerspectiveOne-point Perspective

Said to be the firstpainting in perspective

This is:Trinity with the Virgin,St John and Donors,by Mastaccio in 1427

Page 48: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

48

Two-point PerspectiveTwo-point Perspective

EdwardHopperLighthouseat Two Lights

-seewww.postershop.com

Page 49: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

49

Parallel Projection - Two typesParallel Projection - Two types

OrthographicOrthographic parallel projection has view plane perpendicular to direction of projection

ObliqueOblique parallel projection has view plane at an oblique angle to direction of projection

P1

P2

view plane

P1

P2

view plane

We shall only consider orthographic projectionorthographic projection

Page 50: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

50

Parallel Projection Calculation

Parallel Projection Calculation

xv

yv

zv

zVview plane

Q

yV

zQ zVP

looking along x-axis

Page 51: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

51

Parallel Projection CalculationParallel Projection Calculation

zVview plane

Q

yV

P

yP = yQ

and similarly xP = xQ

Page 52: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

52

Parallel Projection CalculationParallel Projection Calculation

So this is much easier than perspective!– xP = xQ

– yP = yQ

– zP = zVP

The transformation matrix is simply1 0 0 0

0 1 0 00 0 zVP/zQ 00 0 0 1

Page 53: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

53

View Volumes - View WindowView Volumes - View Window

Type of lens in a camera is one factor which determines how much of the view is captured– wide angle lens captures more than

regular lens Analogy in computer graphics is the

view windowview window, a rectangle in the view plane

xv

yv

zv

view window

Page 54: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

54

View Volume - Front and Back Planes

View Volume - Front and Back Planes

We will also typically want to limit the view in the zV direction

We define two planes, each parallel to the view plane, to achieve this– front plane (or near plane)– back plane (or far plane)

front planeback plane

zV

Page 55: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

55

View Frustum - Perspective Projection

View Frustum - Perspective Projection

view window

backplane

frontplane

camera

view frustum

zV

Page 56: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

56

View Volume - Parallel ProjectionView Volume - Parallel Projection

view window

backplane

frontplane

zV

view volume

Page 57: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

57

View VolumeView Volume

The front and back planes act as important clipping planesclipping planes

Can be used to select part of a scene we want to view

Front plane Front plane important in perspective to remove near objects which will swamp picture

Page 58: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

58

VRML - An Introduction

SEN 992 Computer Graphics ISEN 992 Computer Graphics I

Page 59: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

59

Good Ideas are SimpleGood Ideas are Simple

Realization 1:– Hypertext + Internet = World Wide Web

Realization 2:– Adding images makes pages more interesting

Realization 3:– Images are pictures taken by the publisher -

why not send 3D scenes and allow the user to take the picture!

VRML: Virtual Reality Modelling Language– a language to describe 3D worlds - for the

Web

Page 60: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

60

World Wide Web PagesWorld Wide Web Pages

AUTHORINGPROCESS HTML

file

server

INTERNET

client

WEBBROWSER

text/html

.htmlMIMEtype

Page 61: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

61

VRMLVRML

AUTHORINGPROCESS VRML

file

server

INTERNET

client

VRMLBROWSER

x-world/x-vrml

.wrl

Major browser:CosmoPlayer

Page 62: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

62

Advantages of VRMLAdvantages of VRML

Transferring a 3D model - rather than a 2D image - to the browser has great advantages– viewer can choose how to look at

the model - or world– viewer can navigate the world– file size can often be much less

Page 63: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

63

How Did It All Begin?How Did It All Begin?

Original brainwave– Mark Pesce and Tony Parisi - early 1994– vision of a VR interface to the Web

VRML 1.0– practical realisation based on Open

Inventor (Silicon Graphics toolkit - similar to OpenGL but higher level)

– Open Inventor file format PLUS hyperlinks

– static, non-interactive worlds– Gavin Bell (SGI) - late 1994

Page 64: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

64

Where are we now?Where are we now?

VRML97– adds object behaviours and

interaction to allow creation of dynamicdynamic worlds

– ISO standard - December 1997– Gavin Bell, Rikk Carey (ex-SGI) and

Chris Marrin (SGI) 2000

– being reworked as XML (X3D)– many new developments

Page 65: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

65

A VRML FileA VRML File

VRML file consists of:

header nodes

– objects such as cylinders and spheres

– operations such as transformations

fields– parameters of

nodes

#VRML V2.0 utf8Shape {

geometry Cylinder {

radius3height 6

}}

Page 66: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

66

As Seen By A BrowserAs Seen By A Browser

#VRML V2.0 utf8

Shape {

geometry Cylinder {

radius2

height 4

}

}

Page 67: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

67

Adding Color to the SceneAdding Color to the Scene

#VRML V2.0 utf8

Shape {

geometry Cylinder {

radius 2

height 4

}

appearance Appearance {

material Material {

diffuseColor 1 0 0

specularColor 1 1 1 }

}

}

Page 68: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

68

Co-ordinate SystemsCo-ordinate Systems

Each node is drawn within its own local co-ordinate system..

x

z

y

Page 69: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

69

Modelling TransformationsModelling Transformations

...and can be subjected to a modelling transformation to scale, rotate, translate

Transform is a VRML node - treated just like an object

It applies to a group of children nodes

#VRML V2.0 utf8

Transform{

scale 5.0 0.5 1.0

children [

Shape {

geometry Cylinder {

radius 2

height 4

}

appearance Appearance {

material Material {

diffuseColor 1 0 0

specularColor 1 1 1 }

} } ] }

Page 70: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

70

Hierarchical StructureHierarchical Structure

#VRML V2.0 utf8

Transform{

scale 5.0 0.5 1.0

children [

Shape {

geometry Cylinder {

radius 2

height 4

}

appearance Appearance {

material Material {

diffuseColor 1 0 0

specularColor 1 1 1 }

} } ] }

TRANSFORM

SHAPE

parent

child

Page 71: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

71

Hierarchical StructureHierarchical Structure

This generalises to allow nodes to appear in a hierarchy

This is known as the VRML scene scene graphgraph

TRANSFORM

SHAPE TRANSFORM

SHAPE SHAPE

Page 72: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

72

TransformationsTransformations

Here we see Cylinder, Sphere and Cone nodes

Each has been subjected to a modelling transformation in order to position them

Page 73: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

73

InstancesInstances

A node can be given a ‘name’ and then used multiple times - with different transformations applied to each

DEF kwb Shape {...} gives it a name

USE kwb allows it to be included at other points in the scene graph

Page 74: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

74

AnchorsAnchors

A piece of geometry can act as a link to another URL

Page 75: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

75

TexturesTextures

Texture mapping: Images can be mapped to geometry to provide texturing

VRML looks like:Shape{

geometry Sphere { }

appearance Appearance{

texture ImageTexture{

url “http://..../kwb.gif”}

Page 76: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

76

Polygonal SurfacesPolygonal Surfaces

The general primitive for drawing polygonal surfaces is:

– IndexedFaceSet– coord field lists

the points– coordIndex

describes the polygons

Shape{geometry IndexedFaceSet {

coord Coordinate {point [ 17.5 11.2 -

1.2,17.5 15.0 -

1.2,… ]}

coordIndex [ 0 1 2 3 -1,4 1 0 5 -1,…]

}}

Page 77: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

77

LightsLights

VRML includes:– DirectionalLight– PointLight– SpotLight

Note # sign is a comment

Example:

PointLight{

on TRUE

intensity 0.75

color 1 0 0 #red

location 0 0 0

radius 100

}

Page 78: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

78

Viewing Viewing

Specified via the Viewpoint node

VRML file can have a number of Viewpoint nodes - browsers allow a user to jump from one viewpoint to another

Orientation = axis + angle of rotation

Example:

Viewpoint {

position 0 0 5

orientation 0 0 1 0.3

description“frontview”

}

Page 79: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

79

Other Basic FeaturesOther Basic Features

Inline node– incorporate VRML code from

another url– this allows us to composecompose large

worlds from many smaller ones Level of Detail

– different geometric representations depending on distance

Page 80: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

80

Information About VRMLInformation About VRML

Web3D Consortium– http://www.web3d.org– links to specifications and resources

Web3D Information– http://web3d.about.com/compute/web3d

Leeds University VRML/Java3D Information Centre – http://www.scs.leeds.ac.uk/vrmljava3d

VRML Repository– http://www.sdsc.edu/vrml/

Page 81: 1 Basic Modelling. 2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered

81

Range of books now available– The VRML 2.0 Handbook (Addison Wesley)

Jed Hartman and Josie Wernecke

http://vrml.sgi.com/handbook– The Annotated VRML Reference Book (Addison

Wesley)

Rikk Carey and Gavin Bell

http://www.best.com/~rikk/Book/ Tutorials include:

– Floppy’s guide: www.vapourtech.com/vrmlguide

Books and TutorialsBooks and Tutorials