Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

ゲームグラフィックス特論 第３回 講義ノート

547

Published on

Published in: Education
3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
547
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
39
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript

• 1. 100 7 7.1 7.1.1 OpenGL 6 OpenGL API ( 78) ( CPU )
• 2. 101 GPU ( 79) 78 79 80 部品 部品 配置 配置
• 3. 102 7.1.2 ( ) ( 80) 7.1.3 ( 81) 81 82 82 ローカル座標系 ローカル座標系 ワールド座標系 視点座標系 x z y x z y x z y x z y スクリーン
• 4. 103 7.1.4 (View Volume) 2 (Canonical View Volume) ( 83) 83 (Orthogonal Projection) (Perspective Projection) ( 19) (View Frustum, ) 84 標準ビューボリューム 視野錐台 (View Frustum) 直交投影 (Orthographic Projection) 透視投影 (Perspective Projection) 1 -1 1 -1 1 -1 (Canonical View Volume) ビューボリューム (View Volume)
• 5. 104 7.2 7.2.1 ! (1) x a b (2) (3) (3) (4) 7.2.2 (4) x, y, z (5) x’, y’, z’ (3) ( ) (5) ( ) ( ) (x* , y* , z* ) (x, y, z, w) x0 = ax + b x0 = axxx + ayxy + bx y0 = axyx + ayyy + by x0 = axxx + ayxy + azxz + bx y0 = axyx + ayyy + azyz + by z0 = axzx + ayzy + azzz + bz 0 @ x0 y0 z0 1 A = 0 @ axx ayx azx axy ayy azy axz ayz azz 1 A 0 @ x y z 1 A + 0 @ bx by bz 1 A 0 B B @ x0 y0 z0 1 1 C C A = 0 B B @ axx ayx azx bx axy ayy azy by axz ayz azz bz 0 0 0 1 1 C C A 0 B B @ x y z 1 1 C C A
• 6. 105 (6) (x, y, z) (x, y, z, 1) w 0 (x, y, z) CG (x, y, z, 0) (x, y, z) (7) (8) (9) CG P0, P1 P0 = (x0, y0, z0, w0), P1 = (x1, y1, z1, w1) P0 P1 (10) w0 w1 0 w0w1 (11) (11) 0 P0 P1 0 (11) w0w1 x⇤ = x w y⇤ = y w z⇤ = z w 0 B B @ x y z 1 1 C C A ) (x, y, z) 0 B B @ x y z 0 1 C C A ) (x, y, z) a 0 B B @ x y z w 1 C C A = 0 B B @ ax ay az aw 1 C C A ) ⇣ ax aw , ay aw , az aw ⌘ = ⇣ x w , y w , z w ⌘ P1 w1 P0 w0 = 0 B B @ x1/w1 y1/w1 z1/w1 1 1 C C A 0 B B @ x0/w0 y0/w0 z0/w0 1 1 C C A = 0 B B @ x1/w1 x0/w0 y1/w1 y0/w0 z1/w1 z0/w0 0 1 C C A w0P1 w1P0 = 0 B B @ w0x1 w0y1 w0z1 w0w1 1 C C A 0 B B @ w1x0 w1y0 w1z0 w1w0 1 C C A = 0 B B @ w0x1 w1x0 w0y1 w1y0 w0z1 w1z0 0 1 C C A
• 7. 106 7.3 7.3.1 (5) 0 1 v M v’ = Mv (15) (12) (13) (14) (15) v’ (x’, y’, z’, w’) (16) v’ M v x’ = (m0 m4 m8 m12) (x y z w)T ((17) ) (17) 7.3.2 t = (tx, ty, tz) T(tx, ty, tz) (18) v = 0 B B @ x y z w 1 C C A v0 = 0 B B @ x0 y0 z0 w0 1 C C A M = 0 B B @ m0 m4 m8 m12 m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15 1 C C A 0 B B @ x0 y0 z0 w0 1 C C A = 0 B B @ m0 m4 m8 m12 m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15 1 C C A 0 B B @ x y z w 1 C C A x0 = m0 x + m4 y + m8 z + m12 w y0 = m1 x + m5 y + m9 z + m13 w z0 = m2 x + m6 y + m10 z + m14 w w0 = m3 x + m7 y + m11 z + m15 w 0 B B @ x0 y0 z0 w0 1 C C A = 0 B B @ m0 m4 m8 m12 m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15 1 C C A 0 B B @ x y z w 1 C C A T(t) = T(tx, ty, tz) = 0 B B @ 1 0 0 tx 0 1 0 ty 0 0 1 tz 0 0 0 1 1 C C A
• 8. 107 (x, y, z) (19) T(7, 8, 0) 85 85 0 (20) 7.3.3 s = (sx, sy, sz) S(sx, sy, sz) (21) 86 0 B B @ 1 0 0 tx 0 1 0 ty 0 0 1 tz 0 0 0 1 1 C C A 0 B B @ x y z 1 1 C C A = 0 B B @ x + tx y + ty z + tz 1 1 C C A T(7, 8, 0) x y O 7 8 x y O 0 B B @ 1 0 0 tx 0 1 0 ty 0 0 1 tz 0 0 0 1 1 C C A 0 B B @ x y z 0 1 C C A = 0 B B @ x y z 0 1 C C A S(s) = S(sx, sy, sz) = 0 B B @ sx 0 0 0 0 sy 0 0 0 0 sz 0 0 0 0 1 1 C C A x y O S(2, 2, 1)
• 9. 108 sx, = sy, = sz = a w 1/a (22) (23) 7.3.4 87 87 Y s X (24) (24) x, y, z (25) 0 B B @ a 0 0 0 0 a 0 0 0 0 a 0 0 0 0 1 1 C C A 0 B B @ x y z 1 1 C C A = 0 B B @ ax ay az 1 1 C C A ) (ax, ay, az) 0 B B @ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1/a 1 C C A 0 B B @ x y z 1 1 C C A = 0 B B @ x y z 1/a 1 C C A ) (ax, ay, az) O x y 1s 1 Hxy(s) = 0 B B @ 1 s 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 C C A Hxy(s) = 0 B B @ 1 s 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 C C A Hyz(s) = 0 B B @ 1 0 0 0 0 1 s 0 0 0 1 0 0 0 0 1 1 C C A Hzx(s) = 0 B B @ 1 0 0 0 0 1 0 0 s 0 1 0 0 0 0 1 1 C C A Hyx(s) = 0 B B @ 1 0 0 0 s 1 0 0 0 0 1 0 0 0 0 1 1 C C A Hzy(s) = 0 B B @ 1 0 0 0 0 1 0 0 0 s 1 0 0 0 0 1 1 C C A Hxz(s) = 0 B B @ 1 0 s 0 0 1 0 0 0 0 1 0 0 0 0 1 1 C C A
• 10. 109 7.3.5 " X 88 X (20) " Y 89 Y (21) θ! Rx(✓) = 0 B B @ 1 0 0 0 0 cos ✓ sin ✓ 0 0 sin ✓ cos ✓ 0 0 0 0 1 1 C C A θ! Ry(✓) = 0 B B @ cos ✓ 0 sin ✓ 0 0 1 0 0 sin ✓ 0 cos ✓ 0 0 0 0 1 1 C C A
• 11. 110 " Z 90 Z (22) " (l, m, n) 91 (23) 7.4 i’, j’, k’ p i, j, k p (x’, y’, z’), (x, y, z) p θ! Rz(✓) = 0 B B @ cos ✓ sin ✓ 0 0 sin ✓ cos ✓ 0 0 0 0 1 0 0 0 0 1 1 C C A (l,m,n) θ! R(l, m, n, ✓) = 0 B B @ l2 + (1 l2 ) cos ✓ lm(1 cos ✓) n sin ✓ ln(1 cos ✓) + m sin ✓ 0 lm(1 cos ✓) + n sin ✓ m2 + (1 m2 ) cos ✓ mn(1 cos ✓) l sin ✓ 0 ln(1 cos ✓) m sin ✓ mn(1 cos ✓) + l sin ✓ n2 + (1 n2 ) cos ✓ 0 0 0 0 1 1 C C A
• 12. 111 (30) (31) (x, y, z) (32) (i j k), (i’ j’ k’) (33) M (x, y, z) (x’, y’, z’) (34) M ( ) r, s, t (35) X Y Z x, y, z (36) r, s, t x, y, z M (37) (38) p = xi + yj + zk = x0 i0 + y0 j0 + z0 k0 i j k 0 @ x y z 1 A = i0 j0 k0 0 @ x0 y0 z0 1 A 0 @ x y z 1 A = i j k 1 i0 j0 k0 0 @ x0 y0 z0 1 A 0 @ x y z 1 A = i j k T i0 j0 k0 0 @ x0 y0 z0 1 A M = i j k T i0 j0 k0 = 0 @ i · i0 i · j0 i · k0 j · i0 j · j0 j · k0 k · i0 k · j0 k · k0 1 A r = 0 @ rx ry rz 1 A , s = 0 @ sx sy sz 1 A , t = 0 @ tx ty tz 1 A x = 0 @ 1 0 0 1 A , y = 0 @ 0 1 0 1 A , z = 0 @ 0 0 1 1 A 8 < : x = Mr y = Ms z = Mt x y z = M r s t
• 13. 112 92 (39) M (40) 7.5 7.5.1 93 x 4 y 3 (41) 93 x z y r s t M M M 0 @ 1 0 0 0 1 0 0 0 1 1 A = M 0 @ rx sx tx ry sy ty rz sz tz 1 A M = 0 @ rx sx tx ry sy ty rz sz tz 1 A 1 = 0 @ rx sx tx ry sy ty rz sz tz 1 A T = 0 @ rx ry rz sx sy sz tx ty tz 1 A = 0 @ rT sT tT 1 A T(4, 3, 0) T(4, 0, 0) T(0, 3, 0)
• 14. 113 (41) 7.5.2 (42) M ! t (43) 7.5.3 7.3.5 M = T(p) Rz(θ) T(−p) T(0, 3, 0)T(4, 0, 0) = 0 B B @ 1 0 0 0 0 1 0 3 0 0 1 0 0 0 0 1 1 C C A 0 B B @ 1 0 0 4 0 1 0 0 0 0 1 0 0 0 0 1 1 C C A = 0 B B @ 1 0 0 4 0 1 0 3 0 0 1 0 0 0 0 1 1 C C A = T(4, 3, 0) M = T(t)R(l, m, n, ✓) = 0 B B @ r00 r10 r20 tx r01 r11 r21 ty r02 r12 r22 tz 0 0 0 1 1 C C A ¯R = 0 @ r00 r10 r20 r01 r11 r21 r02 r12 r22 1 A , t = 0 @ tx ty tz 1 A ) M = 0 @ ¯R t 0T 1 1 A
• 15. 114 94 7.5.4 7.3.3 95 M = T(p) S(s) T(−p) p x y x y x y p T( p) θ" Rz(θ) T(p) M = T( p)Rz(θ)T(p) O O O O x y (移動)
• 16. 115 96 7.5.5 7.3.3 X Y Z X Y Z (x y z) (r s t) F sr ss st X Y Z S M = FSFT (44) (45) 97 x y x y p T(-p) T(p) M = T( p)S (s)T(p) S(s) p x y O O O F = ✓ r s t 0 0 0 0 1 ◆ S = 0 B B @ sr 0 0 0 0 ss 0 0 0 0 st 0 0 0 0 1 1 C C A FT FS x ys r O s rO s rO x ys r O M = FTSF
• 17. 116 7.5.6 98 7.6 7.6.1 X, Y, Z 99 Z R(θ) R(θ) S(s) S(s) x y O x y O x y O x y O x y O x y O heading pitchroll z x y
• 18. 117 (roll, bank) X (pitch) Y (heading, yaw) r, p, h ! r: roll, bank (Z ) ! p: pitch (X ) ! h: heading, yaw (Y ) E(h, p, r) (46) 7.6.2 p = / 2 sin p = 1, cos p = 0 (46) (47) (48) (h - r) r h p = / 2 r (Z ) h 7.6.3 M E(h, p, r) (49) m1 m5 r E(h, p, r) = Ry(h)Rx(p)Rz(r) = 0 B B @ cos h 0 sin h 0 0 1 0 0 sin h 0 cos h 0 0 0 0 1 1 C C A 0 B B @ 1 0 0 0 0 cos p sin p 0 0 sin p cos p 0 0 0 0 1 1 C C A 0 B B @ cos r sin r 0 0 sin r cos r 0 0 0 0 1 0 0 0 0 1 1 C C A = 0 B B @ sin h sin p sin r + cos h cos r sin h sin p cos r cos h sin r sin h cos p 0 cos p sin r cos p cos r sin p 0 cos h sin p sin r sin h cos r cos h sin p cos r + sin h sin r cos h cos p 0 0 0 0 1 1 C C A E(h, ⇡/2, r) = 0 B B @ sin h sin r + cos h cos r sin h cos r cos h sin r 0 0 0 0 1 0 cos h sin r sin h cos r cos h cos r + sin h sin r 0 0 0 0 0 1 1 C C A E(h, ⇡/2, r) = 0 B B @ cos(h r) sin(h r) 0 0 0 0 1 0 sin(h r) cos(h r) 0 0 0 0 0 1 1 C C A M = 0 B B @ m0 m4 m8 m12 m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15 1 C C A = E(h, p, r)
• 19. 118 (50) m8 m10 h (51) p m9 (52) m1 = m5 = 0 cos p = 0 p = / 2 (50) (51) r h h = 0 m0 m14 h (53) 7.7 7.8 7.9 OpenGL 7.10 7.11 7.11.1 7.11.2 7.11.3 7.11.4 m1 = cos p sin r m5 = cos p cos r ! r = atan2(m5, m1) m8 = sin h cos p m10 = cos h cos p ! h = atan2(m10, m8) m9 = sin p ! p = asin( m9) m0 = cos(h ⌥ r) m4 = sin(h ⌥ r) ! h = 0, r = atan2(m0, m4)