Professional Documents
Culture Documents
L06 Viewing Projection - VE
L06 Viewing Projection - VE
HTTPS://WWW.YOUTUBE.COM/WATCH?V=PSOASZ_SS-A
HTTPS://WWW.YOUTUBE.COM/WATCH?V=JC8WAGNRDLM
Exploded/cutaway scenes
Different views of a 3D model 2
GRAPHICS PIPELINE
Transform
Illuminate
Transform
Clip
Project
Rasterize
4
CONVERTING FROM 3-D TO 2-D
Projection is just one part of the Chiếu chỉ là một phần của quá trình
process of converting from 3-D world chuyển đổi từ tọa độ thế giới 3-D
coordinates to a 2-D image thành hình ảnh 2 chiều
5
CONVERTING FROM 3-D TO 2-D
HTTPS://WWW.YOUTUBE.COM/WATCH?V=ACTK6DKYNEU
https://www.youtube.com/watch?v=96JwSK3w
G0E
PARALLEL PROJECTIONS
Parallel Song song, tương đông
The lines of projection are parallel Các đường chiếu song song
Distance between projection plane and
COP is infinite Khoảng cách giữa mặt phẳng chiếu và
COP là vô hạn
Less realistic view
No foreshortening, Chế độ xem ít thực tế hơn
Typically used for architectural and Không foreshortening,
engineering drawings
Exact measurement and parallelism Thường được sử dụng cho các bản vẽ
preserved kiến trúc và kỹ thuật
For parallel projections, we specify a Đo lường chính xác và bảo tồn song song
direction of projection (DOP) instead of a
COP. Đối với các phép chiếu song song, chúng
tôi chỉ định hướng chiếu (DOP) thay vì
COP.
7
8
PARALLEL PROJECTIONS
Two types, defined by
Direction of projection (DOP)
Viewing (projection) plane normal Hai loại, được xác định bởi
(VPN) Hướng chiếu (DOP)
Orthographic Xem mặt phẳng (chiếu) bình thường (VPN)
DOP and VPN the same (or the Orthographic
reverse)
DOP và VPN giống nhau (hoặc ngược lại)
Oblique Xiên
DOP of VPN not the same (nor the
reverse) DOP của VPN không giống nhau (cũng
không đảo ngược)
9
ORTHOGRAPHIC
PARALLEL PROJECTIONS
Projection plane perpendicular to a Mặt phẳng chiếu vuông góc với trục
principle axis chính
Most common types Các loại phổ biến nhất
Front-elevation Chiếu đứng
Top-elevation (plane-elevation) Chếu bằng (mặt phẳng)
Side-elevation
Chiếu cạnh
Used in engineering drawing (such as Được sử dụng trong bản vẽ kỹ thuật
machine parts, architecture) (chẳng hạn như các bộ phận máy,
Hard to deduce 3D nature kiến trúc)
Khó để suy ra bản chất 3D
10
11
ORTHOGRAPHIC PROJECTIONS
We can write orthographic projection onto the z=0
plane with a simple matrix, such that x’=x, y’=y.
1 0 𝑥
0 0 𝑦
𝑥′
𝑦′ = 0 1 0 0 𝑧
1 0 0 0 1 1
𝑥′ 1 0 0 0 𝑥
𝑦′
= 0 1 0 0 𝑦
Normally, we do not drop the z value right away. 𝑍′ 0 0 0 0 𝑧
Why not? 1 0 0 0 1 1
ORTHOGRAPHIC PROJECTION)
▪Phép chiếu trực giao (Orthographic
projection) là phép chiếu song song và tia
chiếu vuông góc với mặt phẳng chiếu thường
dùng mặt phẳng z=0
▪Ứng với mỗi mặt phẳng chiếu ta có 1 ma trận
chiếu tương ứng
1 0 0 0 0 0 0 0 1 0 0 0
0 0 1 0 0
0 0 0 0 1 0 0
[T y ] = [T x ] = [T z ] =
0 0 1 0 0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0 1
13
AXONOMETRIC ORTHOGRAPHIC PROJECTIONS
14
15
PHÉP CHIẾU TRỤC LƯỢNG (AXONOMETRIC)
Phép chiếu trục lượng là phép chiếu mà hình chiếu thu được
Phép chiếu Trimetric
Là phép chiếu hình thành từ việc quay tự do đối tượng trên một trục hay tất cả các trục của hệ
tọa độ và chiếu đối tượng đó bằng phép chiếu song song lên mặt phẳng chiếu (thường là mặt
phẳng z = 0) vuông góc với tia chiếu
trên cơ sở tỉ lệ co - SF của ảnh đối tượng trên mỗi trục là khác nhau.
x x' y x' 0 1
1 0 0 1 '
xy y 'y 0 1
[U ] = 0 1 0 1
[T ] = '
xz y z' 0 1
0 0 1 1
0 0 0 1
16
TRIMETRIC
[ U ] :là ma trận vector đơn vị
của các trục x, y, z bất biến
[ T ] : là ma trận chiếu tổng hợp
tương ứng
SF- tỉ lệ co theo các trục là:
f x = x' 2x +y' 2x
f y = x' + y'
2
y
2
y
f z = x' +y'
2
z
2
z
17
PHÉP CHIẾU DIMETRIC
Là phép chiếu Trimetric với 2 hệ số
tỉ lệ co bằng nhau, giá trị thứ 3 còn
[T ] = [ Ry ][ Rx ][ Pz] lại là tuỳ ý.
cos 0 − sin 0 1 0 0 0 1 0 0 0
0 1 0 0 0 cos sin 0 0 1 0 0
= . .
sin 0 cos 0 0 − sin cos 0 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0 1
f = ( x + y ) = cos
2
y
'2
y
'2
y
2
fz
= sin (
−1
)
2 − f z2
fz
= sin (
−1
)
2
19
PHÉP CHIẾU ISOMETRIC
1 − 2 sin 2
Là phép chiếu trục lượng mà ở đó hệ sin =
2
1 − sin 2
số co cạnh trên 3 trục là bằng nhau
Góc quay tương ứng là 35.26 và 45 sin 2
sin 2 =
1 − sin 2
Ðược ứng dụng nhiều trong việc xây
dựng các góc quan sát chuẩn cho đối sin 2 1 /3
sin =
2
= = 1 /2
tượng trong các hệ soạn thảo đồ họa 1 − sin 1 − 1 / 3
2
1
sin =
3
= 35.260
= 450
f = cos2 = 2 / 3 = 0.8165
20
ISOMETRICS 𝑓= cos2 𝜙 = 2/3 = 0.8165
𝜙 = ±35.260
𝜑 = ±450
Isometric projection is a method for visually
representing three-dimensional objects in two
dimensions in technical and engineering drawings
.
21
ISOMETRIC PROJECTIONS
Isometric projections have been used in computer games from the very early days of the
industry up to today
Matrix of shearing ▪ Kết hợp các thuộc tính của Orthographic và Axonometric
▪ Cung cấp một cảm giác tốt hơn về bản chất 3D.
Cavalier
DOP makes 45 degree with projection plane
Cabinet 𝐕𝑝 𝑥, 𝑦, 𝑧𝑣𝑝
DOP makes angle of arctang(2) with projection plane
𝑥, 𝑦, 𝑧
25
PHÉP CHIẾU CAVALIER 𝑥𝑝 , 𝑦𝑝 , 𝑧𝑣𝑝
1 0 0 0
0 1 0 0 𝑥, 𝑦, 𝑧
[T ' ' ] =
− a − b 0 0
1 0 0 0
0 0 0 1
0 1 0 0
[𝑇] =
a = L cos𝛼 −𝐿 cos 𝛼 −𝐿 sin 𝛼 0 0
𝑏 = 𝐿 sin 𝛼 0 0 0 1
26
27
WHY PERSPECTIVE
PROJECTIONS
Perspective projections are much more realistic than
parallel projections
https://www.youtube.com/watch?v=DcdIWwXapVI
PERSPECTIVE PROJECTION
Projection lines converge in a point behind viewing plane.
Doesn’t preserve relative size but looks more realisticand
used in computer graphics.
View Plane
Projection
Closer objects look larger Reference
Point
29
VANISHING POINT
What happens to two parallel lines that are not
parallel to the projection plane?
Think of train tracks receding into the horizon...
Vanishing Point
Point that set of parallel lines not parallel to the
projection plane converge to
Điều gì xảy ra với hai đường song song
không song song với mặt phẳng chiếu?
Hãy nghĩ đến các đường ray xe lửa đang đi
vào đường chân trời ... Vanishing Point
• Điểm mà tập hợp các đường song song
không song song với mặt phẳng chiếu hội
tụ
30
VANISHING POINTS ?
Example:
If projection plane cuts only z-axis Thí dụ:
Only z-axis vanishing point Nếu mặt phẳng chiếu chỉ cắt z trục
As lines parallel to x or y axis also • Chỉ điểm biến mất trục z
parallel to projection plane • Khi các đường song song với trục x hoặc y
cũng song song với mặt phẳng chiếu
Number of Axis Vanishing Points ?
Số trục biến mất điểm?
Can be used to categorize
• Có thể được sử dụng để phân loại các
perspective projections phép chiếu phối cảnh
Equal to number of axes cut by • Bằng số trục được cắt bằng mặt phẳng
projection plane chiếu
31
NUMBER OF AXIS VANISHING POINTS
Two-point
Commonly used in architecture, engineering,
industrial design, and advertising drawings
32
The perspective projection is
GENERAL PROJECTIVE TRANSFORMATION an example of a projective
transformation.
affine transform projective transform
𝑎 𝑏 𝑐 𝑑 𝑎 𝑏 𝑐 𝑑 1 0 0 0 𝑥
0 1 0 0 𝑦
𝑒 𝑓 𝑔 ℎ 𝑒 𝑓 𝑔 ℎ
= = 0 0 1 0 𝑧
𝑖 𝑔 𝑘 𝑙 𝑖 𝑔 𝑘 𝑙 0 0 −1/𝑍𝑐 0 1
0 0 0 1 𝑚 𝑛 𝑜 𝑝
𝑥𝑃 1 0 0 0 𝑥 1 0 0 0 𝑥
𝑦𝑃 0 1 0 0 𝑦 0 1 0 0 𝑦
=
𝑧𝑃 0 0 1 0 𝑧 0 0 1 0 𝑧
1 0 0 −1Τ𝑍𝑐 0 1 0 0 𝑟 1 1
PHÉP BIẾN ĐỔI PHỐI CẢNH
1 0 0 0
0 1 0 0
[Tr ] =
0 0 1 r
0 0 0 1
𝑥 𝑦 𝑧
[𝑥′ 𝑦′ 𝑧′ 1] = 1
𝑟𝑧 + 1 𝑟𝑧 + 1 𝑟𝑧 + 1
Giả sử khi mặt phẳng được đặt tại z = 0 và tâm phép
Phép chiếu phối ca?nh của các điểm trên đối tượng chiếu nằm trên trục z , cách trục z một khoảng zc = -
lên trên mặt phẳng 2D thu được từ phép chiếu trực 1/r.
giao và phép biến đổi phối cảnh Nếu đối tượng cũng nằm trên mặt phẳng z = 0 thì đối
tượng sẽ cho hình ảnh thật.
Phương trình biến đổi:
[ x y z 1 ][ Tr ] = [ x y z rz+1 ]
ma trận biến đổi một điểm phối cảnh [ Tr ] có dạng:
34
1 0 0 0
PHÉP CHIẾU PHỐI CẢNH 1 TÂM 0 1 0 0
[Tr ] =
0 0 1 r
0 0 0 1
1 0 0 0 1 0 0 0 1 0 0 0
0 1 0 0 0 1 0 0 0 1 0 0
= =
0 0 1 r 0 0 0 0 0 0 0 r
0 0 0 1 0 0 0 1 0 0 0 1
1 0 0 0 x y
0 x' y' z' 1 = 0 1
1 0 0 rz + 1 rz + 1
x y z 1 = x y 0 rz + 1
0 0 0 r
0 0 0 1
35
PHÉP CHIẾU PHỐI CẢNH 2 TÂM
1 0 0 p
0 0 q
1 0 0 p x y z 1
1
= x y z ( px + qy + 1)
0 1 0 q
0 0 1 0
[Tpq ] = 0 0 0 1
0 0 1 0 x y z
x' y' z ' 1 = 1
0 0 0 1 ( px + qy + 1) ( px + qy + 1) ( px + qy + 1)
[ Tc ] = [ Tpq ][ Tz ]
1 0 0 p 1 0 0 0 1 0 0 p
0 1 0 q 0 1 0 0 0 1 0 q
= =
0 0 1 0 0 0 0 0 0
0 0 0
2 tâm chiếu:
[ -1/p 0 0 1 ] 0 0 0 1 0 0 0 1 0 0 0 1
[ 0 -1/q 0 1 ]
VP (Vanishing point) tương ứng trên 2 trục x và y là điểm: [ 1/p 0 0 1 ] và [ 0 1/q 0 1 ].
36
PHÉP CHIẾU PHỐI CẢNH 3 TÂM CHIẾU
[ Tpqr ] = [Tp ][Tq ][Tr ]
1 0 0 p 1 0 0 0 1 0 0 0 1 0 0 p
0 1 0 0 0 1 0 q 0 1 0 0 0 1 0 q
= =
0 0 1 0 0 0 1 0 0 0 1 r 0 0 1 r
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
1 0 0 p
0 1 0 q
x y z 1 = x y z ( px + qy + rz + 1)
0 0 1 r
0 0 0 1
x y z
x' y' z' 1 = 1
( px + qy + rz + 1) ( px + qy + rz + 1) ( px + qy + rz + 1) 37
PROPERTIES OF PERSPECTIVE PROJECTIONS
Here are some properties of Dưới đây là một số tính chất của các
projective transformations: phép biến đổi phối cảnh:
▪ Đoạn thẳng ánh xạ đoạn thẳng
Lines map to lines
▪ Các đường song song sau phép chiếu không
Parallel lines do not necessarily remain nhất thiết vẫn là song song
parallel
▪ Tỷ lệ không được bảo tồn
Ratios are not preserved
Một trong những lợi thế của phép chiếu phối
One of the advantages of perspective cảnh là kích thước thay đổi ngược với
projection is that size varies inversely with khoảng cách - trông thực tế.
distance – looks realistic. Một bất lợi là chúng ta không thể đánh giá
khoảng cách chính xác nhất có thể với các
A disadvantage is that we can't judge phép chiếu song song.
distances as exactly as we can with
parallel projections.
CLASSIFICATION OF PLANAR GEOMETRIC PROJECTIONS
39
HOW TO BUILD
3D VIEWING?
40
3D GEOMETRY PIPELINE
43
𝑦view
p0
𝐧: viewing 𝐮 view-up
directionon 𝐧 vector
𝑧view 𝑥view
𝐮 − 𝐯: viewing
plane
𝐮 = 𝑢𝑥 , 𝑢𝑦 , 𝑢𝑧 Camera: u, v, n
𝐯 = 𝑣𝑥 , 𝑣𝑦 , 𝑣𝑧 The n look vector indicates the direction in which the camera is
𝐧 = 𝑛𝑥 , 𝑛𝑦 , 𝑛𝑧 pointing
𝐩0 = 𝑥0 , 𝑦0 , 𝑧0 The up vector determines how the camera is rotated
For example, is the camera held vertically or horizontally
SPECIFYING A VIEWER
Camera specification requires 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.
VIEW PLANE
Projection Plane
Defined by
VRP (View Reference Point)
look at point in OpenGL
VPN (View Plane Normal)
(eye - look) in OpenGL
46
3D WINDOW
Similar to the window in 2D
Contents mapped to the viewport
Projection on the view plane
outside the window not shown
Specification needs the following
Minimum and maximum window coordinates
Two orthogonal axes
Can be defined by view volume
47
Unity Camera Essentials - 04 - Projection, FOV,
VIEW VOLUME Size, Clipping Planes
https://www.youtube.com/watch?v=K6cU6omb
SK8
48
https://www.youtube.com/wat
ch?v=mpTl003EXCY
3DVIEWING SUMMARY
PRP (Điểm Tham chiếu Chiếu)
•Song song: DOP = từ PRP đến CW
PRP (Projection Reference Point)
Parallel: DOP = from PRP to CW •Phối cảnh: COP
Perspective: COP •“Mắt” trong OpenGL
“Eye” in OpenGL
Hình khối quan sát
View volume
•Cắt tỉa và chiếu
Clipping and projection
Perspective •Phối cảnh
Semi-infinite pyramid with apex at PRP • Kim tự tháp bán vô hạn với đỉnh tại PRP và
các cạnh đi qua các góc cửa sổ
and edges passing through window
corners Song song,
Parallel Vô hạn song song với các cạnh song song
với DOP
Infinite parallelepiped with sides parallel
to DOP 49
DEMO
Unity Tutorial 6 -
Cameras in Unity Daniel
Wood
https://www.youtube.com
/watch?v=blSU_KC_RJQ
Building a Camera
Controller for a Strategy
Game – Game Dev
https://www.youtube.com
/watch?v=rnqF6S7PfFA
Using Cinemachine: State
Driven Cameras
https://www.youtube.com
/watch?v=2X00qXErxIM
50
VIEWING IN OPENGL
OpenGL has multiple matrix stacks -
transformation functions right-multiply the top
of the stack
Two most important stacks: GL_MODELVIEW
and GL_PROJECTION
Points get multiplied by the model view matrix
first, and then the projection matrix
GL_MODELVIEW: Object->Camera
GL_PROJECTION: Camera->Screen
glViewport(0,0,w,h): Screen->Device
https://www.youtube.com/watch?v=G6skrOtJtb
M
VIEWING WITH OPENGL
Positioning and aiming camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eye.x, eye.y, eye.z, // eye position
look.x, look.y, look.z, // look at point
up.x, up.y, up.z) // up vector
Up vector is often set to (0, 1, 0)
https://www.youtube.com/watch?v=P6pJHrA9
Avs
52
OPENGL 3D VIEWING ORTHOGONAL
PROJECTION
MatrixMode(GL_PROJECTION);
glOrtho(xwmin, xwmax, ywmin, ywmax, dnear, dfar);
xwmin, xwmax, ywmin,ywmax:
specification window
dnear: distance to near clipping plane
dfar : distance to far clipping plane
Select dnear and dfar right:
dnear < dfar,
model fits between clipping planes.
OPENGL 3D VIEWING
PERSPECTIVE PROJECTION
MatrixMode(GL_PROJECTION);
glFrustrum(xwmin, xwmax, ywmin, ywmax, dnear, dfar);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glPerspective(viewAngle, aspectRatio, N, F)
Example:
glPerspective(60.0, 1.5, 0.3, 50.0)
Near plane serves as the view plane
OPENGL 3D VIEWING
Finally, specify the viewport (just like in 2D):
glViewport(xvmin, yvmin, vpWidth, vpHeight);
xvmin, yvmin: coordinates lower left corner (in pixel coordinates);
vpWidth, vpHeight: width and height (in pixel coordinates);
glMatrixMode(GL_PROJECTION);
glFrustrum(xwmin, xwmax, ywmin, ywmax, dnear, dfar);
glViewport(xvmin, yvmin, vpWidth, vpHeight);
glMatrixMode(GL_MODELVIEW);
gluLookAt(x0,y0,z0, xref,yref,zref, Vx,Vy,Vz);
Make sure that you can deal with resize/reshape of the (OS) window.
OPENGL EXAMPLE
void SetUpViewing()
{
// The viewport isn’t a matrix, it’s just state...
glViewport( 0, 0, window_width,
window_height );
57
STEREO PROJECTIONS
Faking depth in a 2D image
Based on natural stereoscopic eye-brain system.
Objects are not viewed with just one eye, but two eyes.
Each eye looks at the object from a slightly different location.
58
STEREO PROJECTIONS
59
Tài liệu phục vụ
học tập sinh viên
CNTT&TT ĐHBK -
HN
Tài liệu sử dụng Hình ảnh , Text , Video trên mạng theo
nguyên tắc FU – CC và tuân thủ theo quy tắc đó
Sinh viên, người học hoàn toàn có quyền chỉnh sửa,
copy và tái suất bản theo CC & FU