Comuter Grahics Viewing October 2, 25 htt://www.hallm.ac.kr/~sunkim/teach/25/cga Funamental Tes of Viewing Persective views finite COP (center of rojection) Parallel views COP at infinit DOP (irection of rojection) ersective view arallel view htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Parallel View htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Persective View htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Classical Viewing Secific relationshi between the objects an the viewers htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Orthograhic Projections Projectors are erenicular to the rojection lane reserving both istances an angles orthograhic rojections temle an three multiview orthograhic rojections htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Aonometric Projections (/2) Projection lane can have an orientation with resect to the object rojectors are still orthogonal to the rojection lanes construction to view sie view htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Aonometric Projections (2/2) Preserve arallel lines but not angles isometric rojection lane is lace smmetricall with resect to the three rincial faces imetric two of rincial faces trimetric general case htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Aonometric Projections (2/2) Preserve arallel lines but not angles isometric rojection lane is lace smmetricall with resect to the three rincial faces imetric two of rincial faces trimetric general case htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Oblique Projections Projectors can make an arbitrar angle with the rojection lane reserving angels in lanes arallel to the rojection lane construction to view sie view htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Persective Projections (/2) Diminution of sie when objects are move father from the viewer, their images become smaller htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Persective Projections (2/2) One-, two-, an three-oint ersectives how man of the three rincial irections in the object are arallel to the rojection lane vanishing oints three-oint ersective two-oint ersective one-oint ersective htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Persective Projections (2/2) One-, two-, an three-oint ersectives how man of the three rincial irections in the object are arallel to the rojection lane vanishing oints three-oint ersective two-oint ersective one-oint ersective htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Persective Projections (2/2) One-, two-, an three-oint ersectives how man of the three rincial irections in the object are arallel to the rojection lane vanishing oints three-oint ersective two-oint ersective one-oint ersective htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Persective Projections (2/2) One-, two-, an three-oint ersectives how man of the three rincial irections in the object are arallel to the rojection lane vanishing oints three-oint ersective two-oint ersective one-oint ersective htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Positioning of the Camera (/3) OenGL laces a camera at the origin of the worl frame ointing in the negative irection moving the camera awa from the objects gltranslatef(.,., -); initial configuration after change in the moel-view matri htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Positioning of the Camera (2/3) Looking at the same object from the ositive ais translation after rotation b 9 egrees about the ais glmatrimoe(gl_modelview); glloaientit( ); ); gltranslatef(.,., -); glrotatef(-9.,.,.,.); htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Positioning of the Camera (3/3) Creating an isometric view of the cube M TR R 6 / 3 3 / 3 3 / 3 6 / 3 2 / 2 2 / 2 2 / 2 2 / 2 (,, ) (,, 2) (,, 2) view from ositive ais view from ositive ais view from ositive ais htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Positioning of the Camera (3/3) Creating an isometric view of the cube glmatrimoe(gl_modelview); glloaientit( ); ); gltranslatef(.,., -); glrotatef(35.26,.,.,.); glrotatef(45.,.,.,.); (,, ) (,, 2) (,, 3) view from ositive ais view from ositive ais htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Look-At Function OenGL utilit function glulookat(ee, ee, ee, at, at, at, u, u, u); ee-osition, target-osition, an u-vector look-at ositioning htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
htt://www.hallm.ac.kr/~sunkim/teach/25/g htt://www.hallm.ac.kr/~sunkim/teach/25/cga Simle Persective Projections (/2) Simle camera rojection lane is orthogonal to ais rojection lane in front of COP three-imensional view to view sie view, /, / htt://www.hallm.ac.kr/~sunkim/teach/25/g htt://www.hallm.ac.kr/~sunkim/teach/25/cga Simle Persective Projections (2/2) Homogeneous coorinates Persective rojection matri w w w w / / / / / / / M rojection ieline Moel-view Moel-view Projection Projection Persective ivision Persective ivision
htt://www.hallm.ac.kr/~sunkim/teach/25/g htt://www.hallm.ac.kr/~sunkim/teach/25/cga Simle Orthogonal Projections Projectors are erenicular to the view lane Orthograhic rojection matri htt://www.hallm.ac.kr/~sunkim/teach/25/g htt://www.hallm.ac.kr/~sunkim/teach/25/cga Projections in OenGL Angle of view onl objects that fit within the angle of view of the camera aear in the image View volume being clie out of scene frustum truncate rami
Persective in OenGL (/2) Secification of a frustum glmatrimoe(gl_projection); glloaientit( ); ); glfrustum(min, ma, min, ma, near, far); near, far: ositive number!! ma far min near htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Persective in OenGL (2/2) Secification using the fiel of view glmatrimoe(gl_projection); glloaientit( ); ); glupersective(fov, asect, near, far); fov: angle between to an bottom lanes fov: the angle of view in the u () irection asect ratio: with ivie b height htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Parallel in OenGL Orthograhic viewing function glmatrimoe(gl_projection); glloaientit( ); ); glortho(min, ma, min, ma, near, far); OenGL rovies onl this arallel-viewing function near < far!! no restriction on the sign ma far min near htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Walking Though a Scene (/2) voi kes(unsigne char ke, int, int ) { if(ke ) viewer[] -.; if(ke X ) viewer[] +.; if(ke ) viewer[] -.; if(ke Y ) viewer[] +.; if(ke ) viewer[2] -.; if(ke Z ) viewer[2] +.; } voi isla(voi) { glclearcolor(.f,.f,.f,.f); glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrimoe(gl_modelview); glloaientit(); glulookat(viewer[], viewer[], viewer[2],,,,,,); glrotatef(theta[],.,.,.); glrotatef(theta[],.,.,.); glrotatef(theta[2],.,.,.); } colorcube( ); glutswabuffers( ); htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Walking Though a Scene (2/2) voi mreshae(int w, int h) { glmatrimoe(gl_projection); glloaientit( ); glviewort(,, w, h); if( w < h ) glfrustum(-2., 2., -2.*(GLfloat)h/(GLfloat)w, 2.*(GLfloat)h/(GLfloat)w, 2., 2.); else glfrustum(-2. *(GLfloat)w/(GLfloat)h, 2. *(GLfloat)w/(GLfloat)h, -2., 2., 2., 2.); } return; htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Projections & Shaows (/2) Shaow olgon Stes light source at ( l, l, l ) translation (- l, - l, - l ) ersective rojection through the origin translation ( l, l, l ) M T PT l l l / l l l l htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g
Projections & Shaows (2/2) GLfloat m[6]; /* shaow rojection matri */ for(i; i<6; i++) m[i].; m[] m[5] m[].; m[7] -./l; glcolor3fv(olgon_color); glbegin(gl_polygon);.. /* raw the olgon normall */. glen( ); glpushmatri( ); /* save state */ gltranslatef(l, l, l); /* translate back */ glmultmatrif(m); /* roject */ gltranslatef(-l, -l, -l); /* move light to origin */ glcolorfv(shaow_color); glbegin(gl_polygon);.. /* raw the olgon again */. glen( ); glpomatri( ); /* restore state */ htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g Shaows from a Cube onto Groun htt://www.hallm.ac.kr/~sunkim/teach/25/cga htt://www.hallm.ac.kr/~sunkim/teach/25/g