1 of 52

3D Viewing Transformation

Tong-Yee Lee

1

2 of 52

2

Setup Camera parameters to view 3D scenes

3 of 52

3

Viewing and viewport Transformation

viewport transformation:

open a window on the monitor screen to

display an image display

4 of 52

4

Case A): rotating objects, the camera does not move

Case B): rotating camera, the object does not move

5 of 52

5

World space and

eye space coordinate

: visible objects are on

negative Z direction

6 of 52

6

World

Coordinate

Local Coordinate

View coordinate

Project plane

7 of 52

OpenGL Graphics

Pipeline

8 of 52

8

使用glViewport

指定 Viewport 變換

使用GL_PROJECTION 指定投影變換,OpenGL 支持透視投影和正側投影(一般用於工程製圖)-1<=x,y,z<=1

  • 使用GL_MODELVIEW 來同時指定viewing matrix 和modeling matrix.
  • OpenGL matrix transform

9 of 52

Front and Back Clipping Planes

  • Frustum
    • Volume of space between front and back clipping planes
    • What camera can see – what drawn on screen

  • Near and far clipping planes defined by distance along Look Vector

  • Objects appearing outside of view volume don't get drawn

  • Objects intersecting view volume get clipped

10 of 52

OpenGL: Field of View, gluPerspective�Yet another way to set viewing

  • Can always use:

glFrustum(left, right, bottom, top, near, far)

    • This is certainly sufficient
    • But may be inconvenient in some applications
    • Can be difficult to get desired view

  • May want to use:

gluPerspective(fovy, aspect, near, far)

    • specifies field of view along y axis
      • angle θ made by the sides of frustum
    • aspect ratio of viewport
      • just (width / height)

aspect = w/h

front plane

11 of 52

World coordinate v.s. eye corrdinate

11

12 of 52

Eye-coordinate to Clip coordinate

12

13 of 52

13

14 of 52

14

Viewing Specification

15 of 52

15

Back-face culling

16 of 52

16

Back-face culling (trivial rejection)

Viewing direction

17 of 52

Back-face culling (trivial rejection)

One method of implementing back-face culling is by discarding all triangles where the dot productOne method of implementing back-face culling is by discarding all triangles where the dot product of their surface normal and the camera-to-triangle vector is greater than or equal to zero

                     

where P is the view point, V0 is the first vertex of a triangle and N is its normal, defined as a cross product of two vectors representing sides of the triangle adjacent to V0

                                 

V0

V1

V2

P

N

Reject condition

P

N

V0

18 of 52

18

Viewing frustum and backface culling: The mesh is coarsened outside of the viewing frustum. Triangles oriented away from the viewer are coarsened as well. 

View dependent LOD (Level of Details)

19 of 52

19

20 of 52

20

21 of 52

21

22 of 52

22

23 of 52

23

24 of 52

Intuitive Camera Specification

24

25 of 52

25

26 of 52

26

27 of 52

27

28 of 52

28

29 of 52

29

30 of 52

30

31 of 52

31

32 of 52

32

33 of 52

33

X axis vector

Y axis vector

Z axis vector

34 of 52

34

35 of 52

35

36 of 52

Intuitive Camera Specification

36

37 of 52

37

Not easy for user to pick up

exact up vector!!

So, we compute v automatically

from up vector.

38 of 52

38

39 of 52

39

Note that matrix storage order is column major

in OpenGL

40 of 52

40

Treat yourself (viewer) as an airplane heading to –Zc

Note that: as a viewer is moving, the object is moving in

opposite direction on the viewing plane!!

u (i.e., x) axis

n (i.e.,z) axis

v (i.e., y) axis

俯仰

翻滾

偏航

41 of 52

41

Pitch (x), Roll (z) and Yaw (y) rotation

42 of 52

42

This is z-like rotation

43 of 52

How about slide()

  • Sliding a camera means to move it along one of its own axes-that is in the u,v,n direction-without rotating it.
    • Along n means forward or backward
    • Along u is left and right
    • Along v is up and down
  • Assume slide(delU, delV, delN)

43

延camera座標軸 walking

i.e., needs to transfer its change to word coordinate on eye position

And eye u, v, w directions are not changed!

44 of 52

Flythrough �a Scene!!!

‘P’-64

=ctrl+‘P’

Homework

#3 (optional) Add

this camera control!!

45 of 52

45

Camera Frame

Light v.s. Eye coordinate

46 of 52

46

Animate camera along paths

47 of 52

47

http://graphics.csie.ncku.edu.tw/Motion_Overview/

Motion Overview of Human Actions

Same v.s. Different camera paths for different motions

48 of 52

48

Cinemachine Tutorials | How to make Unity the path animation?

Camera editing Using Unity

49 of 52

49

Cinemachine Tutorials | How to make Unity the path animation?

https://www.programmersought.com/article/69213097748/

50 of 52

50

Zoom-in/Zoom-out

Camera moving

51 of 52

51

Sliding a camera to create panorama images

52 of 52

52