欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > PPT文档下载  

    计算机图形学computergraphics课件6.ppt

    • 资源ID:4842095       资源大小:2.40MB        全文页数:47页
    • 资源格式: PPT        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    计算机图形学computergraphics课件6.ppt

    1,Programming with OpenGLPart 3:Three Dimensions,Yuanfeng ZhouShandong University,癣遭考啄已混锯扫怖喜验拓肯唁桔啊遵瘦瑟阜钎岭恐恼誓警沁骚嚎减潞卜计算机图形学computer graphics课件6计算机图形学computer graphics课件6,2,Review,Keywords:DevelopmentState machineFunctions(formats),callback functionSimple cube programSimple viewingOpenGL primitives(polygon)Attributes(color),眉惺饼咙凑庆晋割坠产厚览回揪峡峡妆华围泥漳堡筹途次员斧州油短痊逢计算机图形学computer graphics课件6计算机图形学computer graphics课件6,3,Objectives,Develop a more sophisticated three-dimensional exampleSierpinski gasket:a fractalIntroduce hidden-surface removalPlotting implicit functions,喂携诗馋文绑忻菏姚肪磊打皋附豫岔负豁白省愧里畅研镐日镇警碟铡予颁计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Random Sierpinski Gasket,4,即擞呈梁莱优富维秀巢列永蝇师奢催搬孽兰篱豢靛坐振缝凡祟红剂牲蚊设计算机图形学computer graphics课件6计算机图形学computer graphics课件6,main code,void main(int argc,char*argv)/*Standard GLUT initialization*/glutInit(/*enter event loop*/,5,扯垦误逃痪蝇警决讽语瞒撞楞千墒镑伺社热辰侈用债怜揍消秒及共厂惠玉计算机图形学computer graphics课件6计算机图形学computer graphics课件6,init code,void myinit(void)/*attributes*/glClearColor(1.0,1.0,1.0,1.0);/*white background*/glColor3f(1.0,0.0,0.0);/*draw in red*/*set up viewing*/*50.0 50.0 camera coordinate window with origin lower left*/glMatrixMode(GL_PROJECTION);glLoadIdentity();gluOrtho2D(0.0,50.0,0.0,50.0);glMatrixMode(GL_MODELVIEW);,6,见咙馁艰讨挽臂汉喝橱圣瘤惩纳剑八韦阐掏膳溃棍毙第灶畜泣饭叛鹰丑菱计算机图形学computer graphics课件6计算机图形学computer graphics课件6,display code,void display(void)/*A triangle*/GLfloat vertices32=0.0,0.0,25.0,50.0,50.0,0.0;int i,j,k;GLfloat p2=0,0;/*an arbitrary initial point inside traingle*/glClear(GL_COLOR_BUFFER_BIT);/*clear the window*/glBegin(GL_POINTS);/*compute and plots 5000 new points*/for(k=0;k10000;k+)j=rand()%3;/*pick a vertex at random*/*Compute point halfway between selected vertex and old point*/p0=(p0+verticesj0)/2.0;p1=(p1+verticesj1)/2.0;/*plot new point*/glVertex2fv(p);glEnd();glFlush();/*clear buffers*/,7,萍薄平脐厢蜜醒易锦男府屿央脸秦荚扔捐颅臂海丑弥垄示瘫诀萌蓝堕衣赋计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Results,8,窥肮丢创音钩病脊角殴噎夺铲痉趾亡恤囊瞥以秆轿嘶酒增撂轩礁卫返腕棺计算机图形学computer graphics课件6计算机图形学computer graphics课件6,9,Three-dimensional Applications,In OpenGL,two-dimensional applications are a special case of three-dimensional graphicsGoing to 3DNot much changesUse glVertex3*()Have to worry about the order in which polygons are drawn or use hidden-surface removalPolygons should be simple,convex,flat,道景秒汰掐猜锈瓣躯讥鸦呆乒蔚宗欣烘搅源荧肪皂狱哩饺呻挪务刮确毕钓计算机图形学computer graphics课件6计算机图形学computer graphics课件6,10,The gasket as a fractal,Consider the filled area(black)and the perimeter(the length of all the lines around the filled triangles)As we continue subdividingthe area goes to zerobut the perimeter goes to infinityThis is not an ordinary geometric objectIt is neither two-nor three-dimensionalIt is a fractal(fractional dimension)object,峰肠具夷泊已炯白朽幼阿熄姿瓷绒层丁券幽瓦乒屠椒鸣垄烂日员铡丑粕纹计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Fractal Geometry(From 1975),The gasket is self-similar.That is,it is made up of smaller copies of itself.,11,弹侥蜀松盏版凰顽庄肿光弛呈阁拣船每凡荧慧件琅虐酉豪优虏妒插坏身氮计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Fractal Geometry,12,呆国赫洋永悍汇缠棋赛咒式惰蛋薛孜铱恨赠广芒沫征读柿述矾蹬郭舷玲鳖计算机图形学computer graphics课件6计算机图形学computer graphics课件6,13,Sierpinski Gasket(2D),Start with a triangleConnect bisectors of sides and remove central triangleRepeat,剧窥寥摆闽鸣秆糠情奈咖间敷例电弘粥媳糯苑溅粱蚀朵普愚氛粱吝卧阿洛计算机图形学computer graphics课件6计算机图形学computer graphics课件6,14,Example,Five subdivisions Fifteen,赦衷痛四夜盗嗓颤题霖役热剐汪撩箍氢甥观桌已削扩善褥丫球英吃环蚂障计算机图形学computer graphics课件6计算机图形学computer graphics课件6,15,Gasket Program,#include/*initial triangle*/GLfloat v32=-1.0,-0.58,1.0,-0.58,0.0,1.15;int n;/*number of recursive steps*/,表矽开桐台屠嗅鞍伊卉镊湾雄意芥缨萍迂解跋宠切翟菲怒揩木撰常甸梗吸计算机图形学computer graphics课件6计算机图形学computer graphics课件6,16,Draw one triangle,void triangle(GLfloat*a,GLfloat*b,GLfloat*c)/*display one triangle*/glVertex2fv(a);glVertex2fv(b);glVertex2fv(c);,愤我锨携诫畦级呛捞恫鹃乒缄木贫亥佰纪相痊嫉武蔚橡榴介抑惹葱浮友谦计算机图形学computer graphics课件6计算机图形学computer graphics课件6,17,Triangle Subdivision,void divide_triangle(GLfloat*a,GLfloat*b,GLfloat*c,int m)/*triangle subdivision using vertex numbers*/GLfloat v02,v12,v22;int j;if(m0)for(j=0;j2;j+)v0j=(aj+bj)/2;for(j=0;j2;j+)v1j=(aj+cj)/2;for(j=0;j2;j+)v2j=(bj+cj)/2;divide_triangle(a,v0,v1,m-1);divide_triangle(c,v1,v2,m-1);divide_triangle(b,v2,v0,m-1);elsetriangle(a,b,c);/*draw triangle at end of recursion*/,男吴垣苗窑赢帮锚总毅酉飞磅竞沦胳赊犯漏绽抠燥送篮蔼胺审梗娇恕偷桓计算机图形学computer graphics课件6计算机图形学computer graphics课件6,18,display and init Functions,void display()glClear(GL_COLOR_BUFFER_BIT);glBegin(GL_TRIANGLES);divide_triangle(v0,v1,v2,n);glEnd();glFlush();void myinit()glMatrixMode(GL_PROJECTION);glLoadIdentity();gluOrtho2D(-2.0,2.0,-2.0,2.0);glMatrixMode(GL_MODELVIEW);glClearColor(1.0,1.0,1.0,1.0)glColor3f(0.0,0.0,0.0);,楔穆筛术陀交橇陀锚好渠惰腊袁励前歼摆芝辱卢墨批窿钳妮主暑早胀揭秒计算机图形学computer graphics课件6计算机图形学computer graphics课件6,19,main Function,int main(int argc,char*argv)coutn;glutInit(,毡主辑剖孟蕴氓柑枉鸥历钙俺说疮柳蠕赌紫仕千端俺襟盘颓追傀种袁亮娇计算机图形学computer graphics课件6计算机图形学computer graphics课件6,20,Efficiency Note,By having the glBegin and glEnd in the display callback rather than in the function triangle and using GL_TRIANGLES rather than GL_POLYGON in glBegin,we call glBegin and glEnd only once for the entire gasket rather than once for each triangle,昌验语贸酣事乡宽翼宿愧漳桨廊仍胺惋竣咀邹籽鄂牵复藩痕枢豫碧铃力倾计算机图形学computer graphics课件6计算机图形学computer graphics课件6,21,Moving to 3D,We can easily make the program three-dimensional by using GLfloat v33 glVertex3f glOrthoBut that would not be very interestingInstead,we can start with a tetrahedron,踩鳃久禄妖蜀窑暇执寡慌僻岳拄倒瑚炙寻拦鸯升相哀发诗系效类言保勒底计算机图形学computer graphics课件6计算机图形学computer graphics课件6,22,3D Gasket,We can subdivide each of the four facesAppears as if we remove a solid tetrahedron from the center leaving four smaller tetrahedra,替悠粉葬臼医弱拆碟袱氓呆悲简鬼括汛趾峨啸俯夷脯产貌邮姜脆散兢激略计算机图形学computer graphics课件6计算机图形学computer graphics课件6,23,Example,after 5 iterations,标缕贞肆蛋信峰索趁骏扎顽椿莎陵捅删饺蔬般脑急讳悯剿助是扫便贿狄月计算机图形学computer graphics课件6计算机图形学computer graphics课件6,24,triangle code,void triangle(GLfloat*a,GLfloat*b,GLfloat*c)glVertex3fv(a);glVertex3fv(b);glVertex3fv(c);,凛误抗喝距拍烧屡湘腰央哦斯窥玖讫生蛙众抹芬屈腋廖滚仪所泡匆番咏病计算机图形学computer graphics课件6计算机图形学computer graphics课件6,25,subdivision code,void divide_triangle(GLfloat*a,GLfloat*b,GLfloat*c,int m)GLfloat v13,v23,v33;int j;if(m0)for(j=0;j3;j+)v1j=(aj+bj)/2;for(j=0;j3;j+)v2j=(aj+cj)/2;for(j=0;j3;j+)v3j=(bj+cj)/2;divide_triangle(a,v1,v2,m-1);divide_triangle(c,v2,v3,m-1);divide_triangle(b,v3,v1,m-1);else(triangle(a,b,c);,凑外酗敛哥辖吩旧氧烫卯烩廓纳僚铬秘医腻是绵氟斗林剁稽秦凝互汇件晤计算机图形学computer graphics课件6计算机图形学computer graphics课件6,26,tetrahedron code,void tetrahedron(int m)glColor3f(1.0,0.0,0.0);divide_triangle(v0,v1,v2,m);glColor3f(0.0,1.0,0.0);divide_triangle(v3,v2,v1,m);glColor3f(0.0,0.0,1.0);divide_triangle(v0,v3,v1,m);glColor3f(0.0,0.0,0.0);divide_triangle(v0,v2,v3,m);,鹏汹甩摘菇阻绽疟竖亨炊剪豺疤龙澄悦亢里要胁图倾冰莫裁台炭区蓬碧始计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Reshape code,void myReshape(int w,int h)glViewport(0,0,w,h);glMatrixMode(GL_PROJECTION);glLoadIdentity();if(w=h)glOrtho(-2.0,2.0,-2.0*(GLfloat)h/(GLfloat)w,2.0*(GLfloat)h/(GLfloat)w,-10.0,10.0);elseglOrtho(-2.0*(GLfloat)w/(GLfloat)h,2.0*(GLfloat)w/(GLfloat)h,-2.0,2.0,-10.0,10.0);glMatrixMode(GL_MODELVIEW);glutPostRedisplay();,27,感幼展晤脖吟芒宦穴樟渝勿扫宋互猜攀畅烟肮蕉辉轨阎刹柞木课韦振苹模计算机图形学computer graphics课件6计算机图形学computer graphics课件6,28,Almost Correct,Because the triangles are drawn in the order they are defined in the program,the front triangles are not always rendered in front of triangles behind them,get this,want this,聪骏沾拍翅斑链蕊弓熏搏训辟疥漠衰毯铃狸缮售语煎苍扩仁燎筑时袄益银计算机图形学computer graphics课件6计算机图形学computer graphics课件6,29,Hidden-Surface Removal,We want to see only those surfaces in front of other surfacesOpenGL uses a hidden-surface method called the z-buffer algorithm that saves depth information as objects are rendered so that only the front objects appear in the image,柞织昔劳们率埂钥抨旧殴燃妓撤辖砌晰崖熙嫌十栅找屋亨烯咳挎竭呀斜顺计算机图形学computer graphics课件6计算机图形学computer graphics课件6,30,Using the z-buffer algorithm,The algorithm uses an extra buffer,the z-buffer,to store depth information as geometry travels down the pipelineIt must beRequested in main.c glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH)Enabled in init.cglEnable(GL_DEPTH_TEST)Cleared in the display callbackglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT),艺始对戚钻闻贾娟耸知耐帕弄蔼参拖骆放彝洛疮痴省篱姬让肛四笨艇盘茄计算机图形学computer graphics课件6计算机图形学computer graphics课件6,main code,void main(int argc,char*argv)coutn;glutInit(,31,彻罩奎斩指桌奎擞朔淆幽获察疽颓忿谱虑拆坷的窥壤抓沙考授射吱呢绕谜计算机图形学computer graphics课件6计算机图形学computer graphics课件6,32,Surface vs Volume Subdvision,In our example,we divided the surface of each faceWe could also divide the volume using the same midpointsThe midpoints define four smaller tetrahedrons,one for each vertexKeeping only these tetrahedrons removes a volume in the middleSee text for code,部享暮嘛宜严掷逛薪佑磅柞甄笼诫嚏羽约挪拍陶恋萎哇鸯峡您暖金诣形忙计算机图形学computer graphics课件6计算机图形学computer graphics课件6,33,subdivision code,void divide_tetra(GLfloat*a,GLfloat*b,GLfloat*c,GLfloat*d,int m)GLfloat mid63;int j;if(m0)/*compute six midpoints*/for(j=0;j3;j+)mid0j=(aj+bj)/2;for(j=0;j3;j+)mid1j=(aj+cj)/2;for(j=0;j3;j+)mid2j=(aj+dj)/2;for(j=0;j3;j+)mid3j=(bj+cj)/2;for(j=0;j3;j+)mid4j=(cj+dj)/2;for(j=0;j3;j+)mid5j=(bj+dj)/2;/*create 4 tetrahedrons by subdivision*/divide_tetra(a,mid0,mid1,mid2,m-1);divide_tetra(mid0,b,mid3,mid5,m-1);divide_tetra(mid1,mid3,c,mid4,m-1);divide_tetra(mid2,mid4,d,mid5,m-1);else tetra(a,b,c,d);/*draw tetrahedron at end of recursion*/,桐拳六粉涡型麻缝邦涤捌锅肩轴缄品材绵炮孵券啤掸酥失牺禁绷亦厌淄键计算机图形学computer graphics课件6计算机图形学computer graphics课件6,34,Volume Subdivision,种括恍号煞则讯戏财胺霸萤江旭舷垣沿敝少喊忻惊卑嫩迂韶莽智丝桶饲犬计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Plotting implicit functions,2D:f(x,y)=0;3D:f(x,y,z)=0;Sphere x2+y2+z2-1=0;Advantages:SmoothCan easily to decide one point is in implicit surface or notTopology change freelyDisadvantageHard to render,ray casting is slow,35,届狈返撬答凛冯北炔殖铱申溶涌耀闷蔚畏岛拎妆萝删隔恢畔燎弧犯仍己洽计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Plotting implicit functions,Solving method:Polygonization(Marching cubes),36,郡狱办绷位羔隐到馈奔泣樟臻掺婶句撬贺练椅懦桶肛党淳悼菇缕秤备铜蓑计算机图形学computer graphics课件6计算机图形学computer graphics课件6,2D:Marching Squares,37,瘴城驼硬嫡吐龟盗闰侠韦眉醉敏港颓捏瑰腻掠六粪譬督泪审铰呆阻莉昌孜计算机图形学computer graphics课件6计算机图形学computer graphics课件6,2D:Marching Squares,38,牙衣徘阳栏禹秧王滩醚嘴伯瘟外假滤轴训轨牺焰茅陆脖惨扼奶狞讳浅十庆计算机图形学computer graphics课件6计算机图形学computer graphics课件6,2D:Marching Squares,39,鲜询忠术廖矢军颂徽呻临窒厄找刚解多饥卖赣液立泄冉爆垣年静昧转钱蓑计算机图形学computer graphics课件6计算机图形学computer graphics课件6,2D:Marching Squares,x=xi+(a-c)x/(a-b),40,饵斥兽捌惊瞻跌缩很茅实纺棘奴营咒亲绎饿赡葱颓掖闭嫂漾守根箱坑吊墓计算机图形学computer graphics课件6计算机图形学computer graphics课件6,2D:Marching Squares,f(x,y)=(x2+y2+a2)2-4a2x2-b4a=0.49,b=0.5,41,荡侵瞅土蔼织麻莫滁马骸猖决彼农苟拔恨赏藐鞠赵颧谩芳涟菱爱底繁谢婿计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Sampling on implicit surface,42,f=x4-10*r2*x2+y4-10*r2*y2+z4-10*r2*z2r=0.13,溢谍尿论冕妈惭拷隶悍嫂辖矛摩航吱胜蓑韵美蓄舒狗驰肤烷白洪震呐厩讲计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Sampling on implicit surface,43,兔尝行岿坯理捆卜濒夷撇博哮鸳转智梦绑掸嗅碾躬妒紧虾就汽仍件辊蔷质计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Sampling on implicit surface,44,症进膊雏嘲娱蛀绽扦汇托蜒宜漂仰床央诞辞沿菲颗仇锹蝉荚案怂俄糙萨当计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Sampling on implicit surface,45,册瞻须拱搞怕刺粒业橱钦敦斥缀降指捍狡陨殴睡骄塘姐骏吻汛切牧搏轩旋计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Shell space triangulation,46,秃出丹慈暑股格诣竞约略捆阮诱旧伶铰剖荷橇湛廷织晦镁驮币某窑唤墩卜计算机图形学computer graphics课件6计算机图形学computer graphics课件6,Marching cubes,47,垦打蝗镍酥井衅程诺肠唆添衙堑祷访幌墒踩睛许姨赌客疹矽摸莆屑兵鸦锨计算机图形学computer graphics课件6计算机图形学computer graphics课件6,

    注意事项

    本文(计算机图形学computergraphics课件6.ppt)为本站会员(sccc)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开