Trang 4 Viewing transformation■ More logical to use dimensions which are appropriate to the object.. □metres for buildings, □millimetres for assembly parts, □nanometres or microns for mo
Trang 1Lesson 6
Viewing Transformation
Trinh Thanh Trung School of ICT, HUST
Trang 2Content
Trang 3Overview
Trang 4Viewing transformation
appropriate to the object e.g
□ metres for buildings,
□ millimetres for assembly parts,
□ nanometres or microns for molecules, cells, and
atoms
physical size in the real world,
screen co-ordinates before displaying
Trang 5Viewing transformation
co-ordinates to Screen Coco-ordinates
view
effect without changing the model by scaling
dimensions proportionally
Trang 6screen co-ordinates?
Trang 7Viewing transformation
view volume
Trang 8Homogeneous Coordinates
the same point when all elements are multiplied by the same factor
□ (2,0,1,1) and (4,0,2,2) are the same points
□ To bring back to Cartesian space, need to
divide the other elements by the fourth element w
▫ (x, y, z, w) → (x/w, y/w, z/w, 1)
Trang 92D viewing transformation
Trang 10Window and viewport
■ Window: the portion of the world which will be
displayed
■ Viewport: The screen where the image will be
displayed
(wx min ,wy min)
(wx max ,wy max)
(vx min ,vy min)
(vx max ,vy max)
Trang 11Transformation
Trang 120 0 1
1
Yw Xw
0
0 min max
min max
0
0 0
Xwmin -
Xwmax
Xvmin -
Xvmax
] 1 [
Yw Yw
Yv Yv
0 0 1 ]
2 [
Yy Xv T
Trang 13Combined transformation matrix
min
max min
min Xwmin
Xwmax
-Xvmin -
Xvmax min
min
0 min
max
min
max 0
0 0
Xwmin -
Xwmax
Xvmin -
Xvmax
]
[
] 2 [ ] 1 [ ]
Yv
Yv Yw
Yv Xw
Xv
Yw Yw
Yv
Yv T
T x S x
T
T
Trang 14Example in OpenGL
//set the viewing coordinates
setWindow(xmin, xmax, ymin, ymax);
-void setWindow(GLdouble left, Gldouble right, GLdouble bottom, GLdouble top) {
-void setViewport(GLdouble left, Gldouble right, GLdouble bottom, GLdouble top)
{ glViewport(left, bottom, right – left, top - bottom);
}
Trang 153D viewing transformation
Trang 163D viewing
■ Part of the difficulty lies in trying to display three dimensional objects on a 2D display
lead to different 2D representations at the
projection stage
□ The projected 2D image of a 3D object is viewer
dependent
parameters e.g position, orientation, field of view
Trang 173D viewing
□ a description of the scene geometry
□ a view definition (camera)
plane
in 2D viewing
scene geometry onto a 2D surface for display
Trang 20Camera analogy
components, specified independently:
□ objects (a.k.a geometry)
□ viewer (a.k.a camera)
projection plane (usually in front of the camera).
■ Projectors emanate from the center of
projection (COP) at the center of the lens (or
pinhole)
□ The image of an object point P is at the intersection
of the projector through P and the image plane.
Trang 21Camera analogy
four kinds of parameters:
□ Position: the COP.
□ Orientation: rotations about axes with origin at the COP.
□ Focal length: determines the size of the image on the film plane, or the
field of view.
□ Film plane: its width and height.
Trang 22transformation
Trang 23Camera parameters
■ View Reference Point (VRP): origin of our viewing system (position of the camera)
■ View Plane Normal vector (VPN): viewing direction
■ View UP vector (VUP): establishes orientation of
“camera”
),,(n1 n2 n3
=
=
N
N n
),,(u1 u2 u3
N V u
) , , ( v1 v2 v3
=
= n u v
Trang 24Viewing transformation
■ (xw, yw, zw) and (u, v, n) are 2 coordinate systems with the same centre
M WC,VC = R T
24
,
,
3 2 1
3 2 1
3 2
v v v
u u
u
n v
u
Trang 25100
010
001
0 0 0
z y
0
000
3 2
1
3 2
1
3 2
1
n n
n
v v
v
u u
u
R
T R
Trang 26Viewing transformation
following transformation sequence:
□ Translate the view reference point to the origin of the world co-ordinate system
□ Apply Rotations to align xv, yv and zv, axes, respectively
1 0 0
0 1 0
0 0 1
0 0 0
z y x
Trang 27Viewing transformation
27
1 0 0 0
0 0
0
3 2 1
3 2 1
3 2 1
v v v
u u u
u u
u
R u
Trang 28Camera movement
□ The camera is positioned using a combination of translations and rotations.
□ Think if the camera being in the same location as the viewers eye.
and position
own axes
28
Trang 29Camera in OpenGL
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eye.x, eye.y, eye.z,
look.x, look.y, look.z, up.x, up.y, up.z);
29
Trang 30Camera Movement
1 slid in 3 directions; and
2 rotated in 3 directions
□ The camera can move along its axes.
□ This is called sliding the camera.
30
Trang 31■ Besides physically moving the camera to another location, the camera can be tilted in different directions to look at different parts of the scene.
31
u v
n
Trang 32The Camera - Camera Movement
■ We use a plane analogy to describe the cameras movement.
□ a rotation from the horizontal along the length is called PITCH
□ a rotation from the horizontal along the width is called ROLL
□ a rotation around the vertical is called YAW
32
Trang 33u v
u n
Trang 34Any questions?
Trang 35Lecture notes provided by School of Information and
Communication Technology, Hanoi University of Science and
Technology.
Composed by Huynh Quyet Thang, Le Tan Hung, Trinh Thanh
Trung and others
Edited by Trinh Thanh Trung
Special thanks to all the people who made and released these awesome resources for free:
■ Presentation template by SlidesCarnival
■ Photographs by Death to the Stock Photo ( license )
■ Diverse device hand photos by Facebook Design Resources