CS10101001 2D and 3D Viewing Basics Junqiao Zhao 赵君峤 Department of Computer Science and Technology College of Electronics and Information Engineering Tongji University
Viewing Analog to the physical viewing Objects Camera the position of camera the type of lens the position and the shape of film Viewing is based on the relationship among these elements
Viewing Transformations (2013 Steve Marschner)
Coordinate frames Local coordinates World coordinates Camera coordinates (viewing coordinates) Screen/Viewport coordinates Window coordinates (device coordinates)
Viewing implementation Transform into camera coordinates. Perform projection into view volume or screen coordinates. Clip geometry outside the view volume. Remove hidden surfaces
2D viewing The Clipping Window The Viewport
right, top Clipping y Clipping window left, bottom? x A screen
Viewport Transform
Viewport Transform y Clipping window right, top y x left, bottom x y The Viewport The glut Window A screen x
What will happen? y Clipping window right, top y x left, bottom x y The Viewport The glut Window A screen x
right, top Implement Zooming? y Clipping window left, bottom The Viewport right, top x left, bottom
OpenGL Defining the Clipping Window glortho(left, right, bottom, top, -1, 1) gluortho2d(left, right, bottom, top) Defining the Viewport glviewport(x, y, width, height) In Camera Coordinates In Window Coordinates
The 3D viewing pipeline
Before the virtual camera.. The 2D clipping window => The 3D clipping volume
Orthographic view volume (Ken Power 2011)
Orthographic projection
Defining an orthographic view volume glortho(left, right, bottom, top, near, far) VC NDC
Multiview Orthographic Projection Projection plane parallel to principal face Usually form front, top, side views isometric front in CAD and architecture, we often display three multiviews plus isometric top side (2005 Angel)
Advantages and Disadvantages Preserves both distances and angles Shapes preserved Can be used for measurements Building plans Manuals Cannot see what object really looks like because many surfaces hidden from view Often we add the isometric
Oblique Projection Arbitrary relationship between projectors and projection plane (2005 Angel)
Perspective projection
Perspective projection (Ken Power 2011)
Perspective view volume Also a 3D clipping volume called frustum (2013 Steve Marschner)
Defining perspective viewing frustum glfrustum(left, right, bottom, top, near, far) VC NDC
Defining perspective viewing frustum gluperspective(fov, aspect, near far)
Perspective projection
Vanishing Points Parallel lines (not parallel to the projection plan) on the object converge at a single point in the projection (the vanishing point) Drawing simple perspectives by hand uses these vanishing point(s) vanishing point (2005 Angel)
Advantages and Disadvantages Objects further from viewer are projected smaller than the same sized objects closer to the viewer (diminution) Looks realistic Equal distances along a line are not projected into equal distances (nonuniform foreshortening) Angles preserved only in planes parallel to the projection plane More difficult to construct by hand than parallel projections (but not more difficult by computer)
Finally the camera the position of camera The default camera is located at origin and points in the negative z direction the type of lens and the position of the film OpenGL also specifies a default view volume that is a cube with sides of length 2 centered at the origin Orthogonal
Moving the camera default frames frames after translation by d d > 0 (2005 Angel)
glulookat gllookat(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz) (2005 Angel)
References Ed Angel, CS/EECE 433 Computer Graphics, University of New Mexico Steve Marschner, CS4620/5620 Computer Graphics, Cornell Tom Thorne, COMPUTER GRAPHICS, The University of Edinburgh Elif Tosun, Computer Graphics, The University of New York Lin Zhang, Computer Graphics, Tongji Unviersity
Questions?