graphics graphics lab @ korea university kucg.korea.ac.kr viewing 고려대학교 컴퓨터...
TRANSCRIPT
![Page 1: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/1.jpg)
Graphics
kucg.korea.ac.kr Graphics Lab @ Korea University
Viewing
고려대학교 컴퓨터 그래픽스 연구실
![Page 2: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/2.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Fundamental Types of Viewing
Perspective views finite COP (center of projection)
Parallel views COP at infinity DOP (direction of projection)
perspective view parallel view
![Page 3: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/3.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Parallel View
![Page 4: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/4.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective View
![Page 5: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/5.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Classical Viewing
Specific relationship between the objects and the viewers
![Page 6: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/6.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Orthographic Projections
Projectors are perpendicular to the projection plane preserve both distances and angles
orthographic projections temple and three multiview orthographic projections
![Page 7: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/7.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Axonometric Projections (1/2)
Projection plane can have any orientation with respect to the object projectors are still orthogonal to the projection planes
top view side viewconstruction
![Page 8: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/8.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Axonometric Projections (2/2)
Preserve parallel lines but not angles isometric – projection plane is placed symmetrically w
ith respect to the three principal faces dimetric – two of principal faces trimetric – general case
![Page 9: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/9.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Axonometric Projections (2/2)
Preserve parallel lines but not angles isometric – projection plane is placed symmetrically w
ith respect to the three principal faces dimetric – two of principal faces trimetric – general case
![Page 10: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/10.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Oblique Projections
Projectors can make an arbitrary angle with the projection plane preserve angels in planes parallel to the projection
plane
top view side viewconstruction
![Page 11: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/11.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective Projections (1/2)
Diminution of size when objects are moved father from the viewer, their
images become smaller
![Page 12: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/12.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective Projections (2/2)
One-, two-, and three-point perspectives how many of the three principal directions in the
object are parallel to the projection plane vanishing points
three-point perspective
two-point perspective
one-point perspective
![Page 13: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/13.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective Projections (2/2)
One-, two-, and three-point perspectives how many of the three principal directions in the
object are parallel to the projection plane vanishing points
three-point perspective
two-point perspective
one-point perspective
![Page 14: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/14.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective Projections (2/2)
One-, two-, and three-point perspectives how many of the three principal directions in the
object are parallel to the projection plane vanishing points
three-point perspective
two-point perspective
one-point perspective
![Page 15: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/15.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective Projections (2/2)
One-, two-, and three-point perspectives how many of the three principal directions in the
object are parallel to the projection plane vanishing points
three-point perspective
two-point perspective
one-point perspective
![Page 16: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/16.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Positioning of the Camera (1/3)
initial configuration after change in the model-view matrix
OpenGL places a camera at the origin of the world frame pointing in the negative z direction move the camera away from the objects
glTranslatef(0.0, 0.0, -d);glTranslatef(0.0, 0.0, -d);
![Page 17: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/17.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Positioning of the Camera (2/3)
Look at the same object from the positive x axis translation after rotation by 90 degrees about the y
axis
glMatrixMode(GL_MODELVIEW);glLoadIdentity( );glTranslatef(0.0, 0.0, -d);glRotatef(-90.0, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);glLoadIdentity( );glTranslatef(0.0, 0.0, -d);glRotatef(-90.0, 0.0, 1.0, 0.0);
![Page 18: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/18.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Positioning of the Camera (3/3)
Create an isometric view of the cube
y y
)1 ,1 ,1( )2 ,1 ,0(
z
y
1000
02/202/2
0010
02/202/2
1000
03/63/30
03/33/60
0001
1000
100
0010
0001
dyxRTRM
x x
)2 ,1 ,0(
view from positive z axis
view from positive z axis
view from positive x axis
![Page 19: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/19.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Positioning of the Camera (3/3)
Create an isometric view of the cube
glMatrixMode(GL_MODELVIEW);glLoadIdentity( );glTranslatef(0.0, 0.0, -d);glRotatef(35.26, 1.0, 0.0, 0.0);glRotatef(45.0, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);glLoadIdentity( );glTranslatef(0.0, 0.0, -d);glRotatef(35.26, 1.0, 0.0, 0.0);glRotatef(45.0, 0.0, 1.0, 0.0);
x
)3 ,0 ,0(
yy y
)1 ,1 ,1( )2 ,1 ,0(
x x
view from positive z axis
view from positive z axis
![Page 20: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/20.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
U-V-N System (1/2)
VRP (view-reference point), VPN (view-plane normal), and VUP (view-up vector) u, v (up-direction vector), n (normal vector)
x, y, z axes respectively
camera frame determination of the view-up vector
![Page 21: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/21.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
U-V-N System (2/2)
Translation after rotation VRP – (x, y, z) T(-x, -y, -z) VNP – (nx, ny, nz) n
VUP – vup v = vup – (vup• n) n
u = v n
( our assumption – all vectors must be normalized )※
1000
0
0
0
1000
100
010
001
zyx
zyx
zyx
nnn
vvv
uuu
z
y
x
TRM
![Page 22: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/22.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Look-At Function
OpenGL utility function
VRP: eyePoint VPN: – ( atPoint – eyePoint ) VUP: upPoint – eyePoint
gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);
look-at positioning
![Page 23: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/23.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Others
Roll, pitch, and yaw
ex. flight simulation
Elevation and azimuth ex. star in the sky
![Page 24: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/24.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Simple Perspective Projections (1/2) Simple camera
projection plane is orthogonal to z axis projection plane in front of COP
three-dimensional view
top view side view
d
x
z
xdz p
p ,
dz
yy
dz
xx pp /
,/
![Page 25: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/25.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Simple Perspective Projections (2/2) Homogeneous coordinates
Perspective projection matrix
w
wz
wy
wx
z
y
x
1
p
dz
z
y
x
dz
zdz
ydz
x
ddz
ydz
x
z
y
x
p
p
p
/1/
/
/
1
/
/
1
p
0/100
0100
0010
0001
d
M
projection pipeline
Model-viewModel-view ProjectionProjection Perspective division
Perspective division
![Page 26: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/26.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Simple Orthogonal Projections
Projectors are perpendicular to the view plane
Orthographic projection matrix
0
p
p
p
z
yy
xx
11000
0000
0010
0001
1
z
y
x
z
y
x
p
p
p
![Page 27: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/27.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Projections in OpenGL
Angle of view only objects that fit within the
angle of view of the camera appear in the image
View volume be clipped out of scene frustum – truncated pyramid
![Page 28: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/28.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective in OpenGL (1/2)
Specification of a frustum
near, far: positive number !!
zmax = – far
zmin = – near
glMatrixMode(GL_PROJECTION);glLoadIdentity( );glFrustum(xmin, xmax, ymin, ymax, near, far);
glMatrixMode(GL_PROJECTION);glLoadIdentity( );glFrustum(xmin, xmax, ymin, ymax, near, far);
![Page 29: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/29.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Perspective in OpenGL (2/2)
Specification using the field of view
fov: angle between top and
bottom planes fovy: the angle of view in the
up (y) direction aspect ratio: width divided
by height
glMatrixMode(GL_PROJECTION);glLoadIdentity( );gluPerspective(fovy, aspect, near, far);
glMatrixMode(GL_PROJECTION);glLoadIdentity( );gluPerspective(fovy, aspect, near, far);
![Page 30: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/30.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Parallel in OpenGL
Orthographic viewing function
OpenGL provides only this parallel-viewing function near < far !!
no restriction on the sign
zmax = – far
zmin = – near
glMatrixMode(GL_PROJECTION);glLoadIdentity( );glOrtho(xmin, xmax, ymin, ymax, near, far);
glMatrixMode(GL_PROJECTION);glLoadIdentity( );glOrtho(xmin, xmax, ymin, ymax, near, far);
![Page 31: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/31.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Walking Though a Scene (1/2)
void display(void){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(viewer[0], viewer[1], viewer[2], 0,0,0, 0,1,0); glRotatef(theta[0], 1.0, 0.0, 0.0); glRotatef(theta[1], 0.0, 1.0, 0.0); glRotatef(theta[2], 0.0, 0.0, 1.0); colorcube( );
glFlush( ); glutSwapBuffers( );}
void keys(unsigned char key, int x, int y){ if(key == ‘x’) viewer[0] -= 1.0; if(key == ‘X’) viewer[0] += 1.0; if(key == ‘y’) viewer[1] -= 1.0; if(key == ‘Y’) viewer[1] += 1.0; if(key == ‘z’) viewer[2] -= 1.0; if(key == ‘Z’) viewer[2] += 1.0;}
![Page 32: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/32.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Walking Though a Scene (2/2)
void myReshape(int w, int h){ glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION); glLoadIdentity( ); if( w <= h )
glFrustum(-2.0, 2.0, -2.0*(GLfloat)h/(GLfloat)w, 2.0*(GLfloat)h/(GLfloat)w, 2.0, 20.0);
elseglFrustum(-2.0 *(GLfloat)w/(GLfloat)h, 2.0 *(GLfloat)w/(GLfloat)h, -2.0, 2.0, 2.0, 20.0);
glMatrixMode(GL_MODELVIEW);}
![Page 33: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/33.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Projections & Shadows (1/2)
Shadow polygon Steps
light source at (xl, yl, zl)
translation (-xl, -yl, -zl)
perspective projection through the origin
translation (xl, yl, zl)
1000
100
010
001
00/10
0100
0010
0001
1000
100
010
001
1
l
l
l
l
l
l
l
z
y
x
y
z
y
x
PTTM
![Page 34: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/34.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Projections & Shadows (2/2)
GLfloat m[16]; /* shadow projection matrix */for(i=0; i<16; i++) m[i] = 0.0;m[0] = m[5] = m[10] = 1.0;m[7] = -1.0/yl;
glColor3fv(polygon_color);glBegin(GL_POLYGON);.. /* draw the polygon normally */.glEnd( );
glMatrixMode(GL_MODELVIEW);glPushMatrix( ); /* save state */glTranslatef(xl, yl, zl); /* translate back */glMultMatrixf(m); /* project */glTranslatef(-xl, -yl, -zl); /* move light to origin */glColorfv(shadow_color);glBegin(GL_POLYGON);.. /* draw the polygon again */.glEnd( );glPopMatrix( ); /* restore state */
![Page 35: Graphics Graphics Lab @ Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실](https://reader035.vdocuments.mx/reader035/viewer/2022081418/5697bf7c1a28abf838c8421e/html5/thumbnails/35.jpg)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Shadows from a Cube onto Ground