会员注册 | 登录 | 微信快捷登录 QQ登录 微博登录 | 帮助中心 人人文库renrendoc.com美如初恋!
站内搜索 百度文库

热门搜索: 直缝焊接机 矿井提升机 循环球式转向器图纸 机器人手爪发展史 管道机器人dwg 动平衡试验台设计

   首页 人人文库网 > 资源分类 > DOC文档下载

山大教材资料`交互式计算机图形学`附录源码.doc

  • 资源星级:
  • 资源大小:217.50KB   全文页数:59页
  • 资源格式: DOC        下载权限:注册会员/VIP会员
您还没有登陆,请先登录。登陆后即可下载此文档。
  合作网站登录: 微信快捷登录 支付宝快捷登录   QQ登录   微博登录
友情提示
2:本站资源不支持迅雷下载,请使用浏览器直接下载(不支持QQ浏览器)
3:本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰   

山大教材资料`交互式计算机图形学`附录源码.doc

交互式计算机图形学基于openGL的自顶向下方法山东大学数字媒体技术专业课本教材附录程序第四版A.1Sierpinski镂垫程序/twodimensionalSierpinskigasket//generatedusingrandomlyselectedvertices//andbisection/include/youmayhavetochangetheincludetoorelsewheredependingonwhereitisstoredonyoursystem//glut.husuallyhasincludedforgl.handglu.h/voidmyinitvoid{/attributes/glClearColor1.0,1.0,1.0,1.0/whitebackground/glColor3f1.0,0.0,0.0/drawinred//setupviewing//50.050.0cameracoordinatewindowwithoriginlowerleft/glMatrixModeGL_PROJECTIONglLoadIdentitygluOrtho2D0.0,50.0,0.0,50.0glMatrixModeGL_MODELVIEW}voiddisplayvoid{/Atriangle/GLfloatvertices32{{0.0,0.0},{25.0,50.0},{50.0,0.0}}inti,j,kintrand/standardrandomnumbergenerator/GLfloatp2{7.5,5.0}/anarbitraryinitialpointinsidetraingle/glClearGL_COLOR_BUFFER_BIT/clearthewindow/glBeginGL_POINTS/computeandplots5000newpoints/交互式计算机图形学基于OpenGL的自顶向下方法第4版586fork0kinclude/initialtriangle/GLfloatv32{{1.0,0.58},{1.0,0.58},{0.0,1.15}}intnvoidtriangleGLfloata,GLfloatb,GLfloatc/displayonetriangle/附录A实例程序587{glVertex2fvaglVertex2fvbglVertex2fvc}voiddivide_triangleGLfloata,GLfloatb,GLfloatc,intm{/trianglesubdivisionusingvertexnumbers/GLfloatv02,v12,v22intjifm0{forj0jinclude/initialtetrahedron/GLfloatv43{{0.0,0.0,1.0},{0.0,0.942809,0.33333},{0.816497,0.471405,0.333333},{0.816497,0.471405,0.333333}}GLfloatcolors43{{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0},{0.0,0.0,0.0}}intnvoidtriangleGLfloatva,GLfloatvb,GLfloatvc{glVertex3fvvaglVertex3fvvbglVertex3fvvc}voidtetraGLfloata,GLfloatb,GLfloatc,GLfloatd{glColor3fvcolors0trianglea,b,cglColor3fvcolors1trianglea,c,dglColor3fvcolors2trianglea,d,bglColor3fvcolors3triangleb,d,c}voiddivide_tetraGLfloata,GLfloatb,GLfloatc,GLfloatd,intm{GLfloatmid63intjifm0{/computesixmidpoints/附录A实例程序589forj0jvoiddisplay{doublefdouble,doubleintcelldouble,double,double,doublevoidlinesint,int,int,double,double,double,doubledoubledataN_XN_Yinti,jintcglClearGL_COLOR_BUFFER_BIT/formdataarrayfromfunction/fori0iTHRESHOLDn1ifbTHRESHOLDn8ifcTHRESHOLDn4ifdTHRESHOLDn2returnn}/drawlinesegmentsforeachcase/voidlinesintnum,inti,intj,doublea,doubleb,doublec,doubled{voiddraw_oneint,int,int,double,double,double,doublevoiddraw_adjacentint,int,int,double,double,double,doublevoiddraw_oppositeint,int,int,double,double,double,doubleswitchnum{case1case2case4case7case8case11case13case14draw_onenum,i,j,a,b,c,dbreakcase3case6case9case12交互式计算机图形学基于OpenGL的自顶向下方法第4版592draw_adjacentnum,i,j,a,b,c,dbreakcase5case10draw_oppositenum,i,j,a,b,c,dbreakcase0case15break}}voiddraw_oneintnum,inti,intj,doublea,doubleb,doublec,doubled{doublex1,y1,x2,y2doubleox,oydoubledx,dydxX_MAXX_MIN/N_X1.0dyY_MAXY_MIN/N_Y1.0oxX_MINiX_MAXX_MIN/N_X1.0oyY_MINjY_MAXY_MIN/N_Y1.0switchnum{case1case14x1oxy1oydyTHRESHOLDa/dax2oxdxTHRESHOLDa/bay2oybreakcase2case13x1oxy1oydyTHRESHOLDa/dax2oxdxTHRESHOLDd/cdy2oydybreakcase4case11x1oxdxTHRESHOLDd/cdy1oydyx2oxdxy2oydyTHRESHOLDb/cbbreakcase7case8x1oxdxTHRESHOLDa/bay1oyx2oxdxy2oydyTHRESHOLDb/cbbreak}glBeginGL_LINESglVertex2dx1,y1附录A实例程序593glVertex2dx2,y2glEnd}voiddraw_adjacentintnum,inti,intj,doublea,doubleb,doublec,doubled{doublex1,y1,x2,y2doubleox,oydoubledx,dydxX_MAXX_MIN/N_X1.0dyY_MAXY_MIN/N_Y1.0oxX_MINiX_MAXX_MIN/N_X1.0oyY_MINjY_MAXY_MIN/N_Y1.0switchnum{case3case12x1oxdxTHRESHOLDa/bay1oyx2oxdxTHRESHOLDd/cdy2oydybreakcase6case9x1oxy1oydyTHRESHOLDa/dax2oxdxy2oydyTHRESHOLDb/cbbreak}glBeginGL_LINESglVertex2dx1,y1glVertex2dx2,y2glEnd}voiddraw_oppositeintnum,inti,intj,doublea,doubleb,doublec,doubled{doublex1,y1,x2,y2,x3,y3,x4,y4doubleox,oydoubledx,dydxX_MAXX_MIN/N_X1.0dyY_MAXY_MIN/N_Y1.0oxX_MINiX_MAXX_MIN/N_X1.0oyY_MINjY_MAXY_MIN/N_Y1.0switchnum{case5x1oxy1oydyTHRESHOLDa/dax2oxdxTHRESHOLDa/ba

注意事项

本文(山大教材资料`交互式计算机图形学`附录源码.doc)为本站会员(21ask)主动上传,人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知人人文库网(发送邮件至[email protected]或直接QQ联系客服),我们立即给予删除!

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

[email protected] 2015-2017 人人文库网网站版权所有
苏ICP备12009002号-5