转自:https://www.cnblogs.com/gucheng/p/10152889.html

准备第三方库 glew、freeglut、glm、opencv
准备一张灰度图
最终效果
代码如下
代码包括主程序源文件mainApp.cpp、顶点着色器shader.vs、片元着色器shader.fs

mainApp.cpp

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <sstream>
  6. #include <GL/glew.h>
  7. #include <GL/freeglut.h>
  8. #include <opencv2/core/core.hpp>
  9. #include <opencv2/highgui/highgui.hpp>
  10. #include <opencv2/imgproc/imgproc.hpp>
  11. #include <glm/glm.hpp>
  12. #include <glm/gtc/matrix_transform.hpp>
  13.  
  14. using namespace std;
  15. using namespace cv;
  16. using namespace glm;
  17.  
  18. //shader文件
  19. const char* vsShaderName = "shader.vs";//顶点着色器
  20. const char* fsShaderName = "shader.fs";//片元着色器
  21.  
  22. GLuint VBO;//顶点缓冲对象
  23. GLuint IBO;//索引缓冲对象
  24. GLuint UVBO;//uv缓冲对象
  25. GLuint TexBO;//贴图对象
  26. GLuint NormalBO;//法线对象
  27. //光照定义
  28. struct {
  29. GLuint Color;//颜色
  30. GLuint AmbientIntensity;//环境光强度
  31. GLuint Direction;//方向
  32. GLuint DiffuseIntensity;//漫反射强度
  33. } m_dirLightLocation;
  34. static GLfloat *vertices;
  35. static unsigned int *indices;
  36. static GLfloat *uvs;
  37. static GLfloat *normals;
  38.  
  39. GLuint ShaderProgram;
  40. GLuint MatrixID;
  41. GLuint MatrixID2;
  42. GLuint TextureID;
  43.  
  44. int windowWidth = ;
  45. int windowHeight = ;
  46. int imgWidth;
  47. int imgHeihgt;
  48. float verticeScale = 0.1f;
  49. float yScale = 5.0f;
  50. //相机参数
  51. glm::mat4 ViewMatrix;//视图矩阵
  52. glm::mat4 ProjectionMatrix; //投影矩阵
  53. glm::mat4 MVP;//模型视图矩阵
  54. glm::mat4 ModelMatrix;//模型矩阵
  55. glm::vec3 position = glm::vec3(, , ); //相机位置
  56. float horizontalAngle = 3.14f;
  57. float verticalAngle = 0.0f;
  58. float initialFoV = 45.0f; //相机视场角
  59. float speed = 0.05f; //平移速度
  60. float mouseSpeed = 0.005f;
  61. int mouseX, mouseY;//鼠标位置 窗口坐标
  62. bool mouseLeftDown = false;//鼠标左键按下
  63.  
  64. // 传递键盘事件
  65. static void SpecialKeyboardCB(unsigned char Key, int x, int y)
  66. {
  67. glm::vec3 direction(
  68. cos(verticalAngle) * sin(horizontalAngle),
  69. sin(verticalAngle),
  70. cos(verticalAngle) * cos(horizontalAngle)
  71. );
  72. glm::vec3 right = glm::vec3(
  73. sin(horizontalAngle - 3.14f / 2.0f),
  74. ,
  75. cos(horizontalAngle - 3.14f / 2.0f)
  76. );
  77. glm::vec3 up = glm::cross(right, direction);
  78.  
  79. switch (Key) {
  80. case 'w':
  81. position += direction * speed;
  82. //fprintf(stderr, "up \n");
  83. break;
  84. case 'd':
  85. position += right * speed;
  86. //fprintf(stderr, "right \n");
  87. break;
  88. case 's':
  89. position -= direction * speed;
  90. //fprintf(stderr, "down \n");
  91. break;
  92. case 'a':
  93. position -= right * speed;
  94. //fprintf(stderr, "left \n");
  95. break;
  96. case :
  97. exit();
  98. break;
  99. default:
  100. break;
  101. //fprintf(stderr, "Unimplemented GLUT key\n");
  102. //exit(1);
  103. }
  104.  
  105. float FoV = initialFoV;
  106. ProjectionMatrix = glm::perspective(glm::radians(FoV), (float)windowWidth / (float)windowHeight, 0.1f, 100.0f);
  107. ViewMatrix = glm::lookAt(
  108. position,
  109. position + direction,
  110. up
  111. );
  112. ModelMatrix = glm::mat4(1.0);
  113. MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;
  114. glutPostRedisplay();//设置窗口重绘
  115. }
  116.  
  117. //传递鼠标事件
  118. void mouseCB(int button, int state, int x, int y)
  119. {
  120. if (button == GLUT_LEFT_BUTTON)
  121. {
  122. if (state == GLUT_DOWN)
  123. {
  124. mouseLeftDown = true;
  125. mouseX = x;
  126. mouseY = y;
  127. }
  128. else if (state == GLUT_UP)
  129. {
  130. mouseLeftDown = false;
  131. }
  132. }
  133. }
  134.  
  135. //传递鼠标位置
  136. static void mouseMotionCB(int x, int y)
  137. {
  138. if (mouseLeftDown == true)
  139. {
  140. horizontalAngle += mouseSpeed * float(x - mouseX);
  141. verticalAngle += mouseSpeed * float(y - mouseY);
  142. mouseX = x;
  143. mouseY = y;
  144. SpecialKeyboardCB(, , );
  145. }
  146. }
  147.  
  148. //渲染回调函数
  149. void RenderScenceCB() {
  150. // 清空颜色缓存
  151. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br>    //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);//线框模式
  152. //传递矩阵数据
  153. glUniformMatrix4fv(MatrixID, , GL_FALSE, &MVP[][]);
  154. glUniformMatrix4fv(MatrixID2,, GL_FALSE,&ModelMatrix[][]);
  155. //传递光照
  156. glUniform3f(m_dirLightLocation.Color, , , );
  157. glUniform1f(m_dirLightLocation.AmbientIntensity, 0.5);
  158. glUniform3f(m_dirLightLocation.Direction,,,);
  159. glUniform1f(m_dirLightLocation.DiffuseIntensity,0.7);
  160. //传递顶点、索引、UV、法线
  161. glEnableVertexAttribArray(); //开启顶点属性
  162. glBindBuffer(GL_ARRAY_BUFFER, VBO); //绑定GL_ARRAY_BUFFER缓冲器
  163. glVertexAttribPointer(, , GL_FLOAT, GL_FALSE, , ); //告诉管线怎样解析bufer中的数据
  164. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
  165. glEnableVertexAttribArray();
  166. glBindBuffer(GL_ARRAY_BUFFER, UVBO);
  167. glVertexAttribPointer(, , GL_FLOAT, GL_FALSE, , );
  168. glEnableVertexAttribArray();
  169. glBindBuffer(GL_ARRAY_BUFFER, NormalBO);
  170. glVertexAttribPointer(, , GL_FLOAT, GL_FALSE, , );
  171. //传递贴图纹理
  172. glActiveTexture(GL_TEXTURE0);
  173. glBindTexture(GL_TEXTURE_2D, TexBO);
  174. glUniform1i(TextureID, );
  175. //绘制
  176. glDrawElements(GL_TRIANGLES_ADJACENCY, (imgWidth - )*(imgHeihgt - ) * * , GL_UNSIGNED_SHORT, );
  177. glDisableVertexAttribArray();
  178. glDisableVertexAttribArray();
  179. glDisableVertexAttribArray();
  180. //交换前后缓存
  181. glutSwapBuffers();
  182. }
  183.  
  184. //创建顶点
  185. static void CreateVertexBuffer()
  186. {
  187. //读取图片
  188. Mat img = imread("T2.png");
  189. int imgType = img.type();
  190. Mat resImg = Mat(img.rows, img.cols, imgType);
  191. resize(img, resImg, resImg.size(), , , INTER_LINEAR);
  192. Mat gImg = Mat(img.rows, img.cols, CV_8UC1); //灰度图
  193. cv::cvtColor(resImg, gImg, CV_BGR2GRAY);//bgr转灰度
  194. imgWidth = resImg.rows;
  195. imgHeihgt = resImg.cols;
  196. vertices = new GLfloat[imgWidth*imgHeihgt * ];
  197. int k = ;
  198. for (int i = ; i < imgHeihgt; i++)
  199. {
  200. for (int j = ; j < imgWidth; j++)
  201. {
  202. vertices[k++] = verticeScale* (float)i;
  203. int c = (int)gImg.at<uchar>(j, i);
  204. vertices[k++] = yScale*(float)c / 255.0f;
  205. vertices[k++] = verticeScale*(float)j;
  206. }
  207. }
  208. glGenBuffers(, &VBO);
  209. glBindBuffer(GL_ARRAY_BUFFER, VBO);
  210. glBufferData(GL_ARRAY_BUFFER, imgWidth*imgHeihgt * * sizeof(GLfloat), vertices, GL_STATIC_DRAW);
  211. }
  212. //创建索引
  213. static void CreateIndexBuffer()
  214. {
  215. indices = new unsigned int[(imgWidth - )*(imgHeihgt - ) * ];
  216. int k = ;
  217.  
  218. for (int i = ; i < imgHeihgt - ; i++)
  219. {
  220. for (int j = ; j < imgWidth - ; j++)
  221. {
  222. indices[k++] = i*imgWidth + j;
  223. indices[k++] = i*imgWidth + j + ;
  224. indices[k++] = i*imgWidth + j + imgWidth;
  225. indices[k++] = i*imgWidth + j + imgWidth;
  226. indices[k++] = i*imgWidth + j + ;
  227. indices[k++] = i*imgWidth + j + imgWidth + ;
  228. }
  229. }
  230. glGenBuffers(, &IBO);
  231. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
  232. glBufferData(GL_ELEMENT_ARRAY_BUFFER, (imgWidth - )*(imgHeihgt - ) * * sizeof(unsigned int), indices, GL_STATIC_DRAW);
  233.  
  234. }
  235. //创建uv
  236. static void CreateUVBuffer()
  237. {
  238. uvs = new GLfloat[imgWidth*imgHeihgt * ];
  239. int k = ;
  240. for (int i = ; i < imgHeihgt; i++)
  241. {
  242. for (int j = ; j < imgWidth; j++)
  243. {
  244. uvs[k++] = (float)i / (float)(imgHeihgt);
  245. uvs[k++] = (float)j / (float)(imgWidth);
  246. }
  247. }
  248. glGenBuffers(, &UVBO);
  249. glBindBuffer(GL_ARRAY_BUFFER, UVBO);
  250. glBufferData(GL_ARRAY_BUFFER, imgWidth*imgHeihgt * * sizeof(GLfloat), uvs, GL_STATIC_DRAW);
  251. }
  252.  
  253. //创建贴图
  254. static void CreateTexture()
  255. {
  256. Mat img = imread("T2.png");
  257. Mat resImg = Mat(, , img.type());
  258. resize(img, resImg, resImg.size(), , , INTER_LINEAR);
  259. cv::cvtColor(resImg, resImg, CV_BGR2RGB);
  260. glGenTextures(, &TexBO);
  261. glBindTexture(GL_TEXTURE_2D, TexBO);
  262. glTexImage2D(GL_TEXTURE_2D, , GL_RGB, , , , GL_RGB, GL_UNSIGNED_BYTE, resImg.data);//设定纹理
  263. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);//重复纹理
  264. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  265. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//滤波
  266. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  267. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, );
  268. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, );
  269. glGenerateMipmap(GL_TEXTURE_2D);
  270. glBindTexture(GL_TEXTURE_2D, );
  271. TextureID = glGetUniformLocation(ShaderProgram, "myTexture");
  272. }
  273.  
  274. //创建法线
  275. static void CreateNormal()
  276. {
  277. normals= new GLfloat[imgWidth*imgHeihgt*];
  278. int k = ;
  279. //遍历索引三角
  280. for (size_t i = ; i < (imgWidth - )*(imgHeihgt - ) * ; i+=)
  281. {
  282. static unsigned int pIndex1 = indices[i];
  283. static unsigned int pIndex2 = indices[i + ];
  284. static unsigned int pIndex3 = indices[i + ];
  285. static float x1 = vertices[pIndex1];
  286. static float y1 = vertices[pIndex1 + ];
  287. static float z1 = vertices[pIndex1 + ];
  288. static float x2 = vertices[pIndex2];
  289. static float y2 = vertices[pIndex2 + ];
  290. static float z2 = vertices[pIndex2 + ];
  291. static float x3 = vertices[pIndex3];
  292. static float y3 = vertices[pIndex3 + ];
  293. static float z3 = vertices[pIndex3 + ];
  294. //求边
  295. static float vx1 = x2 - x1;
  296. static float vy1 = y2 - y1;
  297. static float vz1 = z2 - z1;
  298. static float vx2 = x3 - x1;
  299. static float vy2 = y3 - y1;
  300. static float vz2 = z3 - z1;
  301. //叉乘求三角形法线
  302. static float xN = vy1 * vz2 - vz1 *vy2;
  303. static float yN = vz1 * vx2 - vx1 * vz2;
  304. static float zN = vx1 * vy2 - vy1 * vx2;
  305. static float Length = sqrtf(xN * xN + yN * yN + zN * zN);
  306. xN /= Length;
  307. yN /= Length;
  308. zN /= Length;
  309. //顶点法线更新
  310. normals[pIndex1] += xN;
  311. normals[pIndex1 + ] += yN;
  312. normals[pIndex1 + ] += zN;
  313. normals[pIndex2] += xN;
  314. normals[pIndex2 + ] += yN;
  315. normals[pIndex2 + ] += zN;
  316. normals[pIndex3] += xN;
  317. normals[pIndex3 + ] += yN;
  318. normals[pIndex3 + ] += zN;
  319. }
  320. glGenBuffers(, &NormalBO);
  321. glBindBuffer(GL_ARRAY_BUFFER, NormalBO);
  322. glBufferData(GL_ARRAY_BUFFER, imgWidth*imgHeihgt * * sizeof(GLfloat), normals, GL_STATIC_DRAW);
  323. }
  324.  
  325. // 使用shader文本编译shader对象,并绑定shader到着色器程序中
  326. static void AddShader(GLuint ShaderProgram, const char* pShaderText, GLenum ShaderType)
  327. {
  328. // 根据shader类型参数定义两个shader对象
  329. GLuint ShaderObj = glCreateShader(ShaderType);
  330. // 检查是否定义成功
  331. if (ShaderObj == ) {
  332. fprintf(stderr, "Error creating shader type %d\n", ShaderType);
  333. exit();
  334. }
  335. // 定义shader的代码源
  336. const GLchar* p[];
  337. p[] = pShaderText;
  338. GLint Lengths[];
  339. Lengths[] = strlen(pShaderText);
  340. glShaderSource(ShaderObj, , p, Lengths);
  341. glCompileShader(ShaderObj);// 编译shader对象
  342. // 检查和shader相关的错误
  343. GLint success;
  344. glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success);
  345. if (!success) {
  346. GLchar InfoLog[];
  347. glGetShaderInfoLog(ShaderObj, , NULL, InfoLog);
  348. fprintf(stderr, "Error compiling shader type %d: '%s'\n", ShaderType, InfoLog);
  349. exit();
  350. }
  351. // 将编译好的shader对象绑定到program object程序对象上
  352. glAttachShader(ShaderProgram, ShaderObj);
  353. }
  354.  
  355. // 编译着色器函数
  356. static void CompileShaders()
  357. {
  358. // 创建着色器程序
  359. ShaderProgram = glCreateProgram();
  360. // 检查是否创建成功
  361. if (ShaderProgram == ) {
  362. fprintf(stderr, "Error creating shader program\n");
  363. exit();
  364. }
  365. // 存储着色器文本的字符串
  366. string vs, fs;
  367. // 分别读取着色器文件中的文本到字符串
  368. std::ifstream VertexShaderStream(vsShaderName, std::ios::in);
  369. if (VertexShaderStream.is_open()) {
  370. std::stringstream sstr;
  371. sstr << VertexShaderStream.rdbuf();
  372. vs = sstr.str();
  373. VertexShaderStream.close();
  374. }
  375. else {
  376. printf("Error to open %s\n", vsShaderName);
  377. getchar();
  378. exit();
  379. }
  380. std::ifstream FragmentShaderStream(fsShaderName, std::ios::in);
  381. if (FragmentShaderStream.is_open()) {
  382. std::stringstream sstr;
  383. sstr << FragmentShaderStream.rdbuf();
  384. fs = sstr.str();
  385. FragmentShaderStream.close();
  386. }
  387.  
  388. // 添加顶点着色器和片段着色器
  389. AddShader(ShaderProgram, vs.c_str(), GL_VERTEX_SHADER);
  390. AddShader(ShaderProgram, fs.c_str(), GL_FRAGMENT_SHADER);
  391. // 链接shader着色器程序,并检查程序相关错误
  392. GLint Success = ;
  393. GLchar ErrorLog[] = { };
  394. glLinkProgram(ShaderProgram);
  395. glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &Success);
  396. if (Success == ) {
  397. glGetProgramInfoLog(ShaderProgram, sizeof(ErrorLog), NULL, ErrorLog);
  398. fprintf(stderr, "Error linking shader program: '%s'\n", ErrorLog);
  399. exit();
  400. }
  401. // 检查验证在当前的管线状态程序是否可以被执行
  402. glValidateProgram(ShaderProgram);
  403. glGetProgramiv(ShaderProgram, GL_VALIDATE_STATUS, &Success);
  404. if (!Success) {
  405. glGetProgramInfoLog(ShaderProgram, sizeof(ErrorLog), NULL, ErrorLog);
  406. fprintf(stderr, "Invalid shader program: '%s'\n", ErrorLog);
  407. exit();
  408. }
  409. glUseProgram(ShaderProgram);
  410. //统一变量位置
  411. MatrixID = glGetUniformLocation(ShaderProgram, "gWVP");
  412. MatrixID2= glGetUniformLocation(ShaderProgram, "gWorld");
  413. m_dirLightLocation.Color = glGetUniformLocation(ShaderProgram,"gDirectionalLight.Color");
  414. m_dirLightLocation.AmbientIntensity = glGetUniformLocation(ShaderProgram,"gDirectionalLight.AmbientIntensity");
  415. m_dirLightLocation.Direction = glGetUniformLocation(ShaderProgram,"gDirectionalLight.Direction");
  416. m_dirLightLocation.DiffuseIntensity = glGetUniformLocation(ShaderProgram,"gDirectionalLight.DiffuseIntensity");
  417. }
  418.  
  419. int main(int argc, char ** argv) {
  420. // 初始化GLUT
  421. glutInit(&argc, argv);
  422. // 显示模式:双缓冲、RGBA
  423. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
  424. // 窗口设置
  425. glutInitWindowSize(windowWidth, windowHeight); // 窗口尺寸
  426. glutInitWindowPosition(, ); // 窗口位置
  427. glutCreateWindow("terrainTest2"); // 窗口标题
  428.  
  429. GLenum res = glewInit();
  430. if (res != GLEW_OK) {
  431. fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
  432. return ;
  433. }
  434.  
  435. // 开始渲染
  436. glutDisplayFunc(RenderScenceCB);
  437. // 注册键盘事件
  438. glutKeyboardFunc(SpecialKeyboardCB);
  439. //注册鼠标事件
  440. glutMouseFunc(mouseCB);
  441. glutMotionFunc(mouseMotionCB);
  442. mouseX = windowWidth / ;
  443. mouseY = windowHeight / ;
  444. // 缓存清空后的颜色值
  445. glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  446. //创建顶点
  447. CreateVertexBuffer();
  448. //创建索引
  449. CreateIndexBuffer();
  450. //创建uv
  451. CreateUVBuffer();
  452. //创建贴图
  453. CreateTexture();
  454. //创建法线
  455. CreateNormal();
  456. // 编译着色器
  457. CompileShaders();
  458. //开启深度测试
  459. glEnable(GL_DEPTH_TEST);
  460. // 通知开始GLUT的内部循环
  461. glutMainLoop();
  462. delete vertices;
  463. return ;
  464. }

shader.vs

  1. #version
  2. layout (location = ) in vec3 Position;
  3. layout (location = ) in vec2 vertexUV;
  4. layout (location = ) in vec3 Normal;
  5. uniform mat4 gWVP;
  6. uniform mat4 gWorld;
  7. out vec2 UV;
  8. out vec3 Normal0;
  9. void main()
  10. {
  11. gl_Position = gWVP * vec4(Position, 1.0);
  12. UV = vertexUV;
  13. Normal0 = (gWorld * vec4(Normal, 0.0)).xyz;
  14. }

shader.fs

  1. #version
  2. in vec2 UV;
  3. in vec3 Normal0;
  4. out vec4 FragColor;
  5. //光照
  6. struct DirectionalLight
  7. {
  8. vec3 Color;
  9. float AmbientIntensity;
  10. float DiffuseIntensity;
  11. vec3 Direction;
  12. };
  13. uniform DirectionalLight gDirectionalLight;
  14. uniform sampler2D myTexture;
  15. void main()
  16. {
  17. //环境光
  18. vec4 AmbientColor = vec4(gDirectionalLight.Color, 1.0f) *
  19. gDirectionalLight.AmbientIntensity;
  20. //漫反射
  21. float DiffuseFactor = dot(normalize(Normal0), -gDirectionalLight.Direction);
  22. vec4 DiffuseColor;
  23. if (DiffuseFactor > ) {
  24. DiffuseColor = vec4(gDirectionalLight.Color, 1.0f) *
  25. gDirectionalLight.DiffuseIntensity *
  26. DiffuseFactor;
  27. }
  28. else {
  29. DiffuseColor = vec4(, , , );
  30. }
  31. FragColor = texture2D(myTexture, UV.xy) *
  32. (AmbientColor + DiffuseColor);
  33.  
  34. }

opengl读取灰度图生成三维地形并添加光照的更多相关文章

  1. opengl读取灰度图生成三维地形

    准备第三方库 glew.freeglut.glm.opencv 准备灰度图片和草地贴图 最终效果 代码包括主程序源文件mainApp.cpp.顶点着色器shader.vs.片元着色器shader.fs ...

  2. unity读取灰度图生成三维地形mesh

    准备灰度图 IGray.png及草地贴图 IGrass.jpg ,放入Assets下StreamingAssets文件夹中.     创建空材质,用作参数传入脚本.   脚本如下,挂载并传入材质球即可 ...

  3. ue4读取灰度图生成三维地形mesh

    转自:https://www.cnblogs.com/gucheng/p/10116857.html 新建ue c++工程. 在Build.cs中添加"ProceduralMeshCompo ...

  4. unity 读取灰度图生成三维地形并贴图卫星影像

    从 https://earthexplorer.usgs.gov/ 下载高程数据 从谷歌地球上保存对应地区卫星图像 从灰度图创建地形模型,并将卫星影像作为贴图 using System.Collect ...

  5. unity 读取灰度图生成按高程分层设色地形模型

    准备灰度图 1.高程按比例对应hue色相(hsv)生成mesh效果 o.color = float4(hsv2rgb(float3(v.vertex.y/100.0, 0.5, 0.75)), 1.0 ...

  6. unity读取灰度图生成等值线图

    准备灰度图 grayTest.png,放置于Assets下StreamingAssets文件夹中.   在场景中添加RawImage用于显示最后的等值线图.   生成等值线的过程,使用Marching ...

  7. blender导入灰度图生成地形模型

    安装软件 在此处下载blender并安装. 添加平面 1.打开blender,右键删除初始的立方体. 2.shift+a选择平面添加进场景: 3.按下s键鼠标拖动调节平面大小确定后按下鼠标左键: 4. ...

  8. (二)GameMaker:Studio ——使用等高图生成3D地形

    上一篇,我们讲解了GM中导入模型的方法,这节我们来讲地形. 源文件地址:http://pan.baidu.com/share/link?shareid=685772423&uk=2466343 ...

  9. c语言实现灰度图转换为二值图

    将上篇得到的灰度图转换为二值图,读取像素数据,低于某一值置0,否则设置为255,为得到更好的效果不同图片应采用不同的值 /* 2015年6月2日11:16:22 灰度图转换为二值图 blog:http ...

随机推荐

  1. mysql类似to_char()to_date()函数mysql日期和字符相互转换方法date_f

    mysql 类似to_char() to_date()函数mysql日期和字符相互转换方法 date_format(date,'%Y-%m-%d') -------------->oracle中 ...

  2. 项目Alpha冲刺--8/10

    项目Alpha冲刺--8/10 作业要求 这个作业属于哪个课程 软件工程1916-W(福州大学) 这个作业要求在哪里 项目Alpha冲刺 团队名称 基于云的胜利冲锋队 项目名称 云评:高校学生成绩综合 ...

  3. DT系统研究之-自定义新建函数

    说说在destoon中,我们二次开发时新建的函数应该放哪里好? 发现部分同学,在学习研究destoon过程中,新建的一些php函数直接放在模块里面,须知这样放置的话,会产生些不良后果. 首先,新建的该 ...

  4. test20190926 孙耀峰

    70+100+0=170.结论题自己还是要多试几组小数据.这套题还不错. ZYB建围墙 ZYB之国是特殊的六边形构造. 已知王国一共有

  5. 四行公式推完神经网络BP

    据说多推推公式可以防止老年痴呆,(●ˇ∀ˇ●) 偶尔翻到我N年前第一次推导神经网络的博客居然四页纸,感慨毅力! http://blog.sina.com.cn/s/blog_1442877660102 ...

  6. c++读写matlab中.mat数据

    前言:在进行图形图像处理时,经常会用到matlab进行算法的仿真验证,然后再移植到别的语言中.有时会涉及到数据的交互,比如直接读取matlab的.mat类型数据,或者是将c++中的数组存为.mat,为 ...

  7. 将idea中xml文件背景颜色去除(转)

    原贴链接:https://blog.csdn.net/weixin_43215250/article/details/89403678 第一步:除去SQL代码块的背景颜色,步骤如下 设置后还是很影响视 ...

  8. 使用vue+mintui 开发省市区功能

    做移动端的都知道 经常会有省市区这种三级联动的功能 今天研究了一下午~ 1.准备工作 vue+mintui+省市区的json数据 下载地址:https://github.com/chzm/addres ...

  9. 2-STM32+W5500+GPRS(2G)基础篇-(W5500-学习说明)

    https://www.cnblogs.com/yangfengwu/p/11220042.html 定版: 这一节先直接说明怎么把官方的源码应用在我做的这块开发板上 https://www.w550 ...

  10. Codevs 3122 奶牛代理商 VIII(状压DP)

    3122 奶牛代理商 VIII 时间限制: 3 s 空间限制: 256000 KB 题目等级 : 大师 Master 题目描述 Description 小徐是USACO中国区的奶牛代理商,专门出售质优 ...