210 likes | 366 Views
Graphics. Lab 5. Transformation Viewport Clipping . Transformation Modeling -> translate (); rotate ();scale() Viewing -> lookat () ; Projection : Perspective Orthographic Viewport Clipping . Projections . There are two basic types of projections: Perspective:
E N D
Graphics Lab 5
Transformation • Viewport • Clipping
Transformation • Modeling ->translate (); rotate ();scale() • Viewing ->lookat() ; • Projection : • Perspective • Orthographic • Viewport • Clipping
Projections • There are two basic types of projections: • Perspective: • Orthographic = Parallel
Perspective: gluPerspective(fov_y, aspect_ratio, near, far) • fov_y is vertical field-of-view in degrees • aspect ratio = width / height • near, far are distances from eye to two clipping planes • must be positive
Zoom • Field of view: Smaller angle means more zoom
OpenGL Projection • For orthographic projection • For perspective projection • Window parameters are with respect to view position and orientation glMatrixMode(GL_PROJECTION); glOrtho(xwmin,xwmax,ywmin,ywmax,dnear,dfar); glMatrixMode(GL_PROJECTION); gluPerspective(theta,aspect,dnear,dfar); glMatrixMode(GL_MODELVIEW); gluLookAt(x0,y0,z0,xref,yref,zref,Vx,Vy,Vz); … other modelview transformations … *Note: dnear and dfar are the distances from camera position to near and far planes respectively. They should be positive.
orthographic projection glOrtho(left, right, bottom, top, near, far) • left, right, bottom, top are coordinates in eye space • left, right are the x-coordinate limits • bottom, top are the y-coordinate limits • near, far are signed distances from the eye to the near and far
Notes : when Zeye equal with zfar ,the object will be Disappearance
Viewport : • EX: glViewport (0, 0, (GLsizei)width, (GLsizei)height);
void keyboard (unsigned char key, int x, int y) • In the main : • glutKeyboardFunc(keyboard);