《计算机图形学》总复习.ppt_第1页
《计算机图形学》总复习.ppt_第2页
《计算机图形学》总复习.ppt_第3页
《计算机图形学》总复习.ppt_第4页
《计算机图形学》总复习.ppt_第5页
已阅读5页,还剩111页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

计算机图形学总复习,ComputerGraphics,Ch1.asurveyofCS,ComputerGraphics,3,GraphicsConcept,Innarrowsense位图(bitmap)-图像Image,矢量图(vectorgraph)GraphicIngeneral,graphicscanbeanyobjectwhichisabletogivevisionimpressioninmansvisionsystem.Itincludevariousgeometrygraphics,views,pictures,patterns,andimages.,4,凡是能够在人的视觉系统中形成视觉印象的客观对象都称为图形。(1)自然景物(2)照片和图片(3)工程图、设计图和方框图(4)人工美术绘画、雕塑品(5)用数学方法描述的图形(包括几何图形、代数方程、分析表达式或列表所确定的图形),什么是图形?,5,Vectorgraphandbitmap,(1).vectorgraph,Anycurvesareapproachedwithmanyshortlines,(2).bitmap,Everycurvemustbeconsistofseveralpixels,6,几何要素:刻画对象的轮廓、形状等(几何模型)非几何要素:刻画对象的颜色、材质等(物理属性),计算机图形学中的图形要素,7,WhatisComputerGraphics?,Thetechnologyforgeneratingtheimagesonthecomputerscreenwithalgorithmsandprogramsiscalledthecomputergraphics.计算机图形学(ComputerGraphics,CG)是研究怎样用数字计算机生成、处理和显示图形的一门学科。,8,Relationshipwithothersubjects,数字图像DigitalImages,数据模型DataModels,研究内容(学科),9,ComputerGraphicsApplications,图形用户界面(GUI)计算机辅助设计与制造(CAD/CAM)娱乐游戏及计算机动画(entertainment/game/animation)计算机艺术(computerart)地理信息系统(GIS)科学技术与信息可视化(Visualization)虚拟现实(VirtualReality)图形用户界面(GUI),10,ResearchHotspot,真实感显示RealisticDisplay变形技术MorphingTechnology数字城市DigitalCity识别技术RecognizeTechnology基于图像的建模ImageBasedModeling自然对象的建模NatureObjectsModeling离散数据建模DiscreteDataModeling网络漫游Web3D,11,CRT(CathodeRayTube),Thebeamemitselectrons(cathode).Rayintensityiscontrolledbythegrid.Thefocusforcestheelectronstowardsaconvergencepath.Deflectorsforcetheraytopointataspecificscreenpoint.Theraystunsoverthephosphor.Phosphoremitslights.Phosphoremissiondeclinesveryfast(refreshmentrequired),Figure2-4ElectrostaticdeflectionoftheelectronbeaminaCRT,12,13,14,当前研究动态,(1)造型技术规则形体:欧氏几何方法不规则形体:分形几何方法、粒子系统、纹理映射实体造型基于物理的造型基于图像的造型,15,当前研究动态,(2)真实感图形绘制技术光照明模型绘制算法快速算法基于图像的绘制(非真实感图形绘制技术),16,当前研究动态,(3)人机交互技术(4)与计算机网络技术的紧密结合远程医疗与诊断远程导航与维修远程教育,17,研究热点,ModelinggettingmodelsfromtherealworldAnimationphysicallybasedmodelingmotioncaptureRenderingmorerealistic:image-basedrenderinglessrealistic:impressionist,penglutInitDisplayMode(mode);glutInitWindowSize(500,500);glutCreateWindow(“Simple”);init();glutDisplayFunc(display);glutKeyboardFunc(key);glutMainLoop();,23,OpenGLInitialization,SetupwhateverstateyouregoingtouseDontneedthismuchdetailunlessworkingin3Dvoidinit(void)glClearColor(0.0,0.0,0.0,0.0);glViewport(0,0,width,height);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(-10,10,-10,10,-10,20);glMatrixMode(GL_MODELVIEW);glLoadIdentity();glEnable(GL_LIGHT0);glEnable(GL_LIGHTING);glEnable(GL_DEPTH_TEST);,24,GLUTCallbackfunctions,Event-driven:ProgramsthatusewindowsInput/OutputWaituntilaneventhappensandthenexecutesomepre-definedfunctionsaccordingtotheusersinputEventskeypress,mousebuttonpressandrelease,windowresize,etc.YourOpenGLprogramwillbeininfiniteloop,25,GLUTCallbackFunctions,Callbackfunction:RoutinetocallwhenaneventhappensWindowresizeorredrawUserinput(mouse,keyboard)Animation(rendermanyframes)“Register”callbackswithGLUTglutDisplayFunc(my_display_func);glutIdleFunc(my_idle_func);glutKeyboardFunc(my_key_events_func);glutMouseFunc(my_mouse_events_func);,26,EventQueue,MainLoop(),27,RenderingCallback,CallbackfunctionwhereallourdrawingisdoneEveryGLUTprogrammusthaveadisplaycallbackglutDisplayFunc(my_display_func);/*thispartisinmain.c*/voidmy_display_func(void)glClear(GL_COLOR_BUFFER_BIT);glBegin(GL_TRIANGLE);glVertex3fv(v0);glVertex3fv(v1);glVertex3fv(v2);glEnd();glFlush();,28,IdleCallback,UseforanimationandcontinuousupdateCanuseglutTimerFuncortimedcallbacksforanimationsglutIdleFunc(idle);voididle(void)/*changesomething*/t+=dt;glutPostRedisplay();,29,UserInputCallbacks,ProcessuserinputglutKeyboardFunc(my_key_events);voidmy_key_events(charkey,intx,inty)switch(key)caseq:caseQ:exit(EXIT_SUCCESS);break;caser:caseR:rotate=GL_TRUE;break;,30,MouseCallback,CapturesmousepressandreleaseeventsglutMouseFunc(my_mouse);voidmyMouse(intbutton,intstate,intx,inty)if(button=GLUT_LEFT_BUTTONglColor3fv(color);glVertex2f(0.0,0.0);glVertex2f(1.0,0.0);glVertex2f(1.5,1.118);glVertex2f(0.5,1.118);glEnd();,Ch3.GeometricPrimitives几何图元绘制,ComputerGraphics,34,Whatisrastering?,Therasterdisplaytechnologyrequirestobrakedowngraphicprimitivesintopixelswithintheraster.Thisprocessiscalledrastering(栅格化).scanconversion(扫描转换),Thisisusuallydonebythegraphicshardware.However,itisusefultounderstandhowthisprocessworksinordertobeabletoachievegoodgraphicsperformance.,35,扫描转换,将图形数字化为一组像素强度值,并存放在帧缓存中。这个数字化过程称为扫描转换(scanconversion)基本图元的扫描转换就是计算出落在基本图元上或充分靠近它的一串像素,并以此像素近似替代基本图元上对应位置在屏幕上显示的过程。,36,Line-DrawingAlgorithms,1)DDAalgorithm2)Bresenhamalgorithm,37,DDAalgorithm(p94),Thedigitaldifferentialanalyzer(DDA,数字微分分析法)isascan-conversionlinealgorithmbasedoncalculatingdifferencesbasedontheslopeoftheline.,38,DDAalgorithm,Alinecanbedescribedbytheequationy=mx+bWithoutlossofgenerality,wecanassume0m1.Otherwisewecanmirrororinterchangethecoordinatesasneeded.Now,weneedtocomputetheseriesofpoints(xk,yk),k=0,nthatbestdescribestheline.,39,DDAalgorithm,Since0mfabs(dy)steps=fabs(dx);elsesteps=abs(dy);xIncrement=(float)(dx)/steps;yIncrement=(float)(dy)/steps;For(k=0;k1,swapthecoordinatesaxes.,42,42,AdvantageandDisadvantageforDDA,Advantage优点:-消除乘法.Disadvantage缺点:-浮点数相加积累误差,对长线段而言,引起像素点位置与理想位置的偏移.-需要圆整操作和浮点计算,消耗时间。,43,DDAalgorithm,TheDDAalgorithmeasilycanbeextendedtoothergraphicsprimitives,suchascircles,ellipses,etc.DDAisGood,butStillNotFastEnough!Floatingpointmultiplygonefromy=mx+bButloopstillhasafloatingpointaddAndaround()WECANDOBETTER!Bestperformance:Onlyintegeradds/subtractsinsideloopTheBresenhamalgorithmallowsustodojustthat.,44,Bresenhamalgorithm(p95),Again,weassumewithoutlossofgeneralitythattheslopeis0m1;hence,thelineislocatedinthefirstoctant.,Ideanomatterwhattheslopeis,weincreaseonecoordinatebyone(x-coordinate)similartotheDDAalgorithm.Theothercoordinate(y-coordinate)iseitherincreasedbyoneaswellorleftunchanged,dependingonthedistancetothenextgridpoint.,45,Bresenhamalgorithm,Inordertodecidewhichpointtopick,weintroduceanerrorEwhichisproportionaltothedifferencebetweentheexactpointonthestraightlineandthecenterbetweenthetwopossiblegridpointsontheraster.ThesignofEcanthenbeusedasacriterionforthedecision.,Eitherpoint1orpoint2isdrawn,dependingonwhichisclosertothestraightline.,46,Bresenhamalgorithm,47,Bresenhamalgorithm,IfwescaleEusingx,thenwecaneliminatem.,48,Bresenhamalgorithm,CanEkbecaculatedrecursively?Yes!,49,Bresenhamalgorithm,Note:ONLYintegeroperationsareused!,BresenhamAlgorithm/(x1,y1),(x2,y2),x1x2x=x1;y=y1;dx=x2-x1;dy=y2-y1;e=2*dy-dx;setPixel(x,y);while(xx2)x=x+1;if(e0)e=e+2*dy;elsee=e+2*dy-2*dx;y=y+1;setPixel(x,y);,50,Bresenhamalgorithm,dx=5,dy=4,2*dy=8,2*dy-2*dx=-2E0=2*dy-dx=3,if(e0)e=e+2*dy;elsee=e+2*dy-2*dx;y=y+1;,51,MidpointCircleAlgorithm(Hearnx=0;y=int(radius);h=1-int(radius);Set8Pixel(x0,y0,x,y);/CirclePlotPointswhile(xy)x+;if(h0)h+=2*x+1;elsey-;h+=2*(x-y)+1;Set8Pixel(x0,y0,x,y);,60,Circlesnotcenteredonorigin,NewSet8Pixel()Function:,Ch4.AttributesofGeometricPrimitives几何图元的属性,ComputerGraphics,1.AreaFillAlgorithms(区域填充算法),(HearnSection4-10/11/12/13,P196),63,Scan-linemethods(扫描线填充算法),WorksrowbyrowfromtoptobottomApixelinsidethecurrentscanlineisonlydrawnifitislocatedinsidethepolygon.,逐点判断法,Greedyapproachveryslow!,64,Coherence,EdgeCoherence(边的连贯性)某条边与当前扫描线相交,也可能与下一条扫描线相交Scan-lineCoherence(扫描线的连贯性)当前扫描线与各边的交点顺序与下一条扫描线与各边的交点顺序可能相同或类似SpanCoherence(区间的连贯性)同一区间上的像素取同一颜色属性,65,Scan-linemethods:Example,Example:Scanliney=2:-intersectionwithpolygonatx=1,8-wecansubdividethescanlineinto3sections:,66,Scan-linemethods:Example,Example:Scanliney=4:-intersectionwithpolygonatx=1,4,6,8-wecansubdividethescanlineinto5sections:,67,Scan-linemethods,Thesimpleorderededgelistalgorithm(有序边表算法)Method:preprocessing+scanconversion,68,OrderedEdgeListAlgorithm,Preprocessing(1)Determ

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论