Biến đổi mô hình hoá - Modeling transformations
– build complex models by positioning simple
components
zBiến đổi tạo góc nhìn - Viewing transformations
– placing virtual camera in the world
– transformation from world coordinates to camera
coordinates
zBiến Phép chiếu – Projection Transform
16 trang |
Chia sẻ: Mr Hưng | Lượt xem: 998 | Lượt tải: 0
Nội dung tài liệu Đồ họa thiết kế - Bài 4 Các phép biến đổi Đồ hoạ Transformations, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
ùng nhìn thấy của
Camera
60
Viewing Coordinates
z Có thể sử dụng mô hình hệ
thống tọa độ quan sát trên các
thông số gồm:
– Điểm nhìn (VRP View Reference
Point ): điểm gốc quan sát. Vị trí của
Camera)
– Vector mặt phẳng quan sát (VPN
View Plane Normal vector ): viewing
direction)
– Vector hướng quan sát (VUP View
UP vector ): establishes orientation of
“camera”
),,( 321 nnn== N
Nn
),,( 321 uuu=×
×=
NV
NVu
),,( 321 vvv=×= unv
Three mutually orthogonal
basis vectors:
Khoa CNTT - DDHBK Hà nội
hunglt@it-hut.edu.vn
8682595
11
61 61
Ví dụ: Viewing Transformation
(i) simple cases ( always view along negative z-axis )
(0, 0, z)
Điểm nhìn trên trục Z
zW -axis
zW
xW
yW
n
MWC,VC = T (0, 0, z,)
(a, b, c)
Nhìn ở vị trí (a, b, c) theo trục Z và
ngược hướng zW-axis
MWC,VC = T (-a, -b, -c )
zW
xW
yW
62 62
.and , ,
3
2
1
3
2
1
3
2
1
⎟⎟
⎟⎟
⎠
⎞
⎜⎜
⎜⎜
⎝
⎛
=
⎟⎟
⎟⎟
⎠
⎞
⎜⎜
⎜⎜
⎝
⎛
=
⎟⎟
⎟⎟
⎠
⎞
⎜⎜
⎜⎜
⎝
⎛
=
n
n
n
v
v
v
u
u
u
nvu
Ma trận biến đổi tọa độ thế giới sang tọa độ quan sát :
MWC,VC = R T
(xw, yw, zw) and (u, v, n) 2 hệ tọa độ với cùng 1 gốc.
Vector đơn vị (u, v, n) được định nghĩa theo WCS
63
3D Viewing Transformation
z Với điểm quan sát VRPoint (x0, y0, z0) the Viewing
Transformation can be defined by composition of the
following two transformations:
⎟⎟
⎟⎟
⎟
⎠
⎞
⎜⎜
⎜⎜
⎜
⎝
⎛
−
−
−
=
1000
100
010
001
0
0
0
z
y
x
T
⎟⎟
⎟⎟
⎟
⎠
⎞
⎜⎜
⎜⎜
⎜
⎝
⎛
=
1000
0
0
0
321
321
321
nnn
vvv
uuu
R
TRM •=VCWC ,
This is used to determine the location of each vertex in the
camera co-ordinate system
xx vcwc
rr
,M=′
64
Viewing Transformation
z We might also achieve this in terms of the 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
(x0, y0, z0)
⎟⎟
⎟⎟
⎟
⎠
⎞
⎜⎜
⎜⎜
⎜
⎝
⎛
−
−
−
1000
100
010
001
0
0
0
z
y
x
65 65
where ,
1000
0
0
0
321
321
321
⎟⎟
⎟⎟
⎟⎟
⎠
⎞
⎜⎜
⎜⎜
⎜⎜
⎝
⎛
=
nnn
vvv
uuu
R
Verification: etc , ? =
⎥⎥
⎥⎥
⎦
⎤
⎢⎢
⎢⎢
⎣
⎡
=
1
3
2
1
u
u
u
R uR
pV = MWC,VC pW
xW
zW
yW
pM
pW
pV
yV
xV -zV
66
• Recall we’ve re-expressed our world geometry in eye’s frame
reference.
• To do projection, we use a synthetic camera by introducing a
viewing frustum after the viewing transformation.
66
xW
zW
yW
yM
xMzM
pM
yV
xV
-zV pV
pW
xW
zW
yW
pM
pW
Khoa CNTT - DDHBK Hà nội
hunglt@it-hut.edu.vn
8682595
12
67
Camera trong OpenGL
z Các hàm cơ bản
– glOrtho() and gluLookAt()
– these created parallel projections
z We now want to modify a scene to give us
perspective projections.
– lines converge as they get further away
68 68
Demo : Viewing
from Nate Robins
(Utah)
69
The Camera
z Khởi tạo Camera với phép
chiếu phối cảnh
– Thay cho glOrtho() bằng:
– gluPerspective()
z gluPerspective
– viewAngle
– aspectRatio (W/H)
– near plane
– far plane
70
The Camera
z The Perspective Camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(viewAngle, aspectRatio, N, F);
71
The Camera
z Positioning the Camera
– The camera is positioned using a combination
of translations and rotations.
– Think if the camera being in the same location
as the viewers eye.
72
The Camera
eye(x,y,z)
lookat(x,y,z)
up(x,y,z)
Khoa CNTT - DDHBK Hà nội
hunglt@it-hut.edu.vn
8682595
13
73
The Camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eye.x, eye.y, eye.z,
look.x, look.y, look.z,
up.x, up.y, up.z);
74
The Camera
z The camera can have an arbitrary orientation and
position.
z Therefore we can think of the camera having its own
axes.
75
Camera Movement
z A camera has six degrees of freedom:
1. slid in 3 directions; and
2. rotated in 3 directions
z Camera Movement
– The camera can move along its axes.
– This is called sliding the camera.
76
The Camera
z Camera Movement
– To move the camera along the u axis you would simply perform
z eye = eye + Du
– To move slide the camera in any direction:
eye.x = dU*u.x + dV*v.x + dN*n.x
eye.y = dU*u.y + dV*v.y + dN*n.y
eye.z = dU*u.z + dV*v.z + dN*n.z
z Camera Movement
– Besides physically moving the camera to another location
– the camera can be tilted in different directions to look at
different parts of the scene.
u
v
n
77
The Camera
z Camera Movement
– Besides physically moving the camera to another
location
– the camera can be tilted in different directions to look
at different parts of the scene.
78
The Camera - Camera Movement
We use a plane analogy to describe the cameras
movement.
z a rotation from the horizontal along the length is called PITCH
z a rotation from the horizontal along the width is called ROLL
z a rotation around the vertical is called YAW
Khoa CNTT - DDHBK Hà nội
hunglt@it-hut.edu.vn
8682595
14
79
The Camera
z Pitch
v’ = cos(θ)v – sin(θ)n
n’ = sin(θ)n + cos(θ)v
n
v
80
The Camera
z Roll
u’ = cos(θ)u + sin(θ)v
v’ = cos(θ)v - sin(θ)u
u
v
81
The Camera
z Yaw
n’ = cos(θ)n - sin(θ)u
u’ = sin(θ)n + cos(θ)u
u
n
82
A 3D Scene
z Notice the presence of
the camera, the
projection plane, and
the world
coordinate axes
z Viewing transformations define how to acquire the image
on the projection plane
83
Viewing Transformations
z Create a camera-centered view
z Camera is at origin
z Camera is looking along negative z-axis
z Camera’s ‘up’ is aligned with y-axis
84
2 Basic Steps
z Align the two coordinate frames by rotation
Khoa CNTT - DDHBK Hà nội
hunglt@it-hut.edu.vn
8682595
15
85
2 Basic Steps
z Translate to align origins
86
Creating Camera Coordinate
Space
z Specify a point where the camera is located in world
space, the eye point
z Specify a point in world space that we wish to become
the center of view, the lookat point
z Specify a vector in world
space that we wish to
point up in camera
image, the up vector
z Intuitive camera
movement
87
Constructing Viewing
Transformation, V
z Create a vector from eye-point to lookat-point
z Normalize the vector
z Desired rotation matrix should map this
vector to [0, 0, -1]T Why?
88
Constructing Viewing
Transformation, V
z Construct another important vector from the
cross product of the lookat-vector and the vup-
vector
z This vector, when normalized, should align with
[1, 0, 0]T Why?
89
Constructing Viewing
Transformation, V
z One more vector to define
z This vector, when normalized, should align with [0, 1, 0]T
z Now let’s compose the results
90
Compositing Vectors to Form V
z We know the three world axis vectors (x, y, z)
z We know the three camera axis vectors (r, u, l)
z Viewing transformation, V, must convert from world to
camera coordinate systems
Khoa CNTT - DDHBK Hà nội
hunglt@it-hut.edu.vn
8682595
16
91
Compositing Vectors to Form V
z Remember
– Each camera axis vector is unit length.
– Each camera axis vector is perpendicular to others
z Camera matrix is orthogonal and normalized
– Orthonormal
z Therefore, M-1 = MT
92
Compositing Vectors to Form V
z Therefore, rotation component of viewing
transformation is just transpose of computed
vectors
93
Compositing Vectors to Form V
z Translation component too
z Multiply it through
94
Final Viewing Transformation, V
z To transform vertices, use this matrix:
z And you get this:
Các file đính kèm theo tài liệu này:
- l5_modelingtrans_9042.pdf