4703 SAYILI ÜRÜNLERE İLİŞKİN TEKNİK MEVZUATIN HAZIRLANMASI VE UYGULANMASINA DAİR KANUN
CAP 4703 Computer Graphic Methods
description
Transcript of CAP 4703 Computer Graphic Methods
CAP 4703CAP 4703Computer Graphic Computer Graphic
MethodsMethodsProf. Roy LevowProf. Roy Levow
Chapter 5Chapter 5
ViewingViewing Classical viewingClassical viewing
– Need to be able to reproduce classical Need to be able to reproduce classical views for a variety of applicationsviews for a variety of applications
– IsometricIsometricPreserves measurementsPreserves measurements
– ElevationElevationView a face of objectView a face of object
– PerspectivePerspectiveReflects size change of distant objectsReflects size change of distant objects
Viewing TerminologyViewing Terminology Center of Projection (COP)Center of Projection (COP)
– Point where all projectors meetPoint where all projectors meet– Center of camera or eye lensCenter of camera or eye lens– Origin of synthetic camera frameOrigin of synthetic camera frame
Direction of Projection (DOP)Direction of Projection (DOP)– Direction of projectors when COP is Direction of projectors when COP is
moved to infinitymoved to infinity
Types of ViewingTypes of Viewing Classical (many)Classical (many)
– OrthographicOrthographic– One-, two-, and 3-point perspectivesOne-, two-, and 3-point perspectives
ComputerComputer– OrthographicOrthographic– PerspectivePerspective
Classical Viewing ConceptsClassical Viewing Concepts Principal facePrincipal face
– Primary surface of viewPrimary surface of viewBased on rectangular solid structuresBased on rectangular solid structures
Orthographic ProjectionOrthographic Projection– Single viewSingle view– MultiviewMultiview
Show three orthogonal viewsShow three orthogonal views
Axonometric ProjectionsAxonometric Projections Projectors are orthogonal to the Projectors are orthogonal to the
projection plane but plane can be at projection plane but plane can be at angle to principal faceangle to principal face– Isometric – symmetric with all three Isometric – symmetric with all three
axesaxes– Dimetric – symmetric with two axesDimetric – symmetric with two axes– Trimetric – general caseTrimetric – general case– Produces foreshortening of distancesProduces foreshortening of distances
Oblique ProjectionOblique Projection Most general parallel viewMost general parallel view
– Projectors make arbitrary angle with Projectors make arbitrary angle with projection planeprojection plane
In computer graphics system, In computer graphics system, isometric, axonometric and oblique isometric, axonometric and oblique projections are all variations on one projections are all variations on one casecase
PerspectivePerspective Characterized by diminution of size Characterized by diminution of size
of more distant objectsof more distant objects Classically, viewer is symmetrical Classically, viewer is symmetrical
with respect to the projection planewith respect to the projection plane One-, two-, and three-point One-, two-, and three-point
perspectives depending on number perspectives depending on number of vanishing pointsof vanishing points
Computer ViewingComputer Viewing Choose parallel or perspective viewChoose parallel or perspective view No separation of perspective degreesNo separation of perspective degrees
Two key elementsTwo key elements– Position cameraPosition camera– Apply projection transformatonApply projection transformaton
OpenGL CameraOpenGL Camera DefaultDefault
– Camera at originCamera at origin– Pointing in negative z directionPointing in negative z direction– Orthogonal viewOrthogonal view– Viewing volume is cubeViewing volume is cube
Centered at originCentered at originSide of length 2Side of length 2
Default CameraDefault Camera
Positioning Camera FramePositioning Camera Frame Can construct camera frame through Can construct camera frame through
translation and rotation of model translation and rotation of model view to get camera to desired view to get camera to desired viewing position from default positionviewing position from default position
For orthographic view, this does not For orthographic view, this does not change clipping volume set by change clipping volume set by glOrtho()glOrtho()– Size is unchangedSize is unchanged– What is seen will changeWhat is seen will change
View as Change of FramesView as Change of Frames Set View-Reference Point (VRP)Set View-Reference Point (VRP)
– Center of cameraCenter of camera View plane defined byView plane defined by
– View-plane normal (VPN)View-plane normal (VPN)– View-up vector (VUP)View-up vector (VUP)– Project VUP onto projection plane to get Project VUP onto projection plane to get
up direction (vup direction (vupup)) Construct new frame with basis for Construct new frame with basis for
view plane, u-v and normal n; u-v-nview plane, u-v and normal n; u-v-n
Look-At PositioningLook-At Positioning
OpenGL Look-AtOpenGL Look-At OpenGL simplifies camera positioning as OpenGL simplifies camera positioning as
followsfollows– e = eye pointe = eye point– a = look-at pointa = look-at point– Determines vpn as e – aDetermines vpn as e – a
glMatrixMode(GL_MODELVIEW);glMatrixMode(GL_MODELVIEW); glLoadIdentity();glLoadIdentity(); gluLookAt(eyex, eyey, eyez, gluLookAt(eyex, eyey, eyez,
atx, aty, atz, upx, upy, upz);atx, aty, atz, upx, upy, upz);/* define objects here *//* define objects here */
Perspective ProjectionPerspective Projection
Note: x/z = xNote: x/z = xpp/d or x/d or xpp= x/(z/d)= x/(z/d)– Similarly for ySimilarly for y– Provides non-uniform foreshorteningProvides non-uniform foreshortening
Perspective TransformationPerspective Transformation– (x, y, z) -> (x(x, y, z) -> (xpp, y, ypp, z, zpp) )
Perspective Projection (cont)Perspective Projection (cont) Moving to 4 dimensions, considerMoving to 4 dimensions, consider
(wx, wy, wz, w)(wx, wy, wz, w)TT Perspective transformation matrixPerspective transformation matrix
11 0 0 00 0 0 takestakes0 1 0 00 1 0 0 (x, y, z, 1) (x, y, z, 1) TT
0 0 1 0 0 0 1 0 toto0 0 1/d 00 0 1/d 0 (x, y, z, z/d) (x, y, z, z/d) TT
Division by last coordinate givesDivision by last coordinate gives (x(xpp, y, ypp, d, 1), the projection, d, 1), the projection
Orthogonal Projection in Orthogonal Projection in OpenGLOpenGL
Simply map z into zeroSimply map z into zero
Projection in OpenGLProjection in OpenGL Clipping region is a frustum, a Clipping region is a frustum, a
truncated pyramidtruncated pyramid
OpenGL FrustumOpenGL Frustum glFrustum(xmin, xmax, ymin, ymax,glFrustum(xmin, xmax, ymin, ymax,
near, far);near, far);// left, right, top, bottom, near, far// left, right, top, bottom, near, far
Parallel Viewing in OpenGLParallel Viewing in OpenGL glOrtho(xmin, xmax, ymin, ymax,glOrtho(xmin, xmax, ymin, ymax,
near, far);near, far);
Hidden Surface RemovalHidden Surface Removal Remove hidden surfacesRemove hidden surfaces Different viewDifferent view
– Visible-surface algoritimsVisible-surface algoritims Identify visible surfacesIdentify visible surfaces
Work in eitherWork in either– Object spaceObject space– Image spaceImage space
Z-Buffer AlgorithmZ-Buffer Algorithm Image SpaceImage Space Requires depth buffer, called z-buffer to Requires depth buffer, called z-buffer to
store depthstore depth Depth resolution usually 16, 24, or 32 bitsDepth resolution usually 16, 24, or 32 bits As polygon is rasterized, depth is As polygon is rasterized, depth is
computed and compared with current z-computed and compared with current z-buffer value; only nearer values updatebuffer value; only nearer values update
Very efficientVery efficient
OpenGL ImplementationOpenGL Implementation Enable withEnable with
– glutInitDisplayMode(GLUT_DEPTH…);glutInitDisplayMode(GLUT_DEPTH…);– glEnabel(GL_DEPTH_TEST);glEnabel(GL_DEPTH_TEST);
Clear withClear with– glClear(GL_DEPTH_BUFFER_BIT);glClear(GL_DEPTH_BUFFER_BIT);
Scene WalkthroughScene Walkthrough Move camera to view color cube from Move camera to view color cube from
different locationsdifferent locations– cubeview.ccubeview.c
Parallel-Projection MatricesParallel-Projection Matrices Previous projection matrices do not Previous projection matrices do not
cover all possibilitiescover all possibilities Projection NormalizationProjection Normalization
– convert all projections to orthogonalconvert all projections to orthogonal– by distorting objectsby distorting objects– distortion is called normalizationdistortion is called normalization
Map viewing volume into 2x2x2 cube Map viewing volume into 2x2x2 cube at origin; translate and then scaleat origin; translate and then scale
Oblique ProjectionOblique Projection Projectors do not need to be Projectors do not need to be
orthogonal to projection plane as in orthogonal to projection plane as in standard OpenGL projectionstandard OpenGL projection
Equivalent to a shear transformation Equivalent to a shear transformation of the objectsof the objects
Perspective-Projection MatricesPerspective-Projection Matrices Again, distort objectAgain, distort object Skipping detailsSkipping details OpenGL Perspective TransformationsOpenGL Perspective Transformations
2z/(X-x) 0 (X+x)/(X-x) 02z/(X-x) 0 (X+x)/(X-x) 0 0 2z/(Y-y) (Y+y)/(Y-y) 00 2z/(Y-y) (Y+y)/(Y-y) 0
0 0 -(f+n)/(f-n) -2fn/(f-n)0 0 -(f+n)/(f-n) -2fn/(f-n) 0 0 -1 00 0 -1 0
Projections and ShadowsProjections and Shadows ShadowShadow
– projection of original polygon onto projection of original polygon onto surfacesurface
– center of projection center of projection is light sourceis light source
– shadow-polygonshadow-polygon– shadow.cshadow.c