计算机图形学computergraph

上传人:鲁** 文档编号:584476410 上传时间:2024-08-31 格式:PPT 页数:59 大小:2.09MB
返回 下载 相关 举报
计算机图形学computergraph_第1页
第1页 / 共59页
计算机图形学computergraph_第2页
第2页 / 共59页
计算机图形学computergraph_第3页
第3页 / 共59页
计算机图形学computergraph_第4页
第4页 / 共59页
计算机图形学computergraph_第5页
第5页 / 共59页
点击查看更多>>
资源描述

《计算机图形学computergraph》由会员分享,可在线阅读,更多相关《计算机图形学computergraph(59页珍藏版)》请在金锄头文库上搜索。

1、1ViewShandong University Software CollegeInstructor: Zhou Yuanfeng2ObjectivesIntroduce the classical viewsCompare and contrast image formation by computer with how images have been formed by architects, artists, and engineersLearn the benefits and drawbacks of each type of viewIntroduce the mathemat

2、ics of projectionIntroduce OpenGL viewing functionsLook at alternate viewing APIsView3We call the pictures for observing objects with different ways are views.View results are related with the shape and size of scene objects, the position and direction of viewpoint.4Classical ViewingViewing requires

3、 three basic elementsOne or more objectsA viewer with a projection surfaceProjectors that go from the object(s) to the projection surfaceClassical views are based on the relationship among these elementsThe viewer picks up the object and orients it how she would like to see itEach object is assumed

4、to constructed from flat principal facesBuildings, polyhedra, manufactured objects5Planar Geometric ProjectionsStandard projections project onto a planeProjectors are lines that eitherconverge at a center of projectionare parallelSuch projections preserve linesbut not necessarily anglesNonplanar pro

5、jections are needed for applications such as map construction63D space2D imageProjectionZXpYpWindow Window coordinatecoordinateScreen coordinate systemScreen coordinate systemWorld coordinate systemWorld coordinate systemViewportViewportWindowWindowFar planeNear planeViewpointImage planeViewing Volu

6、meViewing Volume7Classical Projections8Perspective vs ParallelComputer graphics treats all projections the same and implements them with a single pipelineClassical viewing developed different techniques for drawing each type of projectionFundamental distinction is between parallel and perspective vi

7、ewing even though mathematically parallel viewing is the limit of perspective viewing9Taxonomy of Planar Geometric ProjectionsparallelperspectiveAxonometric multivieworthographicobliqueIsometricDimetric trimetric2 point1 point3 pointplanar geometric projections10Perspective Projection11Parallel Proj

8、ection12Orthographic ProjectionProjectors are orthogonal to projection surfaceArguably the simplest projectiono Image plane is perpendicular to one of the coordinate axes;o Project onto plane by dropping that coordinate; o All rays are parallel.13Multiview Orthographic ProjectionProjection plane par

9、allel to principal faceUsually form front, top, side viewsisometric (not multivieworthographic view)frontsidetopin CAD and architecture, we often display three multiviews plus isometric 14Advantages and DisadvantagesPreserves both distances and anglesShapes preservedCan be used for measurementsBuild

10、ing plansManualsCannot see what object really looks like because many surfaces hidden from viewOften we add the isometric15Axonometric ProjectionsAllow projection plane to move relative to objectclassify by how many angles ofa corner of a projected cube are the samenone: trimetrictwo: dimetricthree:

11、 isometricq 1q 3q 216Types of Axonometric Projections17Advantages and DisadvantagesLines are scaled (foreshortened) but can find scaling factorsLines preserved but angles are notProjection of a circle in a plane not parallel to the projection plane is an ellipseCan see three principal faces of a box

12、like objectSome optical illusions possibleParallel lines appear to divergeDoes not look real because far objects are scaled the same as near objectsUsed in CAD applications18Oblique Projection Arbitrary relationship between projectors and projection plane19Advantages and DisadvantagesCan pick the an

13、gles to emphasize a particular faceArchitecture: plan oblique, elevation obliqueAngles in faces parallel to projection plane are preserved while we can still see “around” sideIn physical world, cannot create with simple camera; possible with bellows camera(波纹管相机) or special lens (architectural)20Per

14、spective ProjectionProjectors converge at center of projectionNaturally we see things in perspectiveo Objects appear smaller the farther away they are;o Rays from view point are not parallel.21Vanishing PointsParallel lines (not parallel to the projection plan) on the object converge at a single poi

15、nt in the projection (the vanishing point) Drawing simple perspectives by hand uses these vanishing point(s)vanishing point22Three-Point PerspectiveNo principal face parallel to projection planeThree vanishing points for cube23Two-Point PerspectiveOn principal direction parallel to projection planeT

16、wo vanishing points for cube24One-Point Perspective One principal face parallel to projection planeOne vanishing point for cube25Advantages and DisadvantagesObjects further from viewer are projected smaller than the same sized objects closer to the viewer (diminution)Looks realisticEqual distances a

17、long a line are not projected into equal distances (nonuniform foreshortening)Angles preserved only in planes parallel to the projection planeMore difficult to construct by hand than parallel projections (but not more difficult by computer)26Computer ViewingThere are three aspects of the viewing pro

18、cess, all of which are implemented in the pipeline,Positioning the cameraSetting the modelview matrixSelecting a lensSetting the projection matrixClippingSetting the view volume27The OpenGL CameraIn OpenGL, initially the object and camera frames are the sameDefault modelview matrix is an identityThe

19、 camera is located at origin and points in the negative z directionOpenGL also specifies a default view volume that is a cube with sides of length 2 centered at the originDefault projection matrix is an identity28OpenGL codeRemember that last transformation specified is first to be appliedglMatrixMo

20、de(GL_MODELVIEW)glLoadIdentity();glTranslatef(0.0, 0.0, -d);glRotatef(-90.0, 0.0, 1.0, 0.0);29Default ProjectionDefault projection is orthogonalclipped out230Moving the Camera FrameIf we want to visualize object with both positive and negative z values we can eitherMove the camera in the positive z

21、directionTranslate the camera frameMove the objects in the negative z directionTranslate the world frameBoth of these views are equivalent and are determined by the modelview matrix Want a translation (glTranslatef(0.0,0.0,-d);) d 031Moving Camera back from Origin default framesframes after translat

22、ion by d d 0glTranslatef(0.0,0.0,-d);32Moving the CameraWe can move the camera to any desired position by a sequence of rotations and translationsExample: side viewRotate the cameraMove it away from originModelview matrix C = TRglTranslatef(0.0, 0.0, -d);glRotatef(-90.0, 0.0, 1.0, 0.0); Important!33

23、The LookAt FunctionThe GLU library contains the function gluLookAt to form the required modelview matrix through a simple interfaceNote the need for setting an up directionStill need to initialize Can concatenate with modeling transformationsExample: isometric view of cube aligned with axesglMatrixM

24、ode(GL_MODELVIEW):glLoadIdentity();gluLookAt(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0., 1.0. 0.0);34gluLookAtglLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)35Other Viewing APIsThe LookAt function is only one possible API for positioning the cameraOthers includeView reference point, view plane normal

25、, view up (PHIGS, GKS3D)Yaw偏转, pitch倾斜, roll侧滚Elevation, azimuth, twist(仰角、方位角、扭转角)Direction angles36Yaw, pitch, roll侧滚倾斜偏转37PHIGS, GKS-3DVPN & VUPVPN: Normal of projection faceOne direction cannot decide the cameraCamera can rotate around the VPN;+ VUP can decide the camera frame38VUPCan not be par

26、allel with Projection face.Project VUP to view plane get v.3940方位角仰角41OpenGL Orthogonal Viewing void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);near and far measured from camera42OpenGL Perspective void glFrustum(GLdouble left,GLdouble Right,GL

27、double bottom,GLdouble top,GLdouble near,GLdouble far); 43Using Field of ViewWith glFrustum it is often difficult to get the desired viewvoid gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); often provides a better interfaceaspect = w/hProjection Matrix44Connecting We g

28、et line:Combining with image plane equationSolving equationsProjection Matrix45We can getSimilarlySubstitute one point of 3D object into above, we can get the projection point on plane fromProjection Matrix46Homogeneous coordinate expression: 47NormalizationRather than derive a different projection

29、matrix for each type of projection, we can convert all projections to orthogonal projections with the default view volumeThis strategy allows us to use standard transformations in the pipeline and makes for efficient clipping48Pipeline View modelviewtransformation projectiontransformationperspective

30、 divisionclippingprojectionnonsingular4D 3Dagainst default cube3D 2D49Orthogonal NormalizationglOrtho(left,right,bottom,top,near,far)normalization find transformation to convertspecified clipping volume to default50Orthogonal MatrixTwo stepsMove center to originT(-(left+right)/2, -(bottom+top)/2,(ne

31、ar+far)/2)Scale to have sides of length 2S(2/(left-right),2/(top-bottom),2/(near-far)P = ST =51Final ProjectionSet z =0 Equivalent to the homogeneous coordinate transformationHence, general orthogonal projection in 4D isMorth = P = MorthST52Simple PerspectiveConsider a simple perspective with the CO

32、P at the origin, the near clipping plane at z = 1, and a 90 degree field of view determined by the planes x = z, y = z53Perspective MatricesSimple projection matrix in homogeneous coordinatesNote that this matrix is independent of the far clipping planeM =54GeneralizationN =after perspective divisio

33、n, the point (x, y, z, 1) goes tox = x/zy = y/zz = -(a+b/z)which projects orthogonally to the desired point regardless of a and b55Picking a a and b bIf we picka = b = the near plane is mapped to z = -1the far plane is mapped to z =1and the sides are mapped to x = 1, y = 1Hence the new clipping volu

34、me is the default clipping volume56Normalization Transformationoriginal clipping volumeoriginal objectnew clipping volumedistorted objectprojects correctlyProjection Matrix57Summary58Perspective Projection and Parallel ProjectionParallel projection orthographics projectionqInfinite viewpointqProject

35、ion rays are parallelqProjection has the same size of original objectqApplications: architecture, computer aided design, etcPerspective projectionqFinite viewpointqConverging projection point: center of projectionqObjects appear smaller the father away they areqApplications: animation, visual simulation, etc59DemoglViewport(0,0,Width,Height); glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective( 45.0f, (GLfloat)Width/(GLfloat)Height, 0.1f, 3000.0f);

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 资格认证/考试 > 自考

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号