文档详情

《计算机图形学》综合设计报告.doc

发布:2018-05-10约1.34万字共19页下载文档
文本预览下载声明
《计算机图形学》综合设计报告 M / m的 制 作 院 系: 信息科学技术学院 专 业: 计算机科学与技术 班 级: 报 告 人: ********** 学 号: **************** 指导教师: ***************** 2011年11月3日 设计思路 记得老师曾说,对于计算机图形这么课而言,绘制任何一种图形的关键就在于取点。就我感觉,所有图形的制作,大致思路都是相同的。对于那些代码和函数大多数都可以从教材或其他方面得到,我们所需要做的就是把握住核心。经过老师的指点之后,我知道了怎样才能画出一个具有立体感觉的图形。主要思路:所有点都取为空间中的点,首先在xoy平面上画出所需图形,而后把所有点的纵坐标沿z轴向后推几个单位即可。在更个设计过程中,我用的是取四个点画矩形的方法。这样看来,对于M和m的制作就变得很简单了。 对M而言,只画了四个矩形。而对于m,上半部分是两个半圆的叠加,下半部分是三个矩形。 具体实现代码 M的实现过程: 取点 GLfloat vertices[20][3]={{-0.3,-0.15,0},{-0.3,0.35,0},{-0.2,0.35,0}, {-0.2,-0.15,0},{-0.1,0,0},{0,0,0},{0.1,0.35,0},{0.2,0.35,0},{0.2,-0.15,0},{0.1,-0.15,0}, {-0.3,-0.15,0.2},{-0.3,0.35,0.2},{-0.2,0.35,0.2}, {-0.2,-0.15,0.2},{-0.1,0,0.2},{0,0,0.2},{0.1,0.35,0.2},{0.2,0.35,0.2},{0.2,-0.15,0.2},{0.1,-0.15,0.2}} Xoy面上画四个矩形构成M glColor3f(0.4,0.5,0.4); //颜色 glBegin(GL_POLYGON); glVertex3fv(vertices[0]); glVertex3fv(vertices[1]); glVertex3fv(vertices[2]); glVertex3fv(vertices[3]); glEnd(); glColor3f(0.6,0.5,0.6); glBegin(GL_POLYGON); glVertex3fv(vertices[2]); glVertex3fv(vertices[1]); glVertex3fv(vertices[4]); glVertex3fv(vertices[5]); glEnd(); glColor3f(0.6,0.8,0.6); glBegin(GL_POLYGON); glVertex3fv(vertices[5]); glVertex3fv(vertices[4]); glVertex3fv(vertices[6]); glVertex3fv(vertices[7]); glEnd(); glColor3f(0.2,0.5,0.7); glBegin(GL_POLYGON); glVertex3fv(vertices[7]); glVertex3fv(vertices[6]); glVertex3fv(vertices[8]); glVertex3fv(vertices[9]); glEnd(); 把xoy面上的图形沿z轴后推0.2个单位 glColor3f(0.4,0.5,0.4); glBegin(GL_POLYGON); glVertex3fv(vertices[10]); glVertex3fv(vertices[11]); glVertex3fv(vertices[12]); glVertex3fv(vertices[13]); glEnd(); glColor3f(0.6,0.5,0.6); glBegin(GL_POLYGON); glVertex3fv(vertices[12]); glVertex3fv(vertices[11]); glVertex3fv(vertices[14]); glVertex3fv(vertices[15]); glEnd(); glColor3f(0.6,0.8,0.6);
显示全部
相似文档