chapters 5
DESCRIPTION
Chapters 5. 2 March 2004. Classical & Computer Viewing. Same elements objects viewer projectors projection plane. Classical and Computer Viewing. Perspective views fixed Center of Projection (COP) Parallel Views COP at infinity. Viewing in OpenGL. Perspective Parallel - Orthogonal. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/1.jpg)
Chapters 5Chapters 5
2 March 2004
![Page 2: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/2.jpg)
Classical & Computer ViewingClassical & Computer Viewing
• Same elements– objects– viewer– projectors– projection plane
![Page 3: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/3.jpg)
Classical and Computer ViewingClassical and Computer Viewing
• Perspective views– fixed Center of Projection (COP)
• Parallel Views– COP at infinity
![Page 4: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/4.jpg)
Viewing in OpenGLViewing in OpenGL
• Perspective
• Parallel - Orthogonal
![Page 5: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/5.jpg)
Perspective viewingPerspective viewing
glMatrixMode(GL_PROJECTION);
gluPerspective(40.0, 1.0, 1.0, 40.0);
// field of view, aspect ratio, z near, z far
// 0-180 w/h + +
glMatrixMode(GL_MODELVIEW);
gluLookat(0.0, 0.0, 30.0, /* eye */
0.0, 0.0, 0.0, /* center */
0.0, 1.0, 0.0); /* up */
![Page 6: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/6.jpg)
Camera Analogy and TransformationsCamera Analogy and Transformations
• Projection transformations– adjust the lens of the camera
• Viewing transformations– tripod–define position and orientation of the
viewing volume in the world
• Modeling transformations– moving the model
• Viewport transformations– enlarge or reduce the physical photograph
![Page 7: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/7.jpg)
Coordinate Systems and TransformationsCoordinate Systems and Transformations
• Steps in Forming an Image– specify geometry (world coordinates)– specify camera (camera coordinates)– project (window coordinates)– map to viewport (screen coordinates)
• Each step uses transformations• Every transformation is equivalent to a
change in coordinate systems (frames)
![Page 8: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/8.jpg)
Affine TransformationsAffine Transformations
• Want transformations which preserve geometry– lines, polygons, quadrics
• Affine = line preserving– Rotation, translation, scaling– Projection– Concatenation (composition)
![Page 9: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/9.jpg)
Specifying TransformationsSpecifying Transformations
• Programmer has two styles of specifying transformations– specify matrices (glLoadMatrix, glLoadMatrix, glMultMatrixglMultMatrix)
– specify operation (glRotate, glOrthoglRotate, glOrtho)
• Programmer does not have to remember the exact matrices
![Page 10: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/10.jpg)
Programming TransformationsProgramming Transformations
• Prior to rendering, view, locate, and orient:– eye/camera position– 3D geometry
• Manage the matrices– including matrix stack
• Combine (composite) transformations
![Page 11: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/11.jpg)
vertex
ModelviewMatrix
ProjectionMatrix
PerspectiveDivision
ViewportTransform
Modelview
Modelview
Projection
object eye
clip normalizeddevice
window
• other calculations here– material color– shade model (flat)– polygon rendering mode– polygon culling– clipping
Transformation PipelineTransformation PipelineCPUCPU
DLDL
Poly.Poly. Per
Vertex
PerVertex
RasterRaster
FragFrag
FBFB
PixelPixel
TextureTexture
![Page 12: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/12.jpg)
Applying Projection TransformationsApplying Projection Transformations
• Typical use (orthographic projection)glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( left, right, bottom, top, zNear, zFar );
• Typical use (orthographic projection)glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( left, right, bottom, top, zNear, zFar );
![Page 13: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/13.jpg)
Viewing TransformationsViewing Transformations
• Position the camera/eye in the scene– place the tripod down; aim camera
• To “fly through” a scene– change viewing transformation and
redraw scene
• gluLookAt( eyex, eyey, eyez, aimx, aimy, aimz, upx, upy, upz )
– up vector determines unique orientation– careful of degenerate positions
tripod
![Page 14: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/14.jpg)
Projection TutorialProjection Tutorial
![Page 15: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/15.jpg)
Transformation TutorialTransformation Tutorial
![Page 16: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/16.jpg)
Connection: Viewing and ModelingConnection: Viewing and Modeling
• Moving camera is equivalent to moving every object in the world towards a stationary camera
• Viewing transformations are equivalent to several modeling transformationsgluLookAt() has its own command
can make your own polar view or pilot view
![Page 17: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/17.jpg)
Projection is left handedProjection is left handed
• Projection transformations (gluPerspective, glOrtho) are left handed– think of zNear and zFar as distance from
view point
• Everything else is right handed, including the vertexes to be rendered
xx
yy
z+
z+
left handed right handed
![Page 18: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/18.jpg)
18
resize()resize(): Perspective & Translate: Perspective & Translate
• Same effect as previous LookAtvoid resize( int w, int h ){ glViewport( 0, 0, (GLsizei) w, (GLsizei) h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 65.0, (GLfloat) w/h, 1.0, 100.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -5.0 );}
• Same effect as previous LookAtvoid resize( int w, int h ){ glViewport( 0, 0, (GLsizei) w, (GLsizei) h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 65.0, (GLfloat) w/h, 1.0, 100.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -5.0 );}
![Page 19: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/19.jpg)
Hidden Surface RemovalHidden Surface Removal
• Modeling a cube– what causes only the 3 front facing sides to be
visible?• Hidden surface removal algorithms
– object space algorithms
– image space algorithms
» z buffer algorithm (requires DEPTH buffer and the GL_DEPTH_TEST to be enabled)
![Page 20: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/20.jpg)
Hidden Surface RemovalHidden Surface Removal
• Optimize the process by rendering only front facing polygons
• glEnable(GL_CULL_FACE)– what is a front facing polygon?
• One with its normal facing the viewer
![Page 21: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/21.jpg)
HomeworkHomework
• Begin Presentation.– No class Thursday. Go to the library or online.
Browse Computer Graphics articles. Find a topic that interests you. You will need to cite a minimum of two sources for your 10 minute presentation.
– Computer Graphics Quarterly - SIGGRAPH– Computer Graphics World
![Page 22: Chapters 5](https://reader035.vdocument.in/reader035/viewer/2022062309/56814f7f550346895dbd31cc/html5/thumbnails/22.jpg)
Program 2 due 3/18Program 2 due 3/18
• Logic…