Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 Bi Nguyờn lý v 3D v Phộp chiu-Projection Nguyờn lý v 3D Lờ Tn Hựng 0913030731 hunglt@it-hut.edu.vn (c) SE/FIT/HUT 2002 é chiu - 3D computer graphics bao gm vic b xung kớch thc v chiu sõu ca i tng, cho phộp ta biu din chỳng th gii thc mt cỏch chớnh xỏc v sinh ng hn Tuy nhiờn cỏc thit b truy xut hin ti u l chiu, Do vy vic biu din c thc thi thụng qua phộp tụ chỏt render gõy o giỏc illusion v sõu 3D Graphics l vic chyn th gii t nhiờn di dng cỏc mụ hỡnh biu din trờn cỏc thit b hin th thụng qua k thut tụ chỏt (rendering) (c) SE/FIT/HUT 2002 éc im ca k thut ho 3D Cỏc phng phỏp hin th 3D Cú cỏc i tng phc tapj hn cỏc i tng khụng gian 2D Cỏc phộp bin i hỡnh hc phc Cỏc phộp bin i h to phc hn Thng xuyờn phi b xung thờm phộp chiu t khụng gian 3D vo khụng gian 2D Luụn phi xỏc nh cỏc b mt hin th (c) SE/FIT/HUT 2002 Perspective and Depth of Field Vi cỏc thit b hin th 2D: Bao bi cỏc mt phng hay cỏc b mt Cú cỏc thnh phn v ngoi 3D viewing positions K thut chiu - projection: orthographic/perspective K thut ỏnh du sõu - depth cueing Nột khut - visible line/surface identification Tụ chỏt b mt-surface rendering Ct lỏt - exploded/cutaway scenes, cross-sections Thit b hin th 3D: Kớnh stereo - Stereoscopic displays* Mn hỡnh 3D - Holograms (c) SE/FIT/HUT 2002 Exploded/cutaway scenes 3D GRAPHICS WORLD PIPELINE SCENE/OBJECT Shadows as depth cues Modelling coordinates: - world coordinate system, - object coordinate system 3D MODELLING VIEWING 3D CLIPPING Camera coordinates PROJECTION Screen/Window coordinates RASTERIZATION Device coordinates Different views of a 3D model (c) SE/FIT/HUT 2002 2D PIXELMAP DISPLAY (c) SE/FIT/HUT 2002 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 3D - Modelling Clipping 3D x +y +z =r 2 2 view frustrum Polygonal 3D Modelling Implicit x = sin y = cos outside view so must be clipped Particles Parametric (c) SE/FIT/HUT 2002 Viewing and Projection (c) SE/FIT/HUT 2002 (c) SE/FIT/HUT 2002 10 Rasterization 3d models camera setup viewport (c) SE/FIT/HUT 2002 Cỏc bc xõy dng hỡnh chiu Phộp chiu tọa độ thực 3D nh ngha v phộp chiu tọa độ theo vùng cắt Cắt theo view volum nh ngha v hỡnh chiu nh ca i tng trờn mt phng chiu c hỡnh thnh t phộp chiu bi cỏc ng thng gi l tia chiu (projector) xut phỏt t mt im gi l tõm chiu (center of projection) i qua cỏc im ca i tng giao vi mt chiu (projection plan) (c) SE/FIT/HUT 2002 11 khung nhìn Phép chiếu mặt phẳng chiếu tọa độ thiết bị Phép biến đổi vào cổng nhìn tọa độ thiết bị i tng khụng gian 3D vi ta thc c ct theo mt khụng gian view volume c chiu lờn mt phng chiu Din tớch choỏn bi view volume xỏc nh gi l view volume trờn mt phng chiu ú s cho chỳng ta khung nhỡn l vic ỏnh x khung nhỡn vo mt cng nhỡn bt k cho trc trờn mn hỡnh hin th hỡnh nh (c) SE/FIT/HUT 2002 12 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 Phộp chiu song song Parallel Projections Phộp chiu song song - Parallel Projections Phõn loi phộp chiu song song da trờn hng ca tia chiu Direction Of Projection v mt phng chiu projection plane Phộp chiu trc giao (Orthographic projection) ng vi mi mt phng chiu ta cú ma trn chiu tng ng [T y ] = 0 0 0 0 [T ] = x 0 0 0 1 0 [T z ] = 0 0 13 (c) SE/FIT/HUT 2002 Phộp chiu trc lng (Axonometric) 0 0 0 0 (c) SE/FIT/HUT 2002 14 (c) SE/FIT/HUT 2002 16 Trimetric Phộp chiu trc lng Phộp chiu Trimetric trờn c s t l co - SF ca nh i tng trờn mi trc l khỏc SF- t l co theo cỏc trc l: f x = x' 2x + y' 2x xx' ' x [T ] = y' xz 0 [U ] = 1 0 1 y x' y 'y y z' (c) SE/FIT/HUT 2002 1 f y = x' 2y + y' 2y f z = x' 2z + y' 2z 15 Phộp chiu Dimetric [T ] = [ Ry ][ Rx ][ Pz ] cos = sin 0 sin 0 cos cos 0 sin 0 cos [T ] = sin sin sin cos cos sin L phộp chiu Trimetric vi h s t l co bng nhau, giỏ tr th cũn li l tu ý sin 0 cos 0 0 0 0 0 0 f z2 = (xz'2 + yz'2 ) = sin2 + cos2 sin2 f y2 = ( x 'y2 + y 'y2 ) = cos = sin ( 0 0 0 = sin ( fz f z2 fz ) ) (c) SE/FIT/HUT 2002 17 (c) SE/FIT/HUT 2002 18 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 Phộp chiu Isometric sin = sin sin sin sin sin2 1/ sin2 = = = 1/ sin2 1/ sin = sin = = 35.260 = 450 f = cos = / = 0.8165 19 (c) SE/FIT/HUT 2002 (c) SE/FIT/HUT 2002 Parallel Projections 20 Phộp chiu xiờn - Oblique Phộp chiu Cavalier Phộp chiu Cabinet orthographic oblique axonometric isometric (c) SE/FIT/HUT 2002 21 (c) SE/FIT/HUT 2002 22 (c) SE/FIT/HUT 2002 24 Phộp chiu Cavalier [T ' ' ] = a b 0 0 0 a = f cos b = f sin [T ] = f cos (c) SE/FIT/HUT 2002 f sin 0 0 0 23 f = 0, = 900 phộp chiu s tr thnh phộp chiu trc giao Cũn vi f = kớch thc ca hỡnh chiu bng kớch thc ca i tng => cavalier Phộp chiu Cavalier cho phộp giỏ tr ca bin i mt cỏch t = 300 v 450 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 Phộp chiu Cabinet Oblique Projections Phộp chiu xiờn vi h s co t l f = 1/2 f = cos ( = cos ( + f 2 ) ) = 63.435 + (1 ) 2 D/2 D D D Cavalier Project Cabinet Projection (c) SE/FIT/HUT 2002 25 (c) SE/FIT/HUT 2002 Phộp chiu phi cnh Perspective Projection Vanishing points Phộp chiu phi cnh Cỏc on thng song song ca mụ hỡnh 3D sau phộp chiu hi t ti im gi l im trit tiờu - vanishing point Phõn loi phộp chiu phi cnh da vo tõm chiu - Centre Of Projection (COP) v mt phng chiu projection plane Each set of parallel lines (=direction) meets at a different point: The vanishing point for this direction Sets of parallel lines on the same plane lead to collinear vanishing points: the horizon for that plane Easy examples (c) SE/FIT/HUT 2002 corridor higher = further away Good way to spot faked images 27 im trit tiờu Vanishing point 26 28 (c) SE/FIT/HUT 2002 Perspective Projections 3-point perspective im trit tiờu quy tc - principle vanishing point 1-point perspective The number of principal vanishing points is determined by the number of principal axes cut by the projection plane If the plane only cut the z axis (most common), there is only vanishing point 2-points sometimes used in architecture and engineering 3points seldom used add little extra realism 2-point perspective (c) SE/FIT/HUT 2002 29 (c) SE/FIT/HUT 2002 30 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 Phộp bin i phi cnh Phộp chiu phi cnh [Tr ] = Phộp chiu phi ca?nh ca cỏc im trờn i tng lờn trờn mt phng 2D thu c t phộp chiu trc giao v phộp bin i phi cnh 31 (c) SE/FIT/HUT 2002 Consider a perspective projection with the viewpoint at the origin and a viewing direction oriented along the positive -z axis and the view-plane located at z = -d y yP y = yP = z d zd Tham s: centre of projection (COP) field of view (, ) projection direction up direction a similar construction for xp d y yp Perspective Projection Details 0 PROJECTION matrix divide by homogenous ordinate to map back to 3D space (c) SE/FIT/HUT 2002 x y z 34 Gi s mt phng c t ti z = v tõm phộp chiu nm trờn trc z , cỏch trc z mt khong zc = -1/r Nu i tng cng nm trờn mt phng z = thỡ i tng s cho hỡnh nh tht Phng trỡnh bin i: [ x y z ][ Tr ] = [ x y z rz+1 ] ma trn bin i mt im phi cnh [ Tr ] cú dng: perspective division [ Tr Flip z to transform to a left handed co-ordinate system increasing z values mean increasing distance from the viewer (c) SE/FIT/HUT 2002 -z 0 0 1d Phộp chiu phi cnh tõm x x xP z d y y y P = z zP z d d z d x y z 0 x x xP z d y y y = P = z zP z d d z d 33 (c) SE/FIT/HUT 2002 x y = z 32 (c) SE/FIT/HUT 2002 Perspective Projections Perspective Projections 0 0 r 0 35 ] = 0 0 0 0 0 r (c) SE/FIT/HUT 2002 36 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 phộp chiu phi cnh tõm Phộp chiu phi cnh tõm Y VP (y=10) VP y = 10 y = 0 0 1 0 r 0 1 [x y z 1] 0 0 1 0 = 0 0 0 0 0 0 0 D 0 0 0 r 0 H C H G A, EB, F C E A, EB, Fx F x A E A F B x B z 0 = [x y rz+1] r [x' y x y' z' 1] = rz +1 rz +1 x y ' z ' 1] = ( px + qy + 1) y ( px + qy + 1) = z ( px + qy + 1) 0 0 1 0 = 0 0 0 p q 0 0 1 = tõm chiu: [ -1/p 0 ] [ -1/q ] VP (Vanishing point) tng ng trờn trc x v y l im: [ 1/p 0 ] v [ 1/q ] y ( px + qy + rz + 1) [x H' G' C' E' G' C' VP ( x = 10 ) VP ( z = 10 ) z' A', E' F' x' B' B' (c) SE/FIT/HUT 2002 0 p 1 z 1] y z ( px + qy + 1)] 38 0 0 0 q 1 0 p q = [x r 0 1 0 y = r 0 0 0 0 p q r z ( px + qy + rz + 1)] 40 tõm chiu: trờn trc x ti im [ -1/p 0 ], y ti im [ -1/q ] z ti im [ 0 -1/r ] VP s tng ng vi cỏc giỏ tr : [ 1/p 0 ], [ 1/q ] [ 0 1/r ] [ Tc ] = [ Tpqr ][ Tz ] = F' A' x' 0 p q = [x 0 (c) SE/FIT/HUT 2002 D' H' z 1] z ( px + qy + rz + 1) y' D' 0 y y' VP ( y = 10) y [ Tpqr ] = [Tp ][Tq ][Tr ] 39 (c) SE/FIT/HUT 2002 x y' z ' 1] = ( px + qy + rz + 1) 0 [x Phộp chiu phi cnh tõm chiu 0 p q 0 p q 0 (c) SE/FIT/HUT 2002 [ Tc ] = [ Tpq ][ Tz ] [x' [T pq ] = 37 (c) SE/FIT/HUT 2002 [x' VP( x = 10) VP X=10 G D D, HC, G D H C,G y 41 0 p 1 q r 0 0 0 1 0 = 0 0 0 0 p q 0 r 0 (c) SE/FIT/HUT 2002 42 Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 8682595 Phõn loi cỏc phộp chiu (c) SE/FIT/HUT 2002 43 ...Khoa CNTT DHBK Hanoi hunglt@it-hut.edu.vn 868 259 5 3D - Modelling Clipping 3D x +y +z =r 2 2 view frustrum Polygonal 3D Modelling Implicit x = sin y = cos outside view so... chiu (center of projection) i qua cỏc im ca i tng giao vi mt chiu (projection plan) (c) SE/FIT/HUT 2002 11 khung nhìn Phép chiếu mặt phẳng chiếu tọa độ thiết bị Phép biến đổi vào cổng nhìn tọa... hunglt@it-hut.edu.vn 868 259 5 Phộp chiu song song Parallel Projections Phộp chiu song song - Parallel Projections Phõn loi phộp chiu song song da trờn hng ca tia chiu Direction Of Projection