山东大学:《计算机图形学》课程PPT教学课件(Programming with OpenGL)Part 3:Three Dimensions

Programming with OpenGL Part 3: Three dimensions Yuanfeng Zhou Shandong University
1 Programming with OpenGL Part 3: Three Dimensions Yuanfeng Zhou Shandong University

Review Keywords 1.Development 2. State machine 3. Functions(formats), callback function 4. Simple cube program 5.Simple viewing 6. OpenGL primitives(polygon) 7. Attributes(color)
2 Review •Keywords: 1.Development 2.State machine 3.Functions (formats), callback function 4.Simple cube program 5.Simple viewing 6.OpenGL primitives (polygon) 7.Attributes (color)

Objectives Develop a more sophisticated three dimensional example Sierpinski gasket: a fractal Introduce hidden -surface removal Plotting implicit functions
3 Objectives •Develop a more sophisticated threedimensional example - Sierpinski gasket: a fractal •Introduce hidden-surface removal •Plotting implicit functions

Random Sierpinski Gasket
Random Sierpinski Gasket 4

main code void main(int argc, char*x argv) / Standard glut initialization glutlnit (&argc, argv) glutlnitDisplayMode(GLUT SINGLE GLUT RGB) glutlnitWindowSize (500, 500); /*500 X 500 pixel window * glutInitWindowPosition(0,0); /*place window top left on display * glut CreateWindow ("Sierpinski Gasket); /*window title */ glutDisplay Func(display) / display callback invoked when window opened * myinit(; /*set attributes*/ glutMainLoopo; /*enter event loop *
main code void main(int argc, char** argv) { /* Standard GLUT initialization */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500,500); /* 500 × 500 pixel window */ glutInitWindowPosition(0,0); /* place window top left on display */ glutCreateWindow("Sierpinski Gasket"); /* window title */ glutDisplayFunc(display); /* display callback invoked when window opened */ myinit(); /* set attributes */ glutMainLoop(); /* enter event loop */ } 5

init code void myinit(void / attributes*/ glClear Color (1.0, 1.0, 1.0, 1.0); / * white background * glColor3f(1.0, 0.0,0.0); / draw in red*/ / set up viewing /*500x 50.0 camera coordinate window with origin lower left * gIMatrixMode(GL PROjECtIon) gILoadldentityo gluortho2D(0.0,50.0,0.0,50.0) gIMatrixMode(GL MODELVIEw
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

display code void display (void) / A triangle * GLfloat vertices]2]={0.0.00}{25.050.0}{50.0.00 int i, j, k; GLfloat p[2]=0,0]; / an arbitrary initial point inside traingle * glClear(GL COLOR BUFFER BID); / clear the window * glBegin(GL POINTS): / compute and plots 5000 new points * for(k=0;k<10000k++) j=rando%3: / pick a vertex at random * Compute point halfway between selected vertex and old point * p[O]=(p[0]+vertices[OJ/2.0 p[1]=(p[1]+vertices[[1)/2.0 I plot new point * glVertex2fv(p) glEndo glFlusho; clear buffers*/
display code void display(void) { /* A triangle */ GLfloat vertices[3][2]={{0.0,0.0},{25.0,50.0},{50.0,0.0}}; int i, j, k; GLfloat p[2] ={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; k<10000; k++) { j=rand()%3; /* pick a vertex at random */ /* Compute point halfway between selected vertex and old point */ p[0] = (p[0]+vertices[j][0])/2.0; p[1] = (p[1]+vertices[j][1])/2.0; /* plot new point */ glVertex2fv(p); } glEnd(); glFlush(); /* clear buffers */ } 7

Results a Sierpinski Gasket 回X AAAA AAAA AAAA
Results 8

Three-dimensional Applications In OpenGL, two-dimensional applications are a special case of three-dimensional graphics Going to 3D Not much changes Use glvertex3*( Have to worry about the order in which polygons are drawn or use hidden-surface removal Polygons should be simple, convex, flat
9 Three-dimensional Applications •In OpenGL, two-dimensional applications are a special case of three-dimensional graphics •Going to 3D - Not much changes - Use glVertex3*( ) - Have to worry about the order in which polygons are drawn or use hidden-surface removal - Polygons should be simple, convex, flat

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 subdividing the area goes to zero but the perimeter goes to infinity This is not an ordinary geometric object It is neither two- nor three-dimensional It is a fractal(fractional dimension) object
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 subdividing - the area goes to zero - but the perimeter goes to infinity •This is not an ordinary geometric object - It is neither two- nor three-dimensional •It is a fractal (fractional dimension) object
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- Integrated analysis of regulatoryand metabolic networks revealsnovel regulatory mechanisms inSaccharomyces cerevisiae.ppt
- 基于语义关联和信息增益的TFIDF改进算法研究.ppt
- 《C程序设计》课程PPT教学课件(电子教案)第六章 函数.ppt
- 安徽理工大学:《汇编语言》课程教学资源(PPT课件讲稿)第五章 循环与分支程序设计.ppt
- 四川大学:Object-Oriented Design and Programming(Java,PPT课件).ppt
- 《编译原理和技术》课程PPT教学课件:第十三章 函数式语言的编译.ppt
- 《Microsoft Access 2003》教程PPT:第9章 报表设计.ppt
- 北京大学远程教育:《计算机应用基础》课程PPT教学课件(专科)串讲(综合复习).pptx
- 计算机问题求解(PPT讲稿)B树.pptx
- 香港理工大学:INSTRUCTION SETS 指令.pptx
- 《计算机网络原理》课程教学资源(PPT课件讲稿)第二章 网络实现模型.ppt
- 上海交通大学:《软件开发》课程教学资源(PPT课件)第一讲 概述.ppt
- 香港浸会大学:《Data Communications and Networking》课程教学资源(PPT讲稿)Socket Programming Part II:Design of Server Software.ppt
- 中国科学技术大学:《网络算法学》课程教学资源(PPT课件)第六章 传输控制.ppt
- 西安电子科技大学:《MATLAB程序设计语言》课程教学资源(PPT讲稿)Chapter1 Matlab系统概述.ppt
- 清华大学:Mandarin Pronunciation Variation Modeling.ppt
- 清华大学出版社:《C语言程序设计》课程教学资源(PPT课件讲稿)第7章 用户自定义函数.ppt
- 中国科学技术大学:《算法基础》课程教学资源(PPT课件讲稿)第七讲 顺序统计学(主讲人:吕敏).pptx
- 《Java语言程序设计》课程教学资源(PPT课件讲稿)第三章 面向对象特征.ppt
- Virtual Topologies - Faculty of Science, HKBU.ppt
- 《算法设计技巧与分析》课程教学资源(PPT讲稿)Lecture 8 贪婪法则 Greedy Approach.ppt
- 山西国际商务职业学院:《网页设计与制作》课程教学资源(PPT课件)第一章 网页设计基础知识.ppt
- 《多媒体教学软件设计》课程PPT教学课件:第13章 多媒体教学软件中脚本编程技巧.ppt
- 中国科学技术大学:《计算机体系结构》课程教学资源(PPT课件讲稿)动态调度(Cont)、推断执行和ILP.ppt
- 香港浸会大学:《Experiencing Cluster Computing》Class 8 Case Studies.ppt
- 香港理工大学:Building Robust Wireless LAN for Industrial Control with DSSS-CDMA Cell Phone Network Paradigm.ppt
- International Trade Forms.ppt
- 因特网多媒体技术(PPT讲稿).ppt
- 长春工业大学:《电子商务》课程教学资源(PPT课件)第9章 网络鞋城前台页面.ppt
- 数据传送类指令(PPT讲稿).ppt
- Lower bound for sorting, radix sort.ppt
- 《ASP动态网页设计实用教程》教学资源(PPT课件讲稿)第8章 Web数据库基础.ppt
- 卷积码的概率译码(PPT讲稿).ppt
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第十章 下一代因特网.ppt
- 复旦大学:Trapping in scale-free networks with hierarchical organization of modularity.pptx
- Network and System Security Risk Assessment(PPT讲稿)Introduction.ppt
- 香港科技大学:Latent Tree Models.pptx
- 《汇编语言程序设计》课程教学资源(PPT课件讲稿)循环与分支程序设计.ppt
- ARM Tachnology:Chapter 3 STM32 Clock and Configuration.ppt
- 《软件工程简介》课程PPT教学课件(可行性研究、需求分析、总体设计、详细设计).ppt