1 / 17

CS770/870

CS770/870. Class 6 PERSPECTIVE. Orthographic projections. Isometric. Oblique. In isometric all distances along the major axes are the same. Orthographic Oblique using a shear. Move x and y proportional to the depth. To generate Oblique perspective. Cot( q ) = dx / dz.

saber
Télécharger la présentation

CS770/870

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS770/870 Class 6 PERSPECTIVE

  2. Orthographic projections Isometric Oblique In isometric all distances along the major axes are the same

  3. Orthographic Oblique using a shear Move x and y proportional to the depth

  4. To generate Oblique perspective Cot(q) = dx/dz Cot(f) = dy/dz

  5. Orthographic projection matrix The effect is to scale in to a [-1,+1] cube. Note – the mapping into a viewport is actually done in two stages First we map into a cube. Then we map into the viewport. Reason:Clipping

  6. The Z buffer algorithm • Problem, how do we make sure that nearer objects hide further objects? • A reason why we need to preserve depth after projection. • The z-buffer contains depth information about an image for every pixel that is rendered between the near and the far clipping plane. • For each pixel, about to be rendered. • If closer than z-buffer depth draw rgb and z value. • Else, discard. It works because the image has already been transformed

  7. Perspective. How to get the scaling

  8. Brunelleschi’s window

  9. Perspective transformation - simplified Final step, divide x and y by w w=z/d Where P is the projective transformation matrix (above) M = PS S is the Scene to Viewport mapping

  10. Two specifications Why? glFrustum (Left,Right, Bottom, Top, Near, Far); gluPerspective(fov, aspect, near far);

  11. View control The Lookat function from a viewpoint (vp) to a scene point (sp) gluLookat(vpX,vpY, vpZ, spX,spY,spZ, upX, upY, upZ); Three ways of doing it. Using gluLookat, or using translate and rotate, or Using change in basis.

  12. Change in basis Express one set of axes in the coordinates of another. In a simple form this is a rotation. Y V U Coordinates of U,V axis As unit vectors Expressed in X,Y system (x,y) X Convert point (x,y) to point (u,v)

  13. How to get a rotation to view vector Use basis method Take difference Normalize Put into matrix form n (eY,eY) v (atX, atY)

  14. To deal with the Up Vector in 3D Purpose, Rotate view so that some defined up in the scene is aligned with the vertical direction on the screen. Calculate view vector v (difference + normalize) Given up vector u use cross products Side ways vector of view coordss= uxv New up vector n = uxs sx sy sz nx ny nz vy vx vz Useful fact: the Transpose of a rotation matrix is its inverse.

  15. How to fly Keep moving the viewpoint in the direction of travel Rotate according to the view direction. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(viewAngle*180.0/3.141592, 0,1,0); glTranslatef(-eyeX,-eyeY, -eyeZ); // to origin scene(); glPopMatrix(); glutSwapBuffers(); df = my*0.01; // the speed in the forward direction (my from mouse) viewAngle += mx*0.0001; // Azimuth in radians dz = cos(viewAngle)*df; dx= sin(viewAngle)*df; eyeX += dx; eyeZ-= dz;

  16. Clipping Cohen Sutherland The outcode function returns an outcode as follows Ymax Ymin bbbb >Ymax Xmin Xmax < Xmin < Ymin >Xmax

  17. Cohen Sutherland Cases C p2 C A C p1 B different regions, may need clipping Let o1 be the outcode of p1 Case A: o1 = o2 = 0; Both inside, no clipping needed Case B: (o1 & 02) |= 0; all bits same  same region  discard Case C: (o1 XOR 01) > 0 ; some bits different different regions, may need clipping

More Related