Advertisement
SwordPencil

Untitled

Nov 21st, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include "objectrotation.h"
  2.  
  3. GLfloat point[3] = {0, 0, 0};
  4. GLfloat trajectory[3] = {0, 0, 0};
  5. GLfloat angle = 0;
  6.  
  7. void display(void)
  8. {
  9.    
  10.     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  11.  
  12.    glMatrixMode(GL_MODELVIEW);
  13.    // Clear current projection matrix to identity.
  14.    glLoadIdentity();
  15.  
  16.    glutSwapBuffers();
  17. }
  18.  
  19. // Keyboard input processing routine.
  20. void keyInput(unsigned char key, int x, int y)
  21. {
  22.    switch(key)
  23.    {
  24.       // Press escape to exit.
  25.       case 27:
  26.          exit(0);
  27.          break;
  28.       default:
  29.          break;
  30.    }
  31. }
  32.  
  33. void ChangePosition(int)
  34. {
  35.     //glutPostRedisplay();
  36.     cout << "TOCHKA.\n";
  37.     for(int i = 0; i < 3; i++)
  38.     {
  39.         cout << "VVOD: ";
  40.         cin >> point[i];
  41.     }
  42.     cout << "\nVECTOR.\n";
  43.     for(int i = 0; i < 3; i++)
  44.     {
  45.         cout << "VVOD: ";
  46.         cin >> trajectory[i];
  47.     }
  48.     cout << "\nUGOL: ";
  49.     cin >> angle;
  50.  
  51.     glTranslatef(point[0], point[1], point[2]);
  52.     glRotatef(angle, trajectory[0], trajectory[1], trajectory[2]);
  53.     glTranslatef(-point[0], -point[1], -point[2]);
  54.  
  55.     glutTimerFunc(2, ChangePosition, 0);
  56. }
  57.  
  58. void main(int argc, char** argv)
  59. {
  60.     Object cube;
  61.     glutInit(&argc, argv);
  62.     glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
  63.     glutInitWindowPosition(0, 0);
  64.     glutInitWindowSize(700, 700);
  65.     glutCreateWindow("Try GLUI");
  66.     glutDisplayFunc(display);
  67.     glClearColor(1, 1, 1, 0);
  68.     glutDisplayFunc(cube.RenderObject);
  69.     glutTimerFunc(0.1, ChangePosition, 0);
  70.     glutMainLoop();
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement