Viewing 1 th Week, 29 OpenGL Viewing Functions glulookat() Defining a viewing matrix glortho() Creating a matrix for an orthographic parallel viewing i volume glfrustum() Creating a matrix for a perspective-view frustum gluperspective() Creating a matrix for a symmetric perspective-view frustum
새프로젝트 Visual C++ Win32 프로젝트 빈프로젝트 응용프로그램설정
새항목추가 C++ 파일
main1.cpp cpp 다운로드 main.cpp cpp 소스파일
프로젝트속성 멀티바이트문자집합사용
OpenGL 라이브러리파일링크 실행결과
GLUT Library (1) GLUT Library (2) glut.h ( /Microsoft SDKs/Windows/v6.A/Include/gl) glut32.lib ( /Microsoft SDKs/Windows/v6.A/Lib) glut32.dll ( Windows/system32) void glutwiresphere(gldouble radius, GLint slices, Glint stacks); void glutsoildsphere(gldouble radius, GLint slices, Glint stacks); void glutwirecone(gldouble base, GLdouble height, GLint slices, Glint stacks); void glutsoildcone(gldouble base, GLdouble height, GLint slices, Glint stacks); void glutwiretorus(gldouble inner, GLdouble outer, GLint sides, Glint slices); void glutsoildtorus(gldouble inner, GLdouble outer, GLint sides, Glint slices); void glutwirecube(gldouble size); void glutsoildcube(gldouble size); void glutwireteapot(gldouble size); void glutsoildteapot(gldouble size); void glutwiretetrahedron(); void glutsoildtetrahedron(); void glutwireoctahedron(); void glutwireoctahedron(); void glutwiredodecahedron(); void glutsoilddodecahedron(); void glutwireicosahedron(); void glutwireicosahedron();
GLUT Library (3) GLUT Library (4)
GLUT Library (5) glut.h copy to project folder (ex: /Prac6) glut32.lib, glut32.dll copy to debug folder (ex: /Prac6/Debug) Drawing Objects (1)
실행결과 Drawing Objects (1) 연습문제 (1) Cone 을회전시켜옆면이보이도록만드시오.
Drawing Objects (2) glpushmatrix( ) and glpopmatrix( ) Performing a transformation and then returning to the same state as before its execution Ex) instance transformation glpushmatrix(); gltranslatef(...); glrotatef(...); glscalef(...); /* draw object here */ glpopmatrix();
실행결과 Drawing Objects (2) 연습문제 (2) Icosahedron 의크기를반으로줄이고, 아래의그림처럼배치하시오. 원점
Drawing Objects (3) 실행결과 Drawing Objects (3)
[Tip] Line Drawing 실행결과 [Tip] Line Drawing
새항목추가 헤더파일 trackball.h h 다운로드
trackball.h h 소스파일 Virtual Trackball (1)
Virtual Trackball (2) Virtual Trackball (3)
Virtual Trackball (4) Setting Matrices Directly Constructing a matrix directly or using it not a transformation function void glloadmatrix{fd}( TYPE *m ); void glmultmatrix{fd}( TYPE *m ); m: 16-element one-dimensional arrays in column order rather than 4x4 two-dimensional arrays
실행결과 Virtual Trackball 연습문제 (3) glmultmatrixd(); 함수의위치를아래와같이각각옮긴후실행해보시오. glpushmatrix(); 다음줄로이동 glpopmatrix(); 다음줄로이동 gltranslatef(.f,.5f,.f); f f); 다음줄로이동 위와같이실행되는이유를설명해보시오.
Look-At Function (1) The GLU library contains the function To form the require model-view matrix glmatrixmode( GL_MODELVIEW ); glloadidentity( ); glulookat(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz); Eye-position, target-position, t and up-vector Look-At Positioning Look-At Function (2)
What s Wrong? Parallel in OpenGL (1) Orthographic viewing function glmatrixmode(gl_projection); glloadidentity( ); glortho(xmin, xmax, ymin, ymax, near, far); OpenGL provides only this parallel-viewing l i function near < far!! no restriction ti on the sign z max = far z min = near
Parallel in OpenGL (2) 실행결과 Parallel in OpenGL
Perspective in OpenGL (1) Specification of a frustum glmatrixmode(gl_projection); glloadidentity( ); glfrustum(xmin, xmax, ymin, ymax, near, far); near, far: positive number!! z max = far z min = near Perspective in OpenGL (2) Specification using the field of view glmatrixmode(gl_projection); glloadidentity( ); gluperspective(fovy, aspect, near, far); fovy: : the angle between top and bottom planes (in the up (y)direction) aspect: width divided by height h
glfrustum( ) 실행결과 glfrustum( )
연습문제 (4) glfrustum() 함수의 near 와 far 파라미터값을변경해보고, 그의미를파악하시오. glfrustum(xmin, xmax, ymin, ymax, near, far); gluperspective( )
실행결과 gluperspective( ) 연습문제 (5) gluperspective() 함수의 fovy 파라미터값을변경해보고, 그의미를파악하시오. gluperspective(fovy, aspect, near, far);
연습문제 (6) 사용자가요구하는대로 Viewing 을변경하시오. o orthographic viewing p perspective viewing Drawing the Ground (1)
Drawing the Ground (2) Drawing the Ground (3)
실행결과 Drawing the Ground (1) 연습문제 (7) Ground 의크기를 1 배로늘리고 Cone 아래로 Ground 의크기를 1 배로늘리고, Cone 아래로평행이동시키시오.
Drawing a Grid 실행결과 Drawing a Grid
Walking Through a Scene (1) Walking Through a Scene (2)
Walking Through a Scene (3) 실행결과 Walking Through
Projections & Shadows Projections & Shadows Shadow polygons Shadow polygons Steps Li h ( ) Light source at (x l, y l, z l ) Translation (-x l, -y l, -z l ) Perspective projection through the origin Translation (x l, y l, z l ) 1 1 1 l x l x = = 1 1 1 1 1 1 1 l l l l z y z y PT T M 1 1/ 1 l y Projection Shadow (1) Projection Shadow (1)
Projection Shadow (2) Projection Shadow (3)
What s Wrong? Projection Shadow (4)
실행결과 Projection Shadow 연습문제 (8) glut 라이브러리를이용하여, 4 개이상의 Object 들을생성하시오. 각 Object 에는그림자가있어야함 각 Object는제자리에서 local y축회전을하고있어야함 [Option] FPS 용 walk-through 를구현하시오. 카메라전진 / 후진 look 벡터방향 카메라좌 / 우 y 축 rotation ti 카메라상 / 하 없음 ( 땅에붙어서걸어다님 )