Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.72 KB | None | 0 0
  1. #define GL_SILENCE_DEPRECATION //эпл не любит опенгл :с
  2. #include <GLFW/glfw3.h>
  3. #include <stdlib.h> //needed for exit function
  4. #include <iostream>
  5. #include <stdio.h>
  6. #include <cmath>
  7.  
  8. struct circleData {
  9. int pointsAmount = 6;
  10. float** pointData;
  11. };
  12.  
  13. struct point {
  14. float xx;
  15. float yy;
  16. float zz;
  17. };
  18.  
  19. struct line {
  20. float xx1;
  21. float yy1;
  22. float zz1;
  23. float xx2;
  24. float yy2;
  25. float zz2;
  26. };
  27.  
  28. void keyboard_callback(GLFWwindow *window, int key, int scancode, int action, int mods);
  29. void drawCylinder(float cylinderHeight, circleData circle, float cylinderRadius, circleData *massOfCircles);
  30. void mouseButtonCallback( GLFWwindow *window, int button, int action, int mods);
  31. void dimetria();
  32. circleData* init(float cylinderHeight, circleData circle, float cylinderRadius);
  33. void cyrus_back(line mainLine, circleData *massOfCircles);
  34.  
  35. int rotate_y = 0;
  36. int rotate_x = 0;
  37. int rotate_z = 0;
  38.  
  39. float trans_x = 0;
  40. float trans_y = 0;
  41. float trans_z = 0;
  42.  
  43. float sc_x = 0.5;
  44. float sc_y = 0.5;
  45. float sc_z = 0.5;
  46.  
  47. int circlesAmount = 3;
  48.  
  49. float fi = (asin(0.625/sqrt(2.0-0.625*0.625))); //62,82
  50. float teta = (asin(0.625/sqrt(2.0))); //41,6
  51.  
  52. bool cyrus = false;
  53.  
  54. GLfloat m[16] = { cos(fi), sin(fi)*sin(teta), sin(fi)*cos(teta), 0,
  55. 0, cos(teta), -sin(teta), 0,
  56. sin(fi), -cos(fi)*sin(teta), -cos(fi)*cos(teta), 0,
  57. 0, 0, 0, 1
  58. }; //как получилась матрица расписать два поворота по х, у
  59.  
  60.  
  61. circleData circle;
  62. circleData *mass;
  63. circleData *massOfCircles;
  64. line mainLine;
  65. point p1;
  66. point p2;
  67.  
  68. int main(int argc, char const *argv[]) {
  69.  
  70. if(!glfwInit()) {
  71. exit(EXIT_FAILURE);
  72. }
  73.  
  74. //glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
  75.  
  76. GLFWwindow *window = glfwCreateWindow(620, 620, "Rorate Cube", NULL, NULL);
  77.  
  78. if (!window) {
  79. glfwTerminate();
  80. exit(EXIT_FAILURE);
  81. }
  82. glfwSetMouseButtonCallback(window, mouseButtonCallback);
  83. glfwMakeContextCurrent(window);
  84. glfwSwapInterval(1);
  85.  
  86. glEnable(GL_DEPTH_TEST);
  87.  
  88. mass = init(1.0, circle, 0.5);
  89.  
  90. mainLine.xx1 = -1.0; //0.4, -0.4, -0.4
  91. mainLine.yy1 = -0.2;
  92. mainLine.zz1 = -0.9;
  93. mainLine.xx2 = 0.9; //0.4, 0.4, -0.4
  94. mainLine.yy2 = 0.6;
  95. mainLine.zz2 = 0.5;
  96.  
  97. cyrus_back(mainLine, mass);
  98.  
  99. while (!glfwWindowShouldClose(window))
  100. {
  101. float ratio;
  102. int width, height;
  103. glfwGetFramebufferSize(window, &width, &height);
  104. ratio = width / (float) height;
  105. glViewport(0, 0, width, height);
  106.  
  107. glfwSetKeyCallback(window, keyboard_callback);
  108.  
  109. glClearColor(0, 0, 0, 0);
  110. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  111.  
  112. glLoadIdentity();
  113. glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
  114. //вращение
  115.  
  116. glTranslatef(0.0, 0.0, 0.0);
  117.  
  118. glScalef(sc_x, sc_y, sc_z);
  119.  
  120. glRotatef(rotate_x, 1.0, 0.0, 0.0); //повороты подломаны???
  121. glRotatef(rotate_y, 0.0, 1.0, 0.0);
  122. glRotatef(rotate_z, 0.0, 0.0, 1.0);
  123.  
  124. //drawLine();
  125. //drawCylinder(1.0, circle, 0.2, mass);
  126.  
  127. glLineWidth(2);
  128. glColor3f(0.9,0.6, 0.3);
  129. glBegin(GL_LINES);
  130. glVertex3f(0,0,0);
  131. glVertex3f(0.7, 0.0, 0.0);
  132. glEnd();
  133. glBegin(GL_LINES);
  134. glVertex3f(0,0,0);
  135. glVertex3f(0, 0.7, 0);
  136. glEnd();
  137. glBegin(GL_LINES);
  138. glVertex3f(0,0,0);
  139. glVertex3f(0, 0, 0.7);
  140. glEnd();
  141.  
  142. glTranslatef(trans_x, trans_y, trans_z);
  143. glTranslatef(0.0, 0.0, 0.0);
  144. glLineWidth(4);
  145.  
  146. if (!cyrus) {
  147. glBegin(GL_LINES); // red side - FRONT
  148. glColor3f(1.0, 0.0, 0.0);
  149. glVertex3f( mainLine.xx1, mainLine.yy1, mainLine.zz1);
  150. glVertex3f( mainLine.xx2, mainLine.yy2, mainLine.zz2);
  151. glEnd();
  152. } else
  153. if (cyrus) {
  154. //glTranslatef(-0.4, -0.1, -0.2);
  155. glTranslatef(0.0, 0.0, 0.0);
  156. glBegin(GL_LINES); // red side - FRONT
  157. glColor3f(0.0, 0.0, 1.0);
  158. glVertex3f( p1.xx, p1.yy, p1.zz);
  159. glVertex3f( p2.xx, p2.yy, p2.zz);
  160. glEnd();
  161. }
  162.  
  163. //dimetria(); //проекция через повороты/ротейты
  164. //glMultMatrixf(m);
  165. glLoadIdentity();
  166. glScalef(sc_x, sc_y, sc_z);
  167.  
  168. glRotatef(rotate_x, 1.0, 0.0, 0.0); //повороты подломаны???
  169. glRotatef(rotate_y, 0.0, 1.0, 0.0);
  170. glRotatef(rotate_z, 0.0, 0.0, 1.0);
  171.  
  172. glTranslatef(trans_x, trans_y, trans_z);
  173.  
  174. //drawCube();*/
  175. glTranslatef(0.0, 0.0, 0.0);
  176. drawCylinder(1.0, circle, 0.5, mass);
  177.  
  178.  
  179.  
  180.  
  181.  
  182. glfwSwapBuffers(window);
  183. glfwPollEvents();
  184. }
  185.  
  186. glfwTerminate();
  187. return 0;
  188. }
  189.  
  190. void cyrus_back(line mainLine,circleData *massOfCircles) {
  191. int k = circle.pointsAmount + 2; //8
  192. float x1, x2, x3, y1, y2, y3, z1, z2, z3;
  193. point normals[k];
  194. point f[k]; //точка, лежащая на i-ой плоскости
  195. point w[k];
  196. float d_scalar;
  197. float w_scalar;
  198. float t_down = 0;
  199. float t_up = 1;
  200. float t;
  201. float A,B,C;
  202.  
  203. point directr;
  204. directr.xx = mainLine.xx2 - mainLine.xx1;
  205. directr.yy = mainLine.yy2 - mainLine.yy1;
  206. directr.zz = mainLine.zz2 - mainLine.zz1;
  207.  
  208. //нормали боковых граней
  209. for (int i=0; i<k-2; i++) {
  210. x1 = massOfCircles[0].pointData[i][0];
  211. y1 = massOfCircles[0].pointData[i][1];
  212. z1 = massOfCircles[0].pointData[i][2];
  213.  
  214. x2 = massOfCircles[0].pointData[i+1][0];
  215. y2 = massOfCircles[0].pointData[i+1][1];
  216. z2 = massOfCircles[0].pointData[i+1][2];
  217.  
  218. x3 = massOfCircles[circlesAmount-1].pointData[i][0];
  219. y3 = massOfCircles[circlesAmount-1].pointData[i][1];
  220. z3 = massOfCircles[circlesAmount-1].pointData[i][2];
  221.  
  222. A = y1*(z2-z3) + y2*(z3-z1) + y3*(z1-z2);
  223. B = z1*(x2-x3) + z2*(x3-x1) + z3*(x1-x2);
  224. C = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
  225.  
  226. normals[i].xx = A/(sqrt(A*A + B*B + C*C));
  227. normals[i].yy = B/(sqrt(A*A + B*B + C*C));
  228. normals[i].zz = C/(sqrt(A*A + B*B + C*C));
  229.  
  230. f[i].xx = x1;
  231. f[i].yy = y1;
  232. f[i].zz = z1;
  233. }
  234. //нормаль дна
  235. x1 = massOfCircles[0].pointData[0][0];
  236. y1 = massOfCircles[0].pointData[0][1];
  237. z1 = massOfCircles[0].pointData[0][2];
  238.  
  239. x2 = massOfCircles[0].pointData[1][0];
  240. y2 = massOfCircles[0].pointData[1][1];
  241. z2 = massOfCircles[0].pointData[1][2];
  242.  
  243. x3 = massOfCircles[0].pointData[2][0];
  244. y3 = massOfCircles[0].pointData[2][1];
  245. z3 = massOfCircles[0].pointData[2][2];
  246.  
  247. A = y1*(z2-z3) + y2*(z3-z1) + y3*(z1-z2);
  248. B = z1*(x2-x3) + z2*(x3-x1) + z3*(x1-x2);
  249. C = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
  250.  
  251. normals[k-2].xx = A/(sqrt(A*A + B*B + C*C));
  252. normals[k-2].yy = B/(sqrt(A*A + B*B + C*C));
  253. normals[k-2].zz = C/(sqrt(A*A + B*B + C*C));
  254.  
  255. f[k-2].xx = x1;
  256. f[k-2].yy = y1;
  257. f[k-2].zz = z1;
  258. //нормаль крышки
  259. x1 = massOfCircles[circlesAmount-1].pointData[0][0];
  260. y1 = massOfCircles[circlesAmount-1].pointData[0][1];
  261. z1 = massOfCircles[circlesAmount-1].pointData[0][2];
  262.  
  263. x2 = massOfCircles[circlesAmount-1].pointData[1][0];
  264. y2 = massOfCircles[circlesAmount-1].pointData[1][1];
  265. z2 = massOfCircles[circlesAmount-1].pointData[1][2];
  266.  
  267. x3 = massOfCircles[circlesAmount-1].pointData[2][0];
  268. y3 = massOfCircles[circlesAmount-1].pointData[2][1];
  269. z3 = massOfCircles[circlesAmount-1].pointData[2][2];
  270.  
  271. A = y1*(z2-z3) + y2*(z3-z1) + y3*(z1-z2);
  272. B = z1*(x2-x3) + z2*(x3-x1) + z3*(x1-x2);
  273. C = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
  274.  
  275. normals[k-1].xx = A/(sqrt(A*A + B*B + C*C));
  276. normals[k-1].yy = B/(sqrt(A*A + B*B + C*C));
  277. normals[k-1].zz = C/(sqrt(A*A + B*B + C*C));
  278.  
  279. f[k-1].xx = x1;
  280. f[k-1].yy = y1;
  281. f[k-1].zz = z1;
  282. //нормали посчитаны //граничные точки плоскостей записаны
  283.  
  284. //началось веселье
  285. for (int i=1; i<k; i++) {
  286. w[i].xx = mainLine.xx1 - f[i].xx;
  287. w[i].yy = mainLine.yy1 - f[i].yy;
  288. w[i].zz = mainLine.zz1 - f[i].zz;
  289. //скалярное произв (directr, n[i])
  290. d_scalar = directr.xx * normals[i].xx + directr.yy * normals[i].yy + directr.zz * normals[i].zz;
  291. //скалярное произв (w[i], n[i])
  292. w_scalar = w[i].xx * normals[i].xx + w[i].yy * normals[i].yy + w[i].zz * normals[i].zz ;
  293.  
  294. if (d_scalar == 0) {
  295. if (w_scalar < 0) continue;
  296. continue;
  297. }
  298. t = -w_scalar/d_scalar;
  299. std::cout << "t = " << t << std::endl;
  300. if (d_scalar > 0) {
  301. if (t <= 1) t_down = fmax(t, t_down);
  302. //continue;
  303. }
  304. if (d_scalar < 0) {
  305. if (t >= 0) t_up = fmin(t, t_up);
  306. //std::cout << t << " " << t_up << std::endl;
  307.  
  308. //std::cout << "------- " << t_up << std::endl;
  309. }
  310. /*if (d_scalar == 0) {
  311. if (w_scalar < 0) break;
  312. else continue;
  313. } else {
  314. t=-w_scalar/d_scalar;
  315. if (d_scalar > 0) {
  316. if (t>1) {
  317. break;
  318. } else {
  319. t_down=fmax(t_down, t);
  320. }
  321. } else {
  322. if (t<0) {
  323. break;
  324. } else {
  325. t_up=fmin(t_up, t);
  326. }
  327. }
  328. } */
  329. }
  330.  
  331. p1.xx = mainLine.xx1 + (mainLine.xx2 - mainLine.xx1)*t_down;
  332. p1.yy = mainLine.yy1 + (mainLine.yy2 - mainLine.yy1)*t_down;
  333. p1.zz = mainLine.zz1 + (mainLine.zz2 - mainLine.zz1)*t_down;
  334.  
  335. p2.xx = mainLine.xx1 + (mainLine.xx2 - mainLine.xx1)*t_up;
  336. p2.yy = mainLine.yy1 + (mainLine.yy2 - mainLine.yy1)*t_up;
  337. p2.zz = mainLine.zz1 + (mainLine.zz2 - mainLine.zz1)*t_up;
  338.  
  339. std::cout << p1.xx << " " << p1.yy << " " << p1.zz << std::endl;
  340. std::cout << p2.xx << " " << p2.yy << " " << p2.zz << std::endl;
  341.  
  342. }
  343.  
  344. circleData* init(float cylinderHeight, circleData circle, float cylinderRadius) {
  345.  
  346. circleData *massOfCircles = new circleData[circlesAmount]; //массив из 4 элементов, каждый из которых содержит кол-во точек 1 кольца и координаты хуz каждой точки
  347.  
  348. for (int ii=0; ii<circlesAmount; ii++) {
  349. massOfCircles[ii].pointData = new float*[circle.pointsAmount];
  350. for (int i=0; i<circle.pointsAmount; i++)
  351. massOfCircles[ii].pointData[i] = new float[3];
  352. }
  353.  
  354.  
  355. float dh = cylinderHeight / circlesAmount;
  356. float dy = 0.0;
  357. for(int j=0; j<circlesAmount; j++) {
  358.  
  359. for(int i=0; i<circle.pointsAmount; i++) { //пробег по точкам j-го круга
  360. float degInRad = ((3.14159*2)*i)/circle.pointsAmount;
  361. massOfCircles[j].pointData[i][0] = cos(degInRad)*cylinderRadius;
  362. massOfCircles[j].pointData[i][1] = dy+dh-0.6;
  363. massOfCircles[j].pointData[i][2] = sin(degInRad)*cylinderRadius;
  364. // std::cout << massOfCircles[j].pointData[i][0] << std::endl;
  365. // std::cout << massOfCircles[j].pointData[i][1] << std::endl;
  366. // std::cout << massOfCircles[j].pointData[i][2] << std::endl;
  367. }
  368. dy += dh;
  369. }
  370. return massOfCircles;
  371. }
  372.  
  373. void dimetria() {
  374.  
  375. //glRotatef(180.0, 0.0, 1.0, 0.0);
  376. glRotatef(-fi*(180/3.14) , 1.0, 0.0, 0.0);
  377. glRotatef(-teta*(180/3.14) , 0.0, 1.0, 0.0);
  378. //glRotatef(180.0 , 0.0, 1.0, 0.0);
  379. }
  380.  
  381. void drawCylinder(float cylinderHeight, circleData circle, float cylinderRadius, circleData *massOfCircles) {
  382. float dh = cylinderHeight / circlesAmount;
  383. float dy = 0.0;
  384. for(int j=0; j<circlesAmount; j++) {
  385. glBegin(GL_POLYGON);
  386. for(int i=0; i<circle.pointsAmount; i++) { //пробег по точкам j-го круга
  387. glColor3f(0.3, 0.0, 0.7);
  388. glVertex3f(massOfCircles[j].pointData[i][0], massOfCircles[j].pointData[i][1], massOfCircles[j].pointData[i][2]);
  389. }
  390. glEnd();
  391. dy += dh;
  392.  
  393. }
  394.  
  395. for (int j=0; j<circlesAmount-1; j++) {
  396. for (int i=0; i<circle.pointsAmount-1; i++) {
  397. glBegin(GL_POLYGON);
  398. glColor3f(0.3, 0.0, 0.7);
  399. glVertex3f(massOfCircles[j].pointData[i][0], massOfCircles[j].pointData[i][1], massOfCircles[j].pointData[i][2]);
  400. glVertex3f(massOfCircles[j].pointData[i+1][0], massOfCircles[j].pointData[i+1][1], massOfCircles[j].pointData[i+1][2]);
  401. glVertex3f(massOfCircles[j+1].pointData[i][0], massOfCircles[j+1].pointData[i][1], massOfCircles[j+1].pointData[i][2]);
  402. glEnd();
  403.  
  404. glBegin(GL_POLYGON);
  405. glColor3f(0.04, 0.14, 0.6);
  406. glVertex3f(massOfCircles[j].pointData[i+1][0], massOfCircles[j].pointData[i+1][1], massOfCircles[j].pointData[i+1][2]);
  407. glVertex3f(massOfCircles[j+1].pointData[i][0], massOfCircles[j+1].pointData[i][1], massOfCircles[j+1].pointData[i][2]);
  408. glVertex3f(massOfCircles[j+1].pointData[i+1][0], massOfCircles[j+1].pointData[i+1][1], massOfCircles[j+1].pointData[i+1][2]);
  409. glEnd();
  410. }
  411. }
  412. for (int j=0; j<circlesAmount-1; j++) {
  413. glBegin(GL_POLYGON);
  414. glColor3f(0.3, 0.0, 0.7);
  415. glVertex3f(massOfCircles[j].pointData[circle.pointsAmount-1][0], massOfCircles[j].pointData[circle.pointsAmount-1][1], massOfCircles[j].pointData[circle.pointsAmount-1][2]);
  416. glVertex3f(massOfCircles[j].pointData[0][0], massOfCircles[j].pointData[0][1], massOfCircles[j].pointData[0][2]);
  417. glVertex3f(massOfCircles[j+1].pointData[circle.pointsAmount-1][0], massOfCircles[j+1].pointData[circle.pointsAmount-1][1], massOfCircles[j+1].pointData[circle.pointsAmount-1][2]);
  418. glEnd();
  419.  
  420. glBegin(GL_POLYGON);
  421. glColor3f(0.04, 0.14, 0.6);
  422. glVertex3f(massOfCircles[j].pointData[0][0], massOfCircles[j].pointData[0][1], massOfCircles[j].pointData[0][2]);
  423. glVertex3f(massOfCircles[j+1].pointData[circle.pointsAmount-1][0], massOfCircles[j+1].pointData[circle.pointsAmount-1][1], massOfCircles[j+1].pointData[circle.pointsAmount-1][2]);
  424. glVertex3f(massOfCircles[j+1].pointData[0][0], massOfCircles[j+1].pointData[0][1], massOfCircles[j+1].pointData[0][2]);
  425. glEnd();
  426. }
  427. /* for (int j=0; j<circlesAmount-1; j++) {
  428. glBegin(GL_POLYGON);
  429. glColor3f(0.3, 0.0, 0.7);
  430. glVertex3f(massOfCircles[j].pointData[0][0], massOfCircles[j].pointData[0][1], massOfCircles[j].pointData[0][2]);
  431. glVertex3f(massOfCircles[j].pointData[circle.pointsAmount-1][0], massOfCircles[j].pointData[circle.pointsAmount-1][1], massOfCircles[j].pointData[circle.pointsAmount-1][2]);
  432. glVertex3f(massOfCircles[j+1].pointData[0][0], massOfCircles[j+1].pointData[0][1], massOfCircles[j+1].pointData[0][2]);
  433. glEnd();
  434.  
  435. glBegin(GL_POLYGON);
  436. glColor3f(0.04, 0.14, 0.6);
  437. glVertex3f(massOfCircles[j].pointData[circle.pointsAmount-1][0], massOfCircles[j].pointData[circle.pointsAmount-1][1], massOfCircles[j].pointData[circle.pointsAmount-1][2]);
  438. glVertex3f(massOfCircles[j+1].pointData[0][0], massOfCircles[j+1].pointData[0][1], massOfCircles[j+1].pointData[0][2]);
  439. glVertex3f(massOfCircles[j+1].pointData[circle.pointsAmount-1][0], massOfCircles[j+1].pointData[circle.pointsAmount-1][1], massOfCircles[j+1].pointData[circle.pointsAmount-1][2]);
  440. glEnd();
  441. }*/
  442. }
  443.  
  444. void keyboard_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
  445.  
  446. if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
  447. glfwSetWindowShouldClose(window, GL_TRUE);
  448.  
  449. if (key == GLFW_KEY_UP && action == GLFW_PRESS)
  450. rotate_x += 5;
  451. if (key == GLFW_KEY_DOWN && action == GLFW_PRESS)
  452. rotate_x -= 5;
  453. if (key == GLFW_KEY_RIGHT && action == GLFW_PRESS)
  454. rotate_y -= 5;
  455. if (key == GLFW_KEY_LEFT && action == GLFW_PRESS)
  456. rotate_y += 5;
  457. if (key == GLFW_KEY_O && action == GLFW_PRESS)
  458. rotate_z -= 5;
  459. if (key == GLFW_KEY_L && action == GLFW_PRESS)
  460. rotate_z += 5;
  461.  
  462. if (key == GLFW_KEY_W && action == GLFW_PRESS)
  463. trans_y += 0.05;
  464. if (key == GLFW_KEY_A && action == GLFW_PRESS)
  465. trans_x -= 0.05;
  466. if (key == GLFW_KEY_D && action == GLFW_PRESS)
  467. trans_x += 0.05;
  468. if (key == GLFW_KEY_S && action == GLFW_PRESS)
  469. trans_y -= 0.05;
  470. //
  471. if (key == GLFW_KEY_Z && action == GLFW_PRESS)
  472. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  473. if (key == GLFW_KEY_X && action == GLFW_PRESS)
  474. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  475. //
  476. if (key == GLFW_KEY_C && action == GLFW_PRESS){
  477. circle.pointsAmount++;
  478.  
  479. mass = init(1.0, circle, 0.5);
  480. }
  481. if (key == GLFW_KEY_V && action == GLFW_PRESS){
  482.  
  483. circle.pointsAmount--;
  484.  
  485. mass = init(1.0, circle, 0.5);
  486.  
  487. }
  488. if (key == GLFW_KEY_B && action == GLFW_PRESS){
  489. circlesAmount++;
  490.  
  491. mass = init(1.0, circle, 0.5);
  492.  
  493.  
  494. }
  495. if (key == GLFW_KEY_N && action == GLFW_PRESS){
  496. circlesAmount--;
  497.  
  498. mass = init(1.0, circle, 0.5);
  499. }
  500. if (key == GLFW_KEY_F && action == GLFW_PRESS){
  501. //cyrus_back(mainLine);
  502. cyrus = true;
  503. }
  504. if (key == GLFW_KEY_G && action == GLFW_PRESS){
  505. //cyrus_back(mainLine);
  506. cyrus = false;
  507. }
  508. }
  509.  
  510. void mouseButtonCallback( GLFWwindow *window, int button, int action, int mods) {
  511. if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) {
  512. std::cout << fi << std::endl;
  513. sc_x += 0.2;
  514. sc_y += 0.2;
  515. //sc_z += 0.2;
  516. }
  517.  
  518. if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
  519. if (sc_x > 0.2 && sc_y > 0.2) {
  520. std::cout << teta << std::endl;
  521. sc_x -= 0.2;
  522. sc_y -= 0.2;
  523. //sc_z -= 0.2;
  524. }
  525. }
  526. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement