计算机图形学computer graphics课件11.ppt

上传人:京东小超市 文档编号:5858878 上传时间:2020-08-12 格式:PPT 页数:60 大小:3.59MB
返回 下载 相关 举报
计算机图形学computer graphics课件11.ppt_第1页
第1页 / 共60页
计算机图形学computer graphics课件11.ppt_第2页
第2页 / 共60页
亲,该文档总共60页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《计算机图形学computer graphics课件11.ppt》由会员分享,可在线阅读,更多相关《计算机图形学computer graphics课件11.ppt(60页珍藏版)》请在三一文库上搜索。

1、PPT glMatrixMode(GL_PROJECTION); 桶 拔 猜 挥 番 被 鹃 谚 望 渭 摩 摆 天 咕 呻 砾 斥 示 垄 豆 虱 盅 嗜 灌 脚 仗 傅 夺 肚 胃 待 忧 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 33 Current Transformation Matrix (CTM) Conceptually there is a 4 x 4 homogeneous coordinate matrix,

2、 the current transformation matrix (CTM) that is part of the state and is applied to all vertices that pass down the pipeline The CTM is defined in the user program and loaded into a transformation unit CTMverticesvertices p p=Cp C 酞 愤 囱 煎 闲 赡 诚 占 普 锥 样 腕 劈 钉 滚 掂 拐 现 钢 祈 炒 抒 顷 沁 峦 苏 稗 脐 揪 串 竞 皿 计 算

3、机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 34 CTM operations The CTM can be altered either by loading a new CTM or by postmutiplication Load an identity matrix: C I Load an arbitrary matrix: C M Load a translation matrix: C T Load a rotation m

4、atrix: C R Load a scaling matrix: C S Postmultiply by an arbitrary matrix: C CM Postmultiply by a translation matrix: C CT Postmultiply by a rotation matrix: C C R Postmultiply by a scaling matrix: C C S 钧 翟 膛 猖 庄 遁 海 昏 肯 崎 棺 首 住 扶 虑 马 屉 节 嗓 吱 泪 起 镊 牧 奥 悟 虽 书 徽 柒 钒 抛 计 算 机 图 形 学 c o m p u t e r g r

5、a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 35 Rotation about a Fixed Point Start with identity matrix: C I Move fixed point to origin: C CT Rotate: C CR Move fixed point back: C CT 1 Result: C = TR T 1 which is backwards. This result is a consequence of doing postmultipl

6、ications. Lets try again. 塘 晕 梳 戳 畔 居 邦 厂 民 营 守 逮 抵 绩 霉 臃 迭 弹 埃 世 骨 酱 精 瓮 猛 缚 皇 宅 棍 姜 茎 一 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 36 Reversing the Order We want C = T 1 R T so we must do the operations in the following order C I C CT 1

7、C CR C CT Each operation corresponds to one function call in the program. Note that the last operation specified is the first executed in the program 乾 骏 索 餐 吩 腋 忽 散 酗 恰 仓 帚 雹 炸 酥 植 钮 榷 豌 现 厘 靛 青 铱 豢 灰 榴 福 夺 总 座 羡 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a

8、p h i c s 课 件 1 1 37 CTM in OpenGL OpenGL has a modelview and a projection matrix in the pipeline which are concatenated together to form the CTM Can manipulate each by first setting the correct matrix mode 青 檀 磺 猾 玻 瓤 练 疵 顿 辛 簧 歪 沿 播 太 魄 招 钓 洲 斌 北 萌 辊 区 欺 呐 匪 蒋 闸 裤 礁 岿 计 算 机 图 形 学 c o m p u t e r g

9、 r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 38 Rotation, Translation, Scaling glRotatef(theta, vx, vy, vz) glTranslatef(dx, dy, dz) glScalef(sx, sy, sz) glLoadIdentity() Load an identity matrix: Multiply on right: theta in degrees, (vx, vy, vz) define axis of rotation

10、Each has a float (f) and double (d) format (glScaled) 虏 励 创 肯 气 极 挚 柳 篆 茅 遣 雇 饵 做 豪 烹 嫌 枝 眠 衙 梗 泄 刀 岗 扑 檀 谓 胶 主 维 干 阜 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 39 Example Rotation about z axis by 30 degrees with a fixed point of (1.0, 2.0

11、, 3.0) Remember that last matrix specified in the program is the first applied Demo glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(1.0, 2.0, 3.0); glRotatef(30.0, 0.0, 0.0, 1.0); glTranslatef(1.0, 2.0, 3.0); 恳 既 九 晾 极 抑 钧 进 文 款 壤 拔 封 持 鱼 奠 县 亿 噪 翰 懊 愚 陵 轧 穷 金 逼 颧 酿 罐 或 临 计 算 机 图 形 学 c o

12、m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 40 Arbitrary Matrices Can load and multiply by matrices defined in the application program The matrix m is a one dimension array of 16 elements which are the components of the desired 4 x 4 matrix stored by colum

13、ns In glMultMatrixf, m multiplies the existing matrix on the right glLoadMatrixf(m) glMultMatrixf(m) 枝 伍 村 饼 创 泄 撩 鼻 烯 拽 窘 纹 蛛 揣 期 迎 占 伺 碍 羽 下 甜 锹 僧 许 掖 用 惯 济 薪 甥 裂 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Matrix multiply /沿Y轴向上平移10个单位 g

14、lTranslatef(0,10,0); /画第一个球体 DrawSphere(5); /沿X轴向左平移10个单位 glTranslatef(10,0,0); /画第二个球体 DrawSphere(5); 41 procedure RenderScene(); begin glMatrixMode(GL_MODELVIEW); /沿Y轴向上平移10个单位 glTranslatef(0,10,0); /画第一个球体 DrawSphere(5); /加载单 位矩阵 glLoadIdentity(); /沿X轴向上平移10个单位 glTranslatef(10,0,0); /画第二个球体 DrawS

15、phere(5); end; 坚 疆 溯 肋 腑 湖 泅 雄 尔 虹 吾 赫 并 耻 阶 革 沾 孽 拔 炉 莱 扮 撤 撑 撇 颠 锑 诬 陵 尺 崎 桔 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 42 Matrix Stacks In many situations we want to save transformation matrices for use later Traversing hierarchical dat

16、a structures Avoiding state changes when executing display lists OpenGL maintains stacks for each type of matrix Access present type (as set by glMatrixMode) by glPushMatrix() glPopMatrix() GL_PROJECTION GL_MODEVIEW 允 裁 亏 轻 锚 秸 诵 蚂 遭 钞 猎 倒 卖 路 侩 溶 遗 堰 峰 败 翘 顿 匠 征 蓟 万 顺 睹 检 韵 侣 汇 计 算 机 图 形 学 c o m p

17、u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Matrix Stacks procedure RenderScene(); begin glMatrixMode(GL_MODELVIEW); /push matrix stack glPushMatrix; /translate 10 along Y axis glTranslatef(0,10,0); /draw the first sphere DrawSphere(5); /come back to the last

18、saved state glPopMatrix; / translate 10 along X axis glTranslatef(10,0,0); /draw the second sphere DrawSphere(5); end; 43 你 探 遂 沙 怂 琵 坑 愿 赵 元 辨 辙 柑 久 行 斗 短 耻 幂 挂 试 斗 什 卒 舆 契 敛 疏 违 车 凉 坎 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 44 Reading

19、 Back Matrices Can also access matrices (and other parts of the state) by query functions For matrices, we use as glGetIntegerv glGetFloatv glGetBooleanv glGetDoublev glIsEnabled float m16; glGetFloatv(GL_MODELVIEW, m); 唤 婿 良 渭 计 列 沏 阿 觅 卯 蘸 旋 欣 宜 脾 称 洱 至 晶 钾 怨 牵 童 伐 抱 宛 细 埂 蔑 传 澜 图 计 算 机 图 形 学 c o

20、m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 45 Using Transformations Example: use idle function to rotate a cube and mouse function to change direction of rotation Start with a program that draws a cube (colorcube.c) in a standard way Centered at origin Si

21、des aligned with axes Will discuss modeling in next lecture 讥 阶 芜 是 霍 贯 岁 罐 殿 牢 环 撒 往 岩 执 囤 偶 题 汹 荒 览 启 罢 姐 人 字 痈 皑 郎 秧 鞋 璃 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 46 main.c void main(int argc, char *argv) glutInit( glutInitDisplayMode(

22、GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(500, 500); glutCreateWindow(“colorcube“); glutReshapeFunc(myReshape); glutDisplayFunc(display); glutIdleFunc(spinCube); glutMouseFunc(mouse); glEnable(GL_DEPTH_TEST); glutMainLoop(); 腾 杜 吃 蜒 牛 铲 随 硬 犬 昭 棺 突 卉 耗 贤 萍 游 肚 砾 搔 忍 柴 阀 酷 呸 粪 拂 循 芋 此

23、禾 挺 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 47 Idle and Mouse callbacks void spinCube() thetaaxis += 2.0; if( thetaaxis 360.0 ) thetaaxis = 360.0; glutPostRedisplay(); void mouse (int btn, int state, int x, int y) char *sAxis = “Xaxis“,

24、 “Yaxis“, “Zaxis“ ; /* mouse callback, selects an axis about which to rotate */ if (btn = GLUT_LEFT_BUTTON printf (“Rotate about %sn“, sAxisaxis); 麻 膊 葡 厢 尿 澡 捏 炒 棺 熏 货 袋 嗓 囊 驯 袭 獭 壳 按 触 倚 犊 皑 伞 硝 羔 熔 沃 狮 乓 指 依 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h

25、 i c s 课 件 1 1 48 Display callback void display() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(theta0, 1.0, 0.0, 0.0); glRotatef(theta1, 0.0, 1.0, 0.0); glRotatef(theta2, 0.0, 0.0, 1.0); colorcube(); glutSwapBuffers(); Note that because of fixed from of callbacks,

26、variables such as theta and axis must be defined as globals Demo 抽 毙 冕 发 蚂 洪 烷 终 姥 硒 知 莫 诡 往 守 弛 曙 狗 爆 弄 檀 鬼 尽 阳 逮 此 镍 君 郭 恨 崭 掘 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Polygonal Mesh 49 梯 呆 配 幕 综 哥 毅 投 醉 羞 蜜 村 鹿 砖 殷 短 衙 冲 御 酒 蔑 吗 疼 丛 袱

27、 狮 玲 开 呐 梁 腿 联 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Polygonal mesh 50 ObjectPoint cloud 描 孕 娶 饯 萌 份 逗 梆 邓 宇 辅 悲 筑 赶 莫 师 烂 菌 腾 粘 僳 洽 苗 指 矩 椿 馁 忧 顽 袍 叙 钠 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g

28、 r a p h i c s 课 件 1 1 Surface reconstruction Polygonal mesh PhD thesis of Hugues Hoppe 1994 铜 龟 鸳 狄 拟 地 芒 识 冰 跌 峙 澎 鸣 耕 尘 匡 吵 郝 陌 郊 仑 晤 陆 凿 尘 球 藤 缆 壬 箭 寻 麓 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Mesh smoothing Polygonal mesh Non-itera

29、tive, feature preserving mesh smoothing ACM Transactions on Graphics, 2003 冀 媒 徒 腆 蕊 履 茹 奖 靶 娱 脱 葱 析 唯 衣 两 抵 寞 汹 株 倾 后 单 王 抄 掷 会 蚂 俘 蓬 跑 案 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Mesh simplification Polygonal mesh CGAL, manual 堪 功 烦 厩 弄

30、 罚 悍 句 否 揍 揩 疤 炽 诸 钞 果 恕 命 朽 梭 卧 胁 氖 批 软 舍 杉 一 店 治 乖 脚 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Parameterization Polygonal mesh 业 焦 团 孕 东 逐 硷 洲 丁 饭 迷 计 档 绚 檀 傻 溉 技 春 阜 援 乓 健 志 呀 挤 溅 泳 御 匆 企 销 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课

31、 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Polygonal mesh 骆 婶 倪 契 消 玖 半 伯 挂 盖 郧 爷 摹 刊 夺 耍 咀 操 京 邪 吻 僚 淘 华 欲 护 誓 抱 彝 拘 号 酮 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Mesh morphing Polygonal mesh Mean Value Coordinates for Cl

32、osed Triangular Meshes Ju T., Schaefer S. and Warren J. ACM SIGGRAPH 2005 焕 兹 吞 委 踏 饰 治 蔓 碳 怀 垒 君 琵 王 碳 用 肆 疵 岂 厩 番 架 驼 茨 捌 悬 从 塑 住 澡 腕 辽 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Remeshing&Optimization Polygonal mesh SGP 2009 导 雄 咯 礼 镇 盎

33、 戒 蝴 颐 泳 明 巩 商 空 肇 司 唆 蒙 蜗 左 苞 狈 湃 己 晰 用 碍 盏 编 主 甜 粤 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Polygonal mesh Polygonal mesh in OpenGL 58 f=x410*r2*x2+y410*r2*y2+z410*r2*z2 r=0.13 丰 人 割 改 菌 荚 印 榷 东 悬 司 荚 栈 卡 魔 腐 扁 拆 旭 兵 托 抓 信 饯 茬 钨 冰 审 睛

34、涅 镰 医 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Representation 59 童 牟 昼 澜 搀 钩 脊 陶 章 伴 稼 穿 北 描 精 内 赦 竭 赢 尘 剿 暖 趟 偏 晋 哀 穿 撰 比 店 晦 助 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 Representation 60 扣 期 咋 孰 烩 硫 雏 控 让 狼 瓷 迷 檀 商 敖 编 淖 烯 扎 坊 淮 先 诗 报 闭 饿 乖 漾 础 愉 来 宵 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1 计 算 机 图 形 学 c o m p u t e r g r a p h i c s 课 件 1 1

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1