![AngelCG09图形学.ppt_第1页](http://file1.renrendoc.com/fileroot2/2020-1/6/7dfb2615-0394-4d7f-8048-2f2609e94e2a/7dfb2615-0394-4d7f-8048-2f2609e94e2a1.gif)
![AngelCG09图形学.ppt_第2页](http://file1.renrendoc.com/fileroot2/2020-1/6/7dfb2615-0394-4d7f-8048-2f2609e94e2a/7dfb2615-0394-4d7f-8048-2f2609e94e2a2.gif)
![AngelCG09图形学.ppt_第3页](http://file1.renrendoc.com/fileroot2/2020-1/6/7dfb2615-0394-4d7f-8048-2f2609e94e2a/7dfb2615-0394-4d7f-8048-2f2609e94e2a3.gif)
![AngelCG09图形学.ppt_第4页](http://file1.renrendoc.com/fileroot2/2020-1/6/7dfb2615-0394-4d7f-8048-2f2609e94e2a/7dfb2615-0394-4d7f-8048-2f2609e94e2a4.gif)
![AngelCG09图形学.ppt_第5页](http://file1.renrendoc.com/fileroot2/2020-1/6/7dfb2615-0394-4d7f-8048-2f2609e94e2a/7dfb2615-0394-4d7f-8048-2f2609e94e2a5.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1,Better Interactive Programs,Shandong University Software College Instructor: Xu Yanning E-mail: ,2,Objectives,Learn to build more sophisticated interactive programs using Picking Select objects from the display Three methods Rubberbanding Interactive drawing of lines and rectangles Display Lists R
2、etained mode graphics,3,Picking,Identify a user-defined object on the display In principle, it should be simple because the mouse gives the position and we should be able to determine to which object(s) a position corresponds Practical difficulties Pipeline architecture is feed forward, hard to go f
3、rom screen back to world Complicated by screen being 2D, world is 3D How close do we have to come to object to say we selected it?,4,Three Approaches,Hit list Most general approach but most difficult to implement Use back or some other buffer to store object ids as the objects are rendered Rectangul
4、ar maps Easy to implement for many applications See paint program in text,5,Rendering Modes Method1,OpenGL can render in one of three modes selected by glRenderMode(mode) GL_RENDER: normal rendering to the frame buffer (default) GL_FEEDBACK: provides list of primitives rendered but no output to the
5、frame buffer GL_SELECTION: Each primitive in the view volume generates a hit record that is placed in a name stack which can be examined later,6,Selection Mode Functions,glSelectBuffer(): specifies name buffer glInitNames(): initializes name buffer glPushName(id): push id on name buffer glPopName():
6、 pop top of name buffer glLoadName(id): replace top name on buffer id is set by application program to identify objects,7,Using Selection Mode,Initialize name buffer Enter selection mode (using mouse) Render scene with user-defined identifiers Reenter normal render mode This operation returns number
7、 of hits Examine contents of name buffer (hit records) Hit records include id and depth information,8,Selection Mode and Picking,As we just described it, selection mode wont work for picking because every primitive in the view volume will generate a hit Change the viewing parameters so that only tho
8、se primitives near the cursor are in the altered view volume Use gluPickMatrix (see text for details),9,Using Regions of the Screen- Method3,Many applications use a simple rectangular arrangement of the screen Example: paint/CAD program Easier to look at mouse position and determine which area of sc
9、reen it is in than using selection mode picking Paint Program,drawing area,tools,menus,10,Using Regions of the Screen- Method3,int pick(int x, int y) y = wh - y; if(y wh-ww/10) return 0; else if(x ww/10) return LINE; else if(x ww/5) return RECTANGLE; else if(x 3*ww/10) return TRIANGLE; else if(x 2*w
10、w/5) return POINTS; else if(x ww/2) return TEXT; else return 0; ,11,Using another buffer and colors for picking- Method2,For a small number of objects, we can assign a unique color (often in color index mode) to each object We then render the scene to a color buffer other than the front buffer so th
11、e results of the rendering are not visible We then get the mouse position and use glReadPixels() to read the color in the buffer we just wrote at the position of the mouse The returned color gives the id of the object,12,Writing Modes,frame buffer,application,bitwise logical operation,13,XOR write,U
12、sual (default) mode: source replaces destination (d = s) Cannot write temporary lines this way because we cannot recover what was “under” the line in a fast simple way Exclusive OR mode (XOR) (d = d s) x y x =y Hence, if we use XOR mode to write a line, we can draw it a second time and line is erase
13、d!,14,Rubberbanding,Switch to XOR write mode Draw object For line can use first mouse click to fix one endpoint and then use motion callback to continuously update the second endpoint Each time mouse is moved, redraw line which erases it and then draw line from fixed first position to to new second
14、position At end, switch back to normal drawing mode and draw line Works for other objects: rectangles, circles,15,Rubberband Lines,initial display,draw line with mouse in XOR mode,mouse moved to new position,first point,second point,original line redrawn with XOR,new line drawn with XOR,16,XOR in Op
15、enGL,There are 16 possible logical operations between two bits All are supported by OpenGL Must first enable logical operations glEnable(GL_COLOR_LOGIC_OP) Choose logical operation glLogicOp(GL_XOR) glLogicOp(GL_COPY) (default),17,Immediate and Retained Modes,Recall that in a standard OpenGL program
16、, once an object is rendered there is no memory of it and to redisplay it, we must re-execute the code for it Known as immediate mode graphics Can be especially slow if the objects are complex and must be sent over a network Alternative is define objects and keep them in some form that can be redisp
17、layed easily Retained mode graphics Accomplished in OpenGL via display lists,18,Display Lists,Conceptually similar to a graphics file Must define (name, create) Add contents Close In client-server environment, display list is placed on server Can be redisplayed without sending primitives over networ
18、k each time,19,Display List Functions,Creating a display list GLuint id; void init() id = glGenLists( 1 ); glNewList( id, GL_COMPILE) /* other OpenGL routines */ /GL_COMPILE_AND_EXECUTE glEndList(); Call a created list void display() glCallList( id ); ,20,Display Lists and State,Most OpenGL functions can be put in display lists State changes made inside a display list persist after the display list is executed Can avoid unexpected results by using glPushAttrib and glPushMatrix upon entering a display list and glPopAt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山林树木买卖合同协议
- 渣土车的租赁合同
- 方债务债权转让协议书
- 厂房转租协议书
- 装修公司与材料商合作协议
- 住宅及地下室买卖合同
- 合同管理数字化建议
- 手摩托车买卖合同版
- 办公中心办公空间租赁居间服务协议
- 租赁合同人力资源服务
- 2022一级建造师矿业工程真题及答案解析
- 小学语文三年级下《漏》公开课教学设计
- 粤教版四年级劳动与技术全册教案教学设计
- 最新肺结核诊断和治疗指南
- 绿色渐变个人简历介绍PPT模板课件
- CosmeticStandard(useforcables)_0622006f苹果电脑外观检验标准(英文版)
- 面粉、面条加工企业应急预案
- 高值医用耗材监测与点评制度
- 八年级地理下 7.1南方地区的自然特征与农业
- 部编版道德与法治《感受生活中的法律》第二课时教案
- EDUR气液多相溶气泵在气浮装置中使用说明
评论
0/150
提交评论