[email protected] 3 d computer graphics. [email protected] the virtual world space in...

33
[email protected] 1 3 D Computer Graphics

Post on 19-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 1

3 D Computer Graphics

Page 2: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 2

The Virtual World Space

In order to render coloured images of a virtual world, knowledge of geometric basis or set of rules needed The Cartesian system: a set of 3D axes where each

axis is orthogonal (90 o) to the other two

assume all Cartesian coordinate systems are right-handed, and the vertical axis is always the y-axis

Page 3: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 3

Positioning the Virtual Observer(VO)

Procedure depends on the VO’s frame of reference within the VE which may involve Direction cosines XYZ fixed angles XYZ Euler angles or quaternions

Page 4: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 4

Direction cosines

A unit 3D vector has three axial components which are also equal to the cosines of the angles formed between the vector and the three axes

the angles are known as direction cosines and can be computed by taking dot products of the vector and the axial unit vectors

the direction cosine enable any point P(x,y,z) in one frame of reference to be transformed into P’(x’,y’,z’)

Xw

Zw

Yw

v

αγ

β

Page 5: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 5

Cont.

x’ r11 r12 r13 x

y’ = r21 r22 r23 y

z’ r31 r32 r33 z

where:

r11 r12 r13 are the direction cosines of the secondary x-axis

r21 r22 r23 are the direction cosines of the secondary y-axis

r31 r32 r33 are the direction cosines of the secondary z-axis

Example 1: shows that (x’,y’,z’)= (x,y,z)

x’ 1 0 0 xy’ = 0 1 0 yz’ 0 0 1 z

XwZw

Yw

P’(x’,y’,z’) = P(x,y,z)

XVO

YVO

ZVOAs the two axial system are coincident, any point P’= P

Page 6: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 6

XYZ fixed angles

Another approach for specifying orientation

3 separate rotations about a fix frame of reference, angles referred to as

yaw: angle of rotation about the y-axis

pitch: angle of rotation about the x-axis

roll: angle of rotation about the z-axis Xw

Zw

Yw

yaw

rollpitch

Page 7: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 7

The perspective projection

Control of perspectives Field of view

Page 8: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 8

Stereo perspective projection

Stereoscopic vision helps us estimate depth and works up to distances of approximately 30 m - beyond this disparity between the images in left and right eyes is significant

Projection plane

Left eye Right eye

Xvo

Yvo

Zvo

Se

To compute the perspective projection of the box for the right eye, the box’s x-coordinates are translated by Se/2 and for the left eye the box’s x-coordinate are translated by - Se/2

Page 9: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 9

Cont. The viewing plane is

located d from the origin and the interocular distance is Se.. Any point on the object P(x,y,z) must now be translated - Se/2:

xpl = x- Se/2

d z+ d

left eye place at origin

Xvo

Zvo

- Se/2

zxpl

d

Left eye Right eyeVO

P(x,y,z)

A plan elevation of the geometry relating the VO’s left eye the projection plane and the box

Page 10: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 10

Yvo

Zvo

z

ypl

d

Left eye

Projection plane

P(x,y,z)

y

ypl = yd z+ d

left eye place at origin

A side elevation of the geometry relating the VO’s left eye, the projection plane and the box

Page 11: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 11

Similar equation for the right eye

xpr = x +Se/2

d z + d

ypr = yd z+ d

•In order to see an object in focus as a single fused image, we must focus and allow both eyes to fixate upon the object by adjusting their convergence angle (natural 3D view)

•however, computer model does not include any convergence angle

•it assumes the two eyes are gazing at infinity

•we will see two overlapping views of an object

•to simulate convergence overlap images in the HMD using diverging or converging optics

Page 12: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 12

3 D clipping

There are many occasions when part of an object is visible and the rest is invisible which implies that every object must be trimmed or clipped against some visible viewing envelope or volume

3D clipping must be applied separately for the left and right eyes

Page 13: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 13

Left eyeRight eye

Xvo

Yvo

Zvo

The two viewing volumes associated with left and right eyes

3 D clipping

Page 14: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 14

Right eye

Near (hither) plane

Projection plane

Far (yon) plane

A single viewing frustum (a truncated pyramid) with near, projection and far plane

3 D clipping

Page 15: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 15

Clipping algorithms

to establish as efficiently as possible whether an object requires clipping or not

example if every object has an associated rectangular bounding box that completely contains the object, and if every vertex of the box is visible than the object must be completely visible

2 popular methods Cohen-Sutherland: employs a 6 bit code to describe

whter the end of a line is visible or not Cyrus-Beck: clips lines against a 3D convex

polyhedron using a parametric definition of a 3D line.

Page 16: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 16

Back-face removal Clipping is computationally expensive process Any way of reducing the number of polygons to be

clipped must be investigated. This can be done by the back-face removal technique.

A

B

na

θa nb

θb

Vb

va

YVO

ZVO

XVO

cosθa = na . va

| na | | va | If cosθa is positive then the surface is visible otherwise it is invisible. In diagram above, A is visible to the VO as θa is less than 90o, whereas surface B is invisible as θb is greater than 90o

Page 17: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 17

Simple 3D modelling

Geometric considerations Euler’s rule: a polyhedron without holes have the number of

edges is always the sum of the faces and vertices minus two:Edges = faces + vertices -2

Surface normal: can be determined by the cross product of two edges

Surface planarity: forms the boundary of an object. If a polygon is defined as a chain of arbitrary edges, it will be very easy to construct twisted surfaces

Modelling tools databases containing surface elements, light points, texture,

colour and ect. Extruding and swept surfaces are examples of modelling

tools

Page 18: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 18

Illumination models

Approaches to create a coloured view of a 3D scene 2 approaches

assign a fix colour to every surface simulate the interaction of light sources with coloured surfaces

Point light sources: radiates light energy equally in all direction

Directional light source: assumes to be located so far away that all of the incident light rays are parallel

Spot light source: a directed beam of light with its associated spot angle

Ambient light: illumination schema that allow the existence of some level of background light level

Shadows: still regarded as a luxury Transparency: to simulate such as the effects of glass and

other transparent media

Page 19: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 19

How to increase realism?

Multiple light source Intensity fall-off with distance negative light X-ray sources

Page 20: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 20

Reflection models

Describe the reflective behaviour of imaginary light Diffuse reflection such as carpets, textiles… can also

give rise to surface gloss effects Specular reflection: smooth or polished surfaces The complete reflection expression: ambient, diffuse

and specular

Page 21: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 21

Shading algorithms

Involves: The frame store: store the image for display

purposes Mapping to the display device Gouraud shading: flat and smooth Phong shading: to compute specular refelctions

Page 22: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 22

Radiosity

A global illumination model that attempas to simulate the multiple diffuse reflections that occur between surfaces

Page 23: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 23

Hidden-surface removal

Problem in distinguishing two surfaces separated by a distance. Approaches taken: The painter’s algorithm: sorts surfaces within the

VO’s field of view in depth sequence Scan-line algorithm: renders images on a line-by-line

basis The z-buffer algorithm: introducing a depth buffer

that always maintains the z-depth for the nearest surface rendered into pixel.

Page 24: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 24

Realism

Realism can be increased by texture mapping of the real world. Some issue has to be considered aliasingcan cause visual artefacts anti-aliasing to overcome the visual artefacts

problems bump mapping: modulating surface normal during

lighting calculation environment mapping: consideration for reflection of

objects to their surroundings

Page 25: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 25

Stereographic images

Red and green glasses red for right eye and green for the left eye to view streographic images: an image for each eye

overlaid with a suitable horizontal overlap

Page 26: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 26

Tranformation

System must be prepared to indicate an object is able to move given the right condition

Modelling transformations translate scale reflection rotation

Page 27: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 27

Translate

The translate transformation enables an object to be positioned anywhere within the VE simply by specifying three offset values that are associated with every 3D vertex of the object

Page 28: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 28

Scale

The scaling transformation alters the size of an object by scaling all of its coordinates

Page 29: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 29

Reflection

Imagine seeing an object in the mirror the same concept for reflection modelling

an object can be computed by reversing the sign of either the x-, y- or z-coordinates

Page 30: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 30

Rotation

Using direction cosines compund rotations: by subjecting an object to a

sequence of matrix operations XYZ fixed angles XYZ Euler angles rotation about an arbitary axis general rotation matrix: can be used to genarate all

of the above rotation matrices

Page 31: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 31

Scaling the VE

VE can be scaled up or down making the VE larger, makes the VO becomes

smaller, can explore the world from the standpoint of a child, or a scene in the dinasour world…

making the VE smaller until a point so small, we can lost all the view of the VE

Page 32: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 32

Animating Position

Some simple linear animation of objects linear tranlation non-linear translation linear angular rotation non-linear angular rotation

shape and object inbetweening process of deriving an object or characterfrom two key

images free-form deformation

works by surrounding an object with a 3D lattice of control points that can be used to deform the object

particle systems a powerful technique for modelling natural phenomena

such as water, rain, fire, grass...

Page 33: Nazlita@fsktm.um.edu.my1 3 D Computer Graphics. nazlita@fsktm.um.edu.my2 The Virtual World Space In order to render coloured images of a virtual world,

[email protected] 33

Others to be considered

Collision detection Instances picking an object pyhsical simulation

object falling, rotating wheels, clocks,projectiles, pendulum, springs, flight dynamics