收藏 分享(赏)

计算机图形图像绘制技术2.ppt

上传人:Facebook 文档编号:9730385 上传时间:2019-08-29 格式:PPT 页数:49 大小:602KB
下载 相关 举报
计算机图形图像绘制技术2.ppt_第1页
第1页 / 共49页
计算机图形图像绘制技术2.ppt_第2页
第2页 / 共49页
计算机图形图像绘制技术2.ppt_第3页
第3页 / 共49页
计算机图形图像绘制技术2.ppt_第4页
第4页 / 共49页
计算机图形图像绘制技术2.ppt_第5页
第5页 / 共49页
点击查看更多>>
资源描述

1、计算机图形图像绘制技术,第二讲,主要内容,显示三维坐标的程序(1) 几何对象的变换 变换矩阵 平移glTranslatef 旋转glRotatef 缩放glScalef 三维实体 显示三维坐标的程序(2) 颜色 点与线的属性 面的显示 隐藏面与深度缓冲 多边形面的方向 显示模式 练习,显示三维坐标的程序(1),变换矩阵,在OpenGL中使用矩阵进行渲染三维场景所需要的数据计算 为简化操作,OpenGL提供一个矩阵栈,每次用栈顶的矩阵对给定的物体或场景进行渲染 用glPushMatrix和glPopMatrix函数来将矩阵压栈和出栈,还可以用glScalef和glRotatef等函数对栈顶的矩阵

2、进行缩放和旋转等修改,Push / Pop Matrix,void glPushMatrix(void);,Push / Pop Matrix,void glPopMatrix(void);,glPushMatrix(); glTranslatef(.); glRotatef(.); glScalef(.); glutSolidCylinder(.); glPopMatrix();,平移glTranslatef,void glTranslated (GLdouble x, GLdouble y, GLdouble z); void glTranslatef (GLfloat x, GLfloa

3、t y, GLfloat z);演示,旋转glRotatef,void glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);演示,缩放glScalef,void glScaled (GLdouble x, GLdouble y, GLdouble z); void glScalef (GLfloat x, GLfloat y, GLfloat z);演示,Example,glLoadIdent

4、ity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef

5、();glPopMatrix(); glPopMatrix();,Identity,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();g

6、lLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,Translate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Id

7、entity,Translate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,Translate,Identity,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadI

8、dentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,Translate,Identity,Translate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPo

9、pMatrix();,Identity,Translate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,Translate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glL

10、oadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,Translate,Rotate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix(

11、);,Identity,Translate,Example,glLoadIdentity(); glPushMatrix();glTranslatef ();glPushMatrix();glLoadIdentity();glTranslate ();glPopMatrix();glPushMatrix();glRotatef ();glPopMatrix(); glPopMatrix();,Identity,平移与旋转的次序很重要,glLoadIdentity()glRotated(45, 0, 0, 1)glTranslated(5, 0, 0),OpenGL commands succe

12、ssively define new “local” coordinate spaces in terms of the “current” or previous local space.,三维实体对象,Glaux.lib库 void auxWireSphere(GLdouble); void auxSolidSphere(GLdouble); void auxWireCube(GLdouble); void auxSolidCube(GLdouble); void auxWireBox(GLdouble, GLdouble, GLdouble); void auxSolidBox(GLdo

13、uble, GLdouble, GLdouble); void auxWireTorus(GLdouble, GLdouble); void auxSolidTorus(GLdouble, GLdouble); void auxWireCylinder(GLdouble, GLdouble); void auxSolidCylinder(GLdouble, GLdouble); void auxWireIcosahedron(GLdouble); void auxSolidIcosahedron(GLdouble); void auxWireOctahedron(GLdouble); void

14、 auxSolidOctahedron(GLdouble); void auxWireTetrahedron(GLdouble); void auxSolidTetrahedron(GLdouble); void auxWireDodecahedron(GLdouble); void auxSolidDodecahedron(GLdouble); void auxWireCone(GLdouble, GLdouble); void auxSolidCone(GLdouble, GLdouble); void auxWireTeapot(GLdouble); void auxSolidTeapo

15、t(GLdouble);,球,立方体,长方体,圆环,圆柱,二十面体,八面体,四面体,十二面体,圆锥,茶壶,Glut库void glutWireSphere(GLdouble radius, GLint slices, GLint stacks);void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);void glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);void glutSolidCone(GLdouble base,

16、 GLdouble height, GLint slices, GLint stacks);void glutWireCube(GLdouble size);void glutSolidCube(GLdouble size);void glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);void glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);void glu

17、tWireDodecahedron(void);void glutSolidDodecahedron(void);void glutWireTeapot(GLdouble size);void glutSolidTeapot(GLdouble size);void glutWireOctahedron(void);void glutSolidOctahedron(void);void glutWireTetrahedron(void);void glutSolidTetrahedron(void);void glutWireIcosahedron(void);void glutSolidIco

18、sahedron(void);,显示三维坐标的程序(2),(演示),颜色,glColor3fv(face color) render_face() glColor3fv(eye color) render_eyes() glColor3fv(hair color) render_hair() glColor3fv(teeth color) render_teeth(),Colors,颜色其有四个分量:R - 红 Red.G - 绿 Green.B - 蓝 Blue.A - 透明度 Transparent.,glShadeModel(GL_FLAT); glBegin(GL_QUADS);glC

19、olor3f (1.0,0.0,0.0);glVertex3f(0.0,0.0,0.0);glColor3f (0.0,1.0,0.0);glVertex3f(1.0,0.0,0.0);glColor3f (0.0,0.0,1.0);glVertex3f(1.0,1.0,0.0);glColor3f (1.0,1.0,0.0);glVertex3f(0.0,1.0,0.0); glEnd();,Shading Models,glShadeModel(GL_SMOOTH); glBegin(GL_QUADS);glColor3f (1.0,0.0,0.0);glVertex3f(0.0,0.0,

20、0.0);glColor3f (0.0,1.0,0.0);glVertex3f(1.0,0.0,0.0);glColor3f (0.0,0.0,1.0);glVertex3f(1.0,1.0,0.0);glColor3f (1.0,1.0,0.0);glVertex3f(0.0,1.0,0.0); glEnd();,Shading Models,演示,点与线的属性,演示,深度缓冲区,当我们从某处看景物时,接近于视点的物体遮挡了离视点较远的物体。 深度缓冲区为每个像素保存一个距离或深度值,以便让OpenGL通过简单方法做隐藏面计算。 只有当新像素的深度值小于旧像素的深度值时,才允许像素的覆盖。,

21、画家算法与深度排序,画家算法的局限性,解决办法:分割成两个,演示,多边形面的方向,法线方向的指定方法一,根据顶点顺序确定,法线方向的指定方法二,指定法线,面的可见性,void glCullFace (GLenum mode); GLenum取值:GL_FRONT、GL_BACK、GL_FRONT_AND_BACK,多边形显示模式,glPolygonMode(GLenum face, GLenum mode);,GL_FILL, GL_LINE, GL_POINT,GL_FRONT, GL_BACK, GL_FRONT_AND_BACK,GL_FILL,GL_LINE,GL_POINT,演示,练习,1. 简单的城市模型,2 三维飞机模型,3,4 作三维成绩统计饼图或条形图,第二次课和第三次课练习作为一次大作业; 可任选题目; 第一次大作业在第四次课,上课之前交. 作业发email至:,

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

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报