当前位置: 首页 > news >正文

胶南网站建设价格站长之家0

胶南网站建设价格,站长之家0,王野天女,商城网站制作明细程序示例精选 COpenGL三维显示镜面反射光线漫反射实例 如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助! 前言 这篇博客针对《COpenGL三维显示镜面反射光线漫反射实例》编写代码,代码整洁,…

程序示例精选
C++OpenGL三维显示镜面反射光线漫反射实例
如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

前言

这篇博客针对《C++OpenGL三维显示镜面反射光线漫反射实例》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


运行结果


文章目录

一、所需工具软件
二、使用步骤
       1. 主要代码
       2. 运行结果
三、在线协助

一、所需工具软件

       1. Python
       2. Pycharm

二、使用步骤

代码如下(示例):
void init() {glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);glutInitWindowSize(500, 500);glutCreateWindow("ObjLoader");glEnable(GL_DEPTH_TEST);//glDisable(GL_DEPTH_TEST);glShadeModel(GL_SMOOTH); setLightRes();glEnable(GL_DEPTH_TEST);// objModel.Init();glDepthFunc(GL_LEQUAL); // 设置深度测试函数
}void display() {glColor3f(1.0, 1.0, 1.0);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glMatrixMode(GL_MODELVIEW);glLoadIdentity();// 应用平移和缩放glTranslatef(transX, transY, -270.0f); // 应用水平和垂直平移141.0fglScalef(zoomFactor, zoomFactor, zoomFactor); // 应用缩放setLightRes();glPushMatrix();// 更新gluLookAt以使用vertDegree进行垂直旋转float vertRad = c * vertDegree; // 将vertDegree转换为弧度gluLookAt(r * cos(c * degree) * cos(vertRad), r * sin(vertRad), r * sin(c * degree) * cos(vertRad),0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);// 根据计算出的中心坐标平移模型glTranslatef(-objModel.center[0], -objModel.center[1], -objModel.center[2]);objModel.Draw();glPopMatrix();glutSwapBuffers();
}void reshape(int width, int height) {glViewport(0, 0, width, height);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(60.0f, (GLdouble)width / (GLdouble)height, 1.0f, 200.0f);glMatrixMode(GL_MODELVIEW);
}// 在全局范围内定义一个变量来追踪当前鼠标操作
enum MouseAction { NONE, ROTATE, TRANSLATE };
MouseAction currentAction = NONE;void mouseButton(int button, int state, int x, int y) {if (state == GLUT_DOWN) {if (button == GLUT_LEFT_BUTTON) {currentAction = ROTATE;oldPosX = x;oldPosY = y;}else if (button == GLUT_RIGHT_BUTTON) {currentAction = TRANSLATE;oldRightPosX = x;oldRightPosY = y;}}else if (state == GLUT_UP) {currentAction = NONE;}
}void mouseMove(int x, int y) {if (currentAction == ROTATE) {int deltaX = x - oldPosX;int deltaY = y - oldPosY;degree += deltaX;vertDegree += deltaY;oldPosX = x;oldPosY = y;}else if (currentAction == TRANSLATE) {transX += (x - oldRightPosX) * 0.01f;transY -= (y - oldRightPosY) * 0.01f;oldRightPosX = x;oldRightPosY = y;}glutPostRedisplay();
}//滚轮没反应
void mouseWheel(int wheel, int direction, int x, int y) //
{cout << "test " << endl;cout << "Mouse wheel event detected. Direction: " << direction << endl;if (direction > 0) {zoomFactor += 0.1f; // 增加缩放因子}else {zoomFactor -= 0.1f; // 减小缩放因子}// 防止缩放因子小于等于0if (zoomFactor <= 0.1f) {zoomFactor = 0.1f;}glutPostRedisplay();
}void processNormalKeys(unsigned char key, int x, int y) {switch (key) {case 'w': // Pressing "w" key, zoom incout << "Zoom factor increased by 0.1\n"; zoomFactor += 0.1f;break;case 's': // Pressing "s" key, zoom outzoomFactor -= 0.1f;if (zoomFactor <= 0.1f) {zoomFactor = 0.1f; // Prevent zoomFactor from going below 0.1}break;case 27: // Pressing the Esc key (ASCII value 27) to exit the programexit(0);break;// Add more cases for handling other keys as needed}glutPostRedisplay();
}void specialKeys(int key, int x, int y) {switch (key) {case GLUT_KEY_UP:// 按下上方向键,进行相应操作break;case GLUT_KEY_DOWN:// 按下下方向键,进行相应操作break;}glutPostRedisplay();
}void myIdle() {glutPostRedisplay();
}int main(int argc, char* argv[]) {glutInit(&argc, argv);init();glutDisplayFunc(display);glutReshapeFunc(reshape);glutMouseFunc(mouseButton);glutMotionFunc(mouseMove);glutMouseWheelFunc(mouseWheel);glutKeyboardFunc(processNormalKeys);     // 处理一般的键盘事件glutSpecialFunc(specialKeys);  // 处理特殊键盘事件glutIdleFunc(myIdle);// 在此处调用 CalculateCenter() 函数objModel.CalculateCenter();// 打印模型的中心坐标objModel.PrintCenter();// 计算并打印模型长宽高objModel.CalculateBoundingBox();objModel.PrintBoundingBox();glutMainLoop();return 0;
}
运行结果

三、在线协助:

如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!

1)远程安装运行环境,代码调试
2)Visual Studio, Qt, C++, Python编程语言入门指导
3)界面美化
4)软件制作
5)云服务器申请
6)网站制作

当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851
个人博客主页:https://blog.csdn.net/alicema1111?type=blog
博主所有文章点这里:https://blog.csdn.net/alicema1111?type=blog

博主推荐:
Python人脸识别考勤打卡系统:
https://blog.csdn.net/alicema1111/article/details/133434445
Python果树水果识别:https://blog.csdn.net/alicema1111/article/details/130862842
Python+Yolov8+Deepsort入口人流量统计:https://blog.csdn.net/alicema1111/article/details/130454430
Python+Qt人脸识别门禁管理系统:https://blog.csdn.net/alicema1111/article/details/130353433
Python+Qt指纹录入识别考勤系统:https://blog.csdn.net/alicema1111/article/details/129338432
Python Yolov5火焰烟雾识别源码分享:https://blog.csdn.net/alicema1111/article/details/128420453
Python+Yolov8路面桥梁墙体裂缝识别:https://blog.csdn.net/alicema1111/article/details/133434445
Python+Yolov5道路障碍物识别:https://blog.csdn.net/alicema1111/article/details/129589741
Python+Yolov5跌倒检测 摔倒检测 人物目标行为 人体特征识别:https://blog.csdn.net/alicema1111/article/details/129272048

http://www.hkea.cn/news/184185/

相关文章:

  • 网站色彩搭配服务器ip域名解析
  • 哪个网站专业做安防如何注册域名网站
  • 穆棱市住房和城乡建设局网站关键词词库
  • 成都网站建设市场什么是网络营销的核心
  • 深圳找人做网站廊坊优化外包
  • 衡阳市城市建设投资有限公司网站湖南企业seo优化报价
  • css做网站常用百度权重优化软件
  • 合合肥网站建设制作网站用什么软件
  • 杭州网站设计公司推荐网络推广与优化
  • 移动惠生活app下载网址荆门网站seo
  • 做网站很赚钱吗关键词自助优化
  • wordpress小工具里的用户中心南京谷歌优化
  • 网站开发中茶叶网络营销策划方案
  • 临海市住房与城乡建设规划局 网站目前最新的营销模式有哪些
  • 高校建设网站的特色如何建立一个网站
  • 公司做网站域名归谁搜索引擎营销策划方案
  • 怎么做外贸个人网站seo综合查询工具可以查看哪些数据
  • 黑客网站盗qq百度seo公司整站优化
  • 网页设计代码不能运行seo的中文名是什么
  • 灵溪网站建设外贸网站谷歌seo
  • 网站开发系统设计产品推销
  • 不用代码做网站 知乎百度引流推广怎么收费
  • 怎么看网站后台什么语言做的产品全网营销推广
  • 可以做宣传图的网站网络销售管理条例
  • 做书籍封皮的网站制作网站平台
  • 1网站建设公司长沙网站到首页排名
  • 域名还在备案可以做网站吗seo培训班
  • 前程无忧网宁波网站建设类岗位北京网站快速排名优化
  • 如何优化网站内部链接站长工具站长之家
  • 阿里云网站建设的实训报告免费的自媒体一键发布平台