首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

OpenGL大作业 三维小破房设计(附报告)

后端 242.99KB 6 需要积分: 1
立即下载

资源介绍:

大一刚上完程序设计基础课的大作业,要求用到图形库,懵逼的我 临时参考网上的程序初步了解了一下。 https://blog.csdn.net/GUOXIAOHE0000/article/details/80893549 在上链接的代码中进行了修改,删去了一些东西。增加了房屋外部结构、内部家具、草地、树木,月亮和字母。另外增加了方向键等按键调整视角 包括源代码以及实验报告 仅用于学习及应付作业 希望可以帮助你
#include #include #include #include GLuint drawcube,drawsphere,drawteapot; static float a=0.0; static GLdouble eye=1.0; static GLfloat locate=1.0; static int lflag=GL_TRUE,rflag=GL_TRUE; void reshape(int w, int h) { glViewport(0,0,(GLsizei)w,(GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90,w/h,0.5,1000); //透视效果 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(80,100,160,0,0,0,0,10,0);//设置观察点 } void init1() //初始化 { glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //画出正方体显示列表 drawcube=glGenLists(1); glNewList(drawcube,GL_COMPILE); glutSolidCube(1); glEndList(); //画出茶壶显示列表 drawteapot=glGenLists(1); glNewList(drawteapot,GL_COMPILE); glutSolidTeapot(1); glEndList(); //设置普通灯光照0位置及参数; GLfloat position0[]={30,5,30,1}; GLfloat light0s[]={0.10,0.10,0.10,0.0}; GLfloat light0d[]={0.6,0.7,0.7}; GLfloat light0a[]={0.9,0.9,0.9}; glLightfv(GL_LIGHT0,GL_POSITION,position0); glLightfv(GL_LIGHT0,GL_SPECULAR,light0s); glLightfv(GL_LIGHT0,GL_DIFFUSE,light0d); glLightfv(GL_LIGHT0,GL_AMBIENT,light0a); //设置探照灯光照1位置及参数 GLfloat position1[]={-60,40,0,1}; GLfloat light1s[]={1.0,1.0,1.0,1.0}; GLfloat light1d[]={0.06,0.1,0.1}; GLfloat light1a[]={0.91,0.99,0.96}; GLfloat direction[]={0,-60,0,1}; glLightfv(GL_LIGHT1,GL_SPOT_DIRECTION,direction); glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,30.0); glLightfv(GL_LIGHT1,GL_POSITION,position1); glLightfv(GL_LIGHT1,GL_SPECULAR,light1s); glLightfv(GL_LIGHT1,GL_DIFFUSE,light1d); glLightfv(GL_LIGHT1,GL_AMBIENT,light1a); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); } void SpecialKeys(int key, int x, int y) //按键功能 { if(key==GLUT_KEY_LEFT) { a+=1.0; glutPostRedisplay(); } if(key==GLUT_KEY_RIGHT) { a-=1.0; glutPostRedisplay(); } if(key==GLUT_KEY_DOWN) { eye-=0.05; glutPostRedisplay(); } if(key==GLUT_KEY_UP) { eye+=0.05; glutPostRedisplay(); } if(key==GLUT_KEY_F1) { locate+=5.0; glutPostRedisplay(); } if(key==GLUT_KEY_F2) { locate-=5.0; glutPostRedisplay(); } } void draw() //绘制 { if(lflag) glEnable(GL_LIGHT0); if(rflag) glEnable(GL_LIGHT1); glClearColor(0.51,0.40,0.5,0.0); //背景色 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(a,0.0,1.0,0.0); glScaled(eye,eye,eye); glTranslatef(0,locate,0); glPushMatrix(); //绘制地面; glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(1.0,1.0,1.0,0.0); glTranslatef(0,-20,0); glScalef(147.5,1,147.5); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); //外地面 glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,100.0/255,0.0,0.5); glTranslatef(0,-22,0); glScalef(300,2,300); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.5); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); //外下地面 glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(210.0/255,105.0/255,30.0/255,0.5); glTranslatef(0,-48,0); glScalef(300,50,300); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.5); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); /*******以下为NPU字母,若不需要请注释*******/ //字 glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(100.0/255,0.0,0.0,0.0); glRotatef(30.0, 1, 0, 0); glRotatef(30.0, 0.0f, 1.0f, 0.0f); glTranslatef(-152,95,-200); glScalef(10,120,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(100.0/255,0.0,0.0,0.0); glTranslatef(-228,132,-5); glScalef(10,110,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(100.0/255,0.0,0.0,0.0); glTranslatef(-230,132,-70); glScalef(10,110,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); //P字母 glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,100.0/255,0.0,0.0); glTranslatef(-230,132,-100); glScalef(10,110,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,100.0/255,0.0,0.0); glTranslatef(-230,157,-160); glScalef(10,60,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,100.0/255,0.0,0.0); glTranslatef(-230,130,-132.5); glScalef(10,10,60); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,100.0/255,0.0,0.0); glTranslatef(-230,182,-132.5); glScalef(10,10,60); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); //u字母 glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,0.0,100.0/255,0.0); glTranslatef(-230,132,-190); glScalef(10,110,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,0.0,100.0/255,0.0); glTranslatef(-230,80,-222.5); glScalef(10,10,70); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(0.0,0.0,100.0/255,0.0); glTranslatef(-230,132,-255); glScalef(10,110,10); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); /*******以上为NPU字母,若不需要请注释*******/ //墙1 glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(1.0,1.0,1.0,0.0); glTranslatef(75,0,0); glScalef(2,150,150); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0); glutWireCube(1); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); //墙2 glPushMatrix(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT,GL_AMBIENT); glColor4f(1.0,1.0,1.0,0.0); glTranslatef(-75,0,0); glScalef(2,150,150); glCallList(drawcube); glColor4f(0.0,1.0,0.0,0.0);

资源文件列表:

3维房屋大作业.zip 大约有14个文件
  1. 3D房屋.exe 57.63KB
  2. 3维房屋大作业/
  3. 3维房屋大作业/bin/
  4. 3维房屋大作业/bin/Debug/
  5. 3维房屋大作业/bin/Debug/xx.exe 57.63KB
  6. 3维房屋大作业/main.cpp 20.03KB
  7. 3维房屋大作业/obj/
  8. 3维房屋大作业/obj/Debug/
  9. 3维房屋大作业/obj/Debug/22.o 33.91KB
  10. 3维房屋大作业/obj/Debug/main.o 30.31KB
  11. 3维房屋大作业/xx.cbp 1.42KB
  12. 3维房屋大作业/xx.depend 5.86KB
  13. 3维房屋大作业/xx.layout 362B
  14. 报告.doc 380KB
0评论
提交 加载更多评论
其他资源 毕业设计-基于JAVA的springboot超市进销存系统(源代码+论文)
本超市进销存系统以springboot作为框架,b/s模式以及MySql作为后台运行的数据库,同时使用Tomcat用为系统的服务器。本系统主要包括首页、个人中心、员工管理、客户管理、供应商管理、承运商管理、仓库信息管理、商品类别管理、 商品信息管理、采购信息管理、入库信息管理、出库信息管理、销售订单管理、部门管理、岗位管理等功能,通过这些功能的实现基本能够满足日常超市进销存管理的操作。 通过这个系统能够满足超市进销存系统的管理及员工的超市进销存管理功能。系统的主要功能包括:首页、个人中心、员工管理、客户管理、供应商管理、承运商管理、仓库信息管理、商品类别管理、 商品信息管理、采购信息管理、入库信息管理、出库信息管理、销售订单管理、部门管理、岗位管理等功能。 本系统提供给管理员对首页、个人中心、员工管理、客户管理、供应商管理、承运商管理、仓库信息管理、商品类别管理、 商品信息管理、采购信息管理、入库信息管理、出库信息管理、销售订单管理、部门管理、岗位管理等诸多功能进行管理。本系统对于用户输入的任何信息都进行了一定的验证,为管理员操作提高了效率,也使其数据安全性得到了保障。
毕业设计-基于JAVA的springboot超市进销存系统(源代码+论文)
tcp/IP源程序
C语言tcp/ip源程序
Flex图片浏览
一个可以看看的图片浏览实例
内网通3.4.3045最新版本 免广告码 积分码 算法工具.zip
内网通3.4.3045最新版本 免广告码 积分码 算法工具,每次生成100万积分
android下UDP通信
android下UDP通信,多播,组播等
STM32F10X固件库 STM32F10x_StdPeriph_Lib_V3.5.0
STM32F10X固件库 STM32F10x_StdPeriph_Lib_V3.5.0
KX驱动3552(稳定支持64位和32位系统)
本驱动是最新的3552版本! 完美支持32位64位的windows系统(XP,WIN7,WIN8,WIN8.1)完美调用EQP5 。本驱动是KX降世以来的全能版本!
spring入门实例
spring入门实例