96
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 1

Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Embed Size (px)

Citation preview

Page 1: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Jinxiang Chai

CSCE 441 Computer Graphics3-D Viewing

1

Page 2: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Outline

3D Viewing

Required readings: HB 10-1 to 10-10

Compile and run the codes in page 388

- opengl three-dimensional viewing program example

2

Page 3: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Taking Pictures Using A Real Camera

Steps:

- Identify interesting objects

- Rotate and translate the camera to a desired camera viewpoint

- Adjust camera settings such as focal length

- Choose desired resolution and aspect ratio, etc.

- Take a snapshot

Page 4: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Taking Pictures Using A Real Camera

Steps:

- Identify interesting objects

- Rotate and translate the camera to a desired camera viewpoint

- Adjust camera settings such as focal length

- Choose desired resolution and aspect ratio, etc.

- Take a snapshot

Graphics does the same thing for rendering an image for 3D geometric objects

Page 5: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space

3D Geometry Pipeline

5

Normalized

projection space

View spaceWorld spaceObject space

Aspect ratio &

resolution

Focal length

Rotate and translate the

camera

11

z

y

x

MCPVd

v

u

Page 6: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

6

Model space

(Object space)

Page 7: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

7

World space

(Object space)

Page 8: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

8

Eye space

(View space)

Page 9: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

9

Normalized projection

space

Page 10: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...

10

Image space, window space, raster

space, screen space, device space

Page 11: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

11

Normalized project

space

View spaceWorld spaceObject space

Image space

Page 12: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

World spaceObject space

glTranslate*(tx,ty,tz)

11000

100

010

001

1

z

y

x

t

t

t

z

y

x

x

y

x

Translate, scale &rotate

Page 13: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Object space

11000

000

000

000

1

z

y

x

s

s

s

z

y

x

z

y

x

glScale*(sx,sy,sz)

World space

Translate, scale &rotate

Page 14: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

Object space

glRotate*),,,( zyx vvv

xy

z),( , zyx vvvr

TRRRRRT zyzyz )()()()()(1

Rotate about r by the angle

World space

Translate, scale &rotate

Page 15: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space

3D Geometry Pipeline

15

Screen spaceNormalized project

space

View spaceWorld spaceObject space

Page 16: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Now look at how we would compute the world->eye transformation

3D Geometry Pipeline

View spaceWorld space

Page 17: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Now look at how we would compute the world->eye transformation

3D Geometry Pipeline

View spaceWorld space

Rotate&translate

Page 18: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Camera Coordinate

18

Page 19: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Canonical coordinate system

- usually right handed (looking down –z axis)

- convenient for project and clipping

Camera Coordinate

Page 20: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Mapping from world to eye coordinates

- eye position maps to origin

- right vector maps to x axis

- up vector maps to y axis

- back vector maps to z axis

Camera Coordinate

Page 21: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

We have the camera in world coordinates We want to transformation T which takes object from world

to camera

Viewing Transformation

wcw

c pTp ,

Page 22: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

We have the camera in world coordinates We want to transformation T which takes object from world

to camera

Trick: find T-1 taking object from camera to world

Viewing Transformation

wcw

c pTp ,

ccw

w pTp 1, )(

Page 23: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

We have the camera in world coordinates We want to transformation T which takes object from world

to camera

Trick: find T-1 taking object from camera to world

Viewing Transformation

wcw

c pTp ,

ccw

w pTp 1, )(

plhd

okgc

njfb

miea

TT wccw ,1

,

?

Page 24: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Review: 3D Coordinate Trans.

Transform object description from to

pj

i

i

j

o

o

'kji ijk

1

'

'

'

1000

'

'

'

10

0

0

z

y

x

zkkjkik

ykjjjij

xkijiii

z

y

x

TTT

TTT

TTT

),,( 000 zyx

k

'k

poooop

25

Page 25: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Review: 3D Coordinate Trans.

Transform object description from to

pj

i

0

0

1

i

0

1

0

j

o

o

'kji ijk

1

'

'

'

1000

'''

'''

'''

10

0

0

z

y

x

zkji

ykji

xkji

z

y

x

zzz

yyy

xxx),,( 000 zyx

1

0

0

k

'k

poooop

26

Page 26: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Review: 3D Coordinate Trans.

Transform object description from camera to world

27

),,( zyx uuu),,( zyx nnn),,( zyx vvv

10000

0

0

,1

, znvu

ynvu

xnvu

TTzzz

yyy

xxx

wccw

Page 27: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Trick: find T-1 taking object from camera to world

- eye position maps to origin

- back vector maps to z axis

- up vector maps to y axis

- right vector maps to x axis

Viewing Transformation

10000

0

0

,1

, znvu

ynvu

xnvu

TTzzz

yyy

xxx

wccw

Page 28: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Trick: find T-1 taking object from camera to world

Viewing Transformation

1

0

1

0

0

0

, 1000

1000

pnvu

znvu

ynvu

xnvu

Tzzz

yyy

xxx

cw

100

0

0

, pn

pv

pu

n

v

u

TT

T

T

cw

H&B equation (10-4)

Page 29: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Viewing Trans: gluLookAt

30

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

Page 30: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

),,( zyx upupupV

How to determine ?

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

nvu

,,

Page 31: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

),,( zyx upupupV

How to determine ?

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

nvu

,,

Page 32: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

refppN

0

),,( zyx upupupV

N

Nn

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

Page 33: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

refppN

0

),,( zyx upupupV

N

Nn

V

nVu

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

Page 34: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Mapping from world to eye coordinates

Viewing Trans: gluLookAt

),,( zyxref atatatp

),,(0 zyx eyeeyeeyep

refppN

0

),,( zyx upupupV

N

Nn

V

nVu

unv

H&B equation (10-1)

gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

Page 35: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Viewing Trans: gluLookAt

Test: gluLookAt( 4.0, 2.0, 1.0, 2.0, 4.0, -3.0, 0, 1.0, 0 )

- What’s the transformation matrix from the world space to the camera reference system?

Page 36: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

3D Geometry Pipeline

View spaceWorld space

3D-3D viewing

transformation

Page 37: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Projection

General definition

transform points in n-space to m-space (m<n)

In computer graphics

map 3D coordinates to 2D screen coordinates

Page 38: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Projection

General definition

transform points in n-space to m-space (m<n)

In computer graphics

map 3D coordinates to 2D screen coordinates

How can we project 3d objects to 2d screen space?

Page 39: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

How Do We See the World?

Let’s design a camera:

idea 1: put a piece of film in front of camera

Do we get a reasonable picture?

Page 40: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Pin-hole Camera

Add a barrier to block off most of the raysThis reduces blurringThe opening known as the apertureHow does this transform the image?

Page 41: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Camera Obscura

The first camera Known to Aristotle Depth of the room is the focal length Pencil of rays – all rays through a point

Page 42: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective Projection

Maps points onto “view plane” along projectors emanating from “center of projection” (COP)

43

Page 43: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective Projection

Maps points onto “view plane” along projectors emanating from “center of projection” (COP)

44

What’s relationship between 3D points and

projected 2D points?

Page 44: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Consider the projection of a 3D point on the camera plane

3D->2D

45

Page 45: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Consider the projection of a 3D point on the camera plane

3D->2D

46

Page 46: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Consider the projection of a 3D point on the camera plane

3D->2D

47

By similar triangles, we can compute how much the x and y coordinates are scaled

Page 47: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Consider the projection of a 3D point on the camera plane

3D->2D

48

By similar triangles, we can compute how much the x and y coordinates are scaled

z

dxx

d

x

z

x

'

z

dyy

d

y

z

y

'

'

Page 48: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Homogeneous Coordinates

Is this a linear transformation?

Page 49: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Homogeneous Coordinates

Is this a linear transformation?– no—division by z is nonlinear

Page 50: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Homogeneous Coordinates

Is this a linear transformation?

Trick: add one more coordinate:

homogeneous image

coordinates

homogeneous scene

coordinates

– no—division by z is nonlinear

Page 51: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Remember how we said 2D/3D geometric transformations work with the last coordinate always set to one

What happens if the coordinate is not one We divide all coordinates by w:

Homogeneous Point Revisited

52

If w=1, nothing happens

Sometimes, we call this division step the “perspective divide”

Page 52: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Now we can rewrite the perspective projection equation as matrix-vector multiplications

The Perspective Matrix

53

z

dxx

d

x

z

x

'

z

dyy

d

y

z

y

'

'

Page 53: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Now we can rewrite the perspective projection equation as matrix-vector multiplications

The Perspective Matrix

54

z

dxx

d

x

z

x

'

z

dyy

d

y

z

y

'

'

10100

0010

0001

'

'

'

z

y

x

dw

y

x

This becomes a linear transformation!

Page 54: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Now we can rewrite the perspective projection equation as matrix-vector multiplications

The Perspective Matrix

55

After the division by w, we have

z

dxx

d

x

z

x

'

z

dyy

d

y

z

y

'

'

10100

0010

0001

'

'

'

z

y

x

dw

y

x

11

'

'

zdy

zdx

y

x

Page 55: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective Effects

Distant object becomes small

The distortion of items when viewed at an angle (spatial foreshortening)

Page 56: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective Effects

Distant object becomes small

The distortion of items when viewed at an angle (spatial foreshortening)

Page 57: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective Effects

Distant object becomes small

The distortion of items when viewed at an angle (spatial foreshortening)

Page 58: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective projection is an example of projective transformation

- lines maps to lines

- parallel lines do not necessary remain parallel

- ratios are not preserved

Properties of Perspective Proj.

Page 59: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective projection is an example of projective transformation

- lines maps to lines

- parallel lines do not necessary remain parallel

- ratios are not preserved One of advantages of perspective projection is that

size varies inversely proportional to the distance-looks realistic

Properties of Perspective Proj.

Page 60: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

Vanishing Points

61

Page 61: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

The equation of the line:

Vanishing Points

62

01z

y

x

z

y

x

v

v

v

tp

p

p

vtpl

p v

Page 62: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

The equation of the line:

After perspective transformation, we have

Vanishing Points

63

01z

y

x

z

y

x

v

v

v

tp

p

p

vtpl

11

'

'

zdy

zdx

y

x

d

tvp

tvp

dtvp

tvp

y

x

zz

yy

zz

xx

11

'

'

p v

Page 63: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Letting t go to infinity:

Vanishing Points (cont.)

64

d

tvp

tvp

dtvp

tvp

y

x

zz

yy

zz

xx

11

'

'

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

Page 64: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

The equation of the line:

Vanishing Points

65

01z

y

x

z

y

x

v

v

v

tp

p

p

vtpl

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

Page 65: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

The equation of the line:

How about the line

Vanishing Points

66

01z

y

x

z

y

x

v

v

v

tp

p

p

vtpl

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

01z

y

x

z

y

x

v

v

v

tq

q

q

vtql

Page 66: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

The equation of the line:

How about the line

Vanishing Points

67

01z

y

x

z

y

x

v

v

v

tp

p

p

vtpl

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

01z

y

x

z

y

x

v

v

v

tq

q

q

vtql

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

Page 67: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

The equation of the line:

How about the line

Vanishing Points

68

01z

y

x

z

y

x

v

v

v

tp

p

p

vtpl

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

01z

y

x

z

y

x

v

v

v

tq

q

q

vtql

d

v

v

dv

v

y

x

z

y

z

x

11

'

'

Same vanishing point!

Page 68: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

Each set of parallel lines intersect at a vanishing point on the PP

Vanishing Points

Page 69: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

What happens to parallel lines they are not parallel to the projection plane?

Each set of parallel lines intersect at a vanishing point on the PP

Vanishing Points

Page 70: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Parallel Projection

Center of projection is at infinity

Direction of projection (DOP) same for all points

Page 71: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Orthographic Projection

Direction of projection (DOP) perpendicular to view plane

Page 72: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Orthographic Projection

Direction of projection (DOP) perpendicular to view plane

1000

0000

0010

0001

Page 73: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Properties of Parallel Projection

Not realistic looking Good for exact measurement Are actually affine transformation

- parallel lines remain parallel

- ratios are preserved

- angles are often not preserved Most often used in CAD, architectural drawings,

etc. where taking exact measurement is important

Page 74: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective projection from 3D to 2D

3D->2D

75

10100

0010

0001

'

'

'

z

y

x

dw

y

x

Page 75: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Perspective projection from 3D to 2D

3D->2D

76

10100

0010

0001

'

'

'

z

y

x

dw

y

x

But so far, we have not considered the size of film

plane!

We have also not considered visibility problem

Page 76: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space

3D Geometry Pipeline

77

Screen spaceNormalized project

space

View spaceWorld spaceObject space

z = -1z = 1

Page 77: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

The center of projection and the portion of projection plane that map to the final image form an infinite pyramid. The sides of pyramid called clipping planes

Additional clipping planes are inserted to restrict the range of depths

Perspective Projection Volume

Page 78: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

OpenGL Perspective-Projection

79

Normalized project

space

View space

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

gluPerspective(fovy,aspect,dnear, dfar)

z = -1z = 1

Page 79: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

View space

(xwmin,ywmin,Znear)(xwmax,ywmax,znear)

General Perspective-Projection

zfar

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

Six parameters define six clipping planes!

nearnear zd

Page 80: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

General Perspective-Projection

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

Left-vertical clipping plane

Page 81: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

General Perspective-Projection

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

right-vertical clipping plane

Page 82: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

General Perspective-Projection

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

bottom-horizontal clipping plane

Page 83: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

General Perspective-Projection

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

top-horizontal clipping plane

Page 84: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

General Perspective-Projection

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

near clipping plane

nearnear zd

Page 85: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

General Perspective-Projection

glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar)

far clipping plane

farfar zd

Page 86: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Normalized project space (left-

handed)

View space (right-

handed)

B’=(1,1,1)

A’=(-1,-1,-1)

General Perspective-Projection

A maps to A’, B maps to B’Keep the directions of x and y axes!

A

B

Page 87: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

B’=(1,1,1)

A’=(-1,-1,-1)

General Perspective-Projection

0100

200

02

0

002

minmax

minmax

minmax

minmax

minmax

minmax

farnear

farnear

farnear

farnear

near

near

zz

zz

zz

zzywyw

ywyw

ywyw

zxwxw

xwxw

xwxw

z

T

H&B equation (10-40)

A

B

Page 88: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

OpenGL Symmetric Perspective-Projection Function gluPerspective(fovy,aspect,dnear, dfar)

89

Assume z-axis is the centerline of 3D view frustum!

Page 89: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space

3D Geometry Pipeline

90

Normalized project

space

View spaceWorld spaceObject space

Page 90: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space-.>Image space

Viewport Transformation

91

glViewport(xmin, ymin, width, height)

(xmin,ymin)

Display window

viewport

Page 91: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space-.>Image space

Viewport Transformation

92

glViewport(xmin, ymin, width, height)

(xmin,ymin)

- Besides x and y, each pixel has a depth value z, which is stored in depth buffer.

-Depth values will be used for visibility testing

-The color of the pixel is stored in color buffer

Page 92: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

93

Image space

Normalized project

space

B’=(1,1,1)

A’=(-1,-1,-1)

Normalized project space

A’’=(xvmin,yvmin,0)

B’’=(xvmax,yvmax,1)

Viewport Transformation

-1<=z<=1

0<=z<=1

Page 93: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Viewport Transformation

94

Image space

Normalized project

space

B’=(1,1,1)

A’=(-1,-1,-1)

Normalized project space

A’’=(xvmin,yvmin,0)

B’’=(xvmax,yvmax,1)

10002

1

2

100

20

20

200

2minmaxminmax

minmaxminmax

yvyvyvyv

xvxvxvxv

T

H&B equation (10-42)

-1<=z<=1

0<=z<=1

Page 94: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Image space

Summary: 3D Geometry Pipeline

95

Normalized project

space

View spaceWorld spaceObject space

Page 95: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Taking Steps Together

96

11

z

y

x

MCPVd

v

u

Image spaceNormalized project

space

View spaceWorld spaceObject space

Page 96: Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

OpenGL Codes

97