Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.57 KB | None | 0 0
  1. #include <GL/gl.h>
  2. #include <GL/glu.h>
  3. #include <GL/glut.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <cstdlib>
  7.  
  8. int VELOCIDADE_MAX = 40;
  9. int a = 0 ;
  10.  float k = -1.0;
  11.  
  12.  
  13.  /** mota variaveis **/
  14.  int d = 0;
  15. float b = -1 ;
  16. int c = 0 ;
  17. int bolaavir = 3;
  18. float x = 0,y= 0,z=-1 ;
  19. int trans = 3.0 ;
  20. int flag =1;
  21. int vetor[4];
  22. float pos[4];
  23.  
  24.  
  25.  
  26.  
  27.  
  28. /*  Create checkerboard texture  */
  29. #define checkImageWidth 64
  30. #define checkImageHeight 64
  31. static GLubyte checkImage[checkImageHeight][checkImageWidth][4];
  32.  
  33. static GLuint texName;
  34.  
  35. float mov1, mov2;
  36. float t1=0, t2=-3.2, t3=-6.4, t4=-9.6, t5=-12.8, t6=-16, t7 = -19.4;
  37. float distancia_objecto_1 = -18.0; // variavel usada por 5 objetos!
  38. float velocidade=400;
  39.  
  40. void gerar()
  41. {
  42.     pos[0]= -30 ;
  43.     pos[1]= -30 ;
  44.     pos[2]= -30;
  45.     pos[3]= -30 ;
  46.     pos[4]= -30 ;
  47.  
  48.     if(flag==0)
  49.    {
  50.     pos[0]= -2 ;
  51.     pos[1]= -1.5 ;
  52.     pos[2]= -1;
  53.     pos[3]= -0.5 ;
  54.     pos[4]= 0 ;
  55.     vetor[0]= 0 ;
  56.     vetor[1]= 0 ;
  57.     vetor[2]= 0;
  58.     vetor[3]= 0 ;
  59.     vetor[4]= 0 ;
  60.     }
  61.    else{
  62.  
  63.     vetor[0]= rand() %5 + 1;
  64.     if(vetor[0]==1)
  65.         pos[0]= -2.0;
  66.     else if (vetor[0]==2)
  67.         pos[0]= -1.5;
  68.     else if (vetor[0]==3)
  69.         pos[0]= -1.0;
  70.     else if (vetor[0]==4)
  71.         pos[0]= -0.5;
  72.     else if (vetor[0]==5)
  73.         pos[0]= 0.0;
  74.     vetor[1]= rand() %5 + 1;
  75.     if(vetor[0]!= vetor[1])
  76.        {
  77.     if(vetor[1]==1)
  78.         pos[1]= -2.0;
  79.     else if (vetor[1]==2)
  80.         pos[1]= -1.5;
  81.     else if (vetor[1]==3)
  82.         pos[1]= -1.0;
  83.     else if (vetor[1]==4)
  84.         pos[1]= -0.5;
  85.     else if (vetor[1]==5)
  86.         pos[1]= 0.0;
  87.  
  88.        }
  89.      vetor[2]= rand() %5 + 1;
  90.     if(vetor[0]!= vetor[2] && vetor[1]!= vetor[2])
  91.     {
  92.         if(vetor[2]==1)
  93.         pos[2]= -2.0;
  94.         else if (vetor[2]==2)
  95.         pos[2]= -1.5;
  96.         else if (vetor[2]==3)
  97.         pos[2]= -1.0;
  98.         else if (vetor[2]==4)
  99.         pos[2]= -0.5;
  100.         else if (vetor[2]==5)
  101.         pos[2]= 0.0;
  102.  
  103.     }
  104.     vetor[3]= rand() %5 + 1;
  105.     if(vetor[0]!= vetor[3] && vetor[1]!= vetor[3] && vetor[2]!= vetor[3])
  106.     {
  107.         if(vetor[3]==1)
  108.         pos[3]= -2.0;
  109.         else if (vetor[3]==2)
  110.         pos[3]= -1.5;
  111.         else if (vetor[3]==3)
  112.         pos[3]= -1.0;
  113.         else if (vetor[3]==4)
  114.         pos[3]= -0.5;
  115.         else if (vetor[3]==5)
  116.         pos[3]= 0.0;
  117.  
  118.     }
  119.  
  120.     printf("pos1 = %d\n pos2 %d\n pos3 %d\n pos4 %d\n",pos[0],pos[1],pos[2],pos[3]);
  121.    }
  122.  }
  123.  
  124. void teclado (int key, int x, int y){
  125.  
  126.     if(key == GLUT_KEY_RIGHT && (b<0))
  127.         b=b+0.5;
  128.     if(key == GLUT_KEY_LEFT && (b >-2))
  129.         b=b-0.5;
  130.  
  131.   glutPostRedisplay();
  132.  
  133. }
  134. void desenha_padroes (int a){
  135.  
  136.  
  137. glPushMatrix();
  138.  
  139.    glRotatef(90, 1 ,0 ,0);
  140.    glTranslatef(0, a, 0);
  141.  
  142.    glBegin(GL_QUADS);
  143.  
  144.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  145.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  146.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  147.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  148.  
  149.    glEnd();
  150.    glPopMatrix();
  151.  
  152.  
  153. }
  154.  
  155. void movimento_do_chao (int value){
  156. velocidade=velocidade-10;
  157.  
  158. if(velocidade<50)
  159.     velocidade=VELOCIDADE_MAX;
  160.  
  161.     t1 = t1 + 0.2;
  162.     t2 = t2 + 0.2;
  163.     t3 = t3 + 0.2;
  164.     t4 = t4 + 0.2;
  165.     t5 = t5 + 0.2;
  166.     t6 = t6 + 0.2;
  167.     t7 = t7 + 0.2;
  168.  
  169.     distancia_objecto_1 = distancia_objecto_1 + 0.2;
  170.  
  171.     if(t1>=4.0)
  172.         t1=-18.6;
  173.     if(t2>=4.0)
  174.         t2=-18.6;
  175.     if(t3>=4.0)
  176.         t3=-18.6;
  177.     if(t4>=4.0)
  178.         t4=-18.6;
  179.     if(t5>=4.0)
  180.         t5=-18.6;
  181.     if(t6>=4.0)
  182.         t6=-18.6;
  183.     if(t7>=4.0)
  184.         t7=-18.6;
  185.  
  186.     if(distancia_objecto_1>4.0){
  187.         distancia_objecto_1=-18.0;
  188.         gerar();
  189.         flag++;
  190.     }
  191.  
  192.     glutPostRedisplay();
  193.     glutTimerFunc(velocidade, movimento_do_chao, 1);
  194.  
  195. }
  196. void desenho() // desenho das bolas
  197. {
  198. /** JOGADOR **/
  199.     glPushMatrix();
  200.    glTranslated(b, -0.34, 2.62);// glTranslated(-1,-0.34, 2.62);
  201.    glRotated(1,1,1,1);
  202.    glutSolidSphere (0.12, 20, 10);
  203.    glPopMatrix();
  204. /** FIM DO JOGADOR **/
  205.  
  206.    glPushMatrix();
  207.    glTranslated(pos[0], -0.34, distancia_objecto_1);
  208.    glRotated(1,1,1,1);
  209.    glutSolidSphere (0.18, 20, 10);
  210.    glPopMatrix();
  211.  
  212.  
  213. /** um cone FEIO  **/
  214.    glPushMatrix();
  215.    glTranslated(pos[1], -0.4 , distancia_objecto_1);
  216.    glRotated(90,-10,1,1);
  217.    glutSolidCone(0.2 , 0.2 ,20 , 10);
  218.    glPopMatrix();
  219.  
  220. /** um cubo **/
  221.  
  222.     glPushMatrix();
  223.     glTranslated(pos[2], -0.34, distancia_objecto_1);
  224.     glutSolidCube(0.2);
  225.     glPopMatrix();
  226.  
  227.     /** Donut **/
  228.  
  229.  
  230.     glPushMatrix();
  231.     glTranslated(pos[3], -0.33, distancia_objecto_1);
  232.     glutSolidTorus(0.08 , 0.17, 4 , 20);
  233.     glPopMatrix();
  234.  
  235. }
  236.  
  237.  
  238. void makeCheckImage(void)
  239. {
  240.    int i, j, c;
  241.  
  242.    for (i = 0; i < checkImageHeight; i++) {
  243.       for (j = 0; j < checkImageWidth; j++) {
  244.          c = ((((i&0x8)==0)^((j&0x8))==0))*255;
  245.          checkImage[i][j][0] = (GLubyte) c;
  246.          checkImage[i][j][1] = (GLubyte) c;
  247.          checkImage[i][j][2] = (GLubyte) c;
  248.          checkImage[i][j][3] = (GLubyte) 255;
  249.       }
  250.    }
  251. }
  252.  
  253. void init(void)
  254. {
  255.  
  256.    GLfloat mat_amb[] = { 0.1, 1, 0.8, 1.0 };
  257.  
  258.    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
  259.    GLfloat mat_shininess[] = { 100.0 };
  260.    GLfloat light_position[] = {0.0, -0.1, -5.0, 0.0 };
  261.  
  262.  
  263.    glClearColor (0.0, 0.0, 0.0, 0.0);
  264.    glShadeModel(GL_SMOOTH);
  265.  
  266.  
  267.    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
  268.    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
  269.    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  270.  
  271.  
  272.  
  273.    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,
  274.             mat_amb);
  275.  
  276.  
  277.  
  278.    makeCheckImage();
  279.    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  280.  
  281.    glGenTextures(1, &texName);
  282.    glBindTexture(GL_TEXTURE_2D, texName);
  283.  
  284.    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  285.    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  286.    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
  287.                    GL_NEAREST);
  288.    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
  289.                    GL_NEAREST);
  290.    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth,
  291.                 checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
  292.                 checkImage);
  293.  
  294.    glEnable(GL_LIGHTING);
  295.    glEnable(GL_LIGHT0);
  296.  
  297.    glEnable(GL_DEPTH_TEST);
  298.  
  299.  
  300. }
  301.  
  302. void display(void)
  303. {
  304.    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  305.    glEnable(GL_TEXTURE_2D);
  306.    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
  307.    glBindTexture(GL_TEXTURE_2D, texName);
  308. /** chao 1 **/
  309.  
  310.  
  311. glPushMatrix();
  312.  
  313.    glRotatef(90, 1 ,0 ,0);
  314.    glTranslatef(0, t1, 0);
  315.  
  316.    glBegin(GL_QUADS);
  317.  
  318.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  319.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  320.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  321.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  322.    glEnd();
  323.    glPopMatrix();
  324.  
  325.   /** parede  1 direita **/
  326. glPushMatrix();
  327.  
  328.    glRotatef(90, 0 ,1 ,0);
  329.    glTranslatef(-t1, 1, 0);
  330.  
  331.    glBegin(GL_QUADS);
  332.  
  333.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  334.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  335.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  336.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  337.    glEnd();
  338.    glPopMatrix();
  339.  
  340. /** parede 1 esquerda **/
  341.  
  342. glPushMatrix();
  343.  
  344.    glRotatef(90, 0 , -1 ,0);
  345.    glTranslatef(t1, 0.77, 2.6);
  346.  
  347.    glBegin(GL_QUADS);
  348.  
  349.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  350.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  351.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  352.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  353.    glEnd();
  354.    glPopMatrix();
  355.  
  356.    /** chao 2 **/
  357.  
  358. glPushMatrix();
  359.  
  360.    glRotatef(90, 1 ,0 ,0);
  361.    glTranslatef(0, t2, 0);
  362.  
  363.    glBegin(GL_QUADS);
  364.  
  365.     glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  366.     glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  367.     glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  368.     glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  369.  
  370.    glEnd();
  371.    glPopMatrix();
  372.  
  373.  //   desenha_padroes(t2);
  374. /** parede 2 direita **/
  375.  
  376. glPushMatrix();
  377.  
  378.    glRotatef(90, 0 ,1 ,0);
  379.    glTranslatef(-t2, 1, 0);
  380.  
  381.    glBegin(GL_QUADS);
  382.  
  383.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  384.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  385.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  386.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  387.    glEnd();
  388.    glPopMatrix();
  389.  
  390.    /** parede 2 esquerda **/
  391.  
  392.  
  393. glPushMatrix();
  394.  
  395.    glRotatef(90, 0 , -1 ,0);
  396.    glTranslatef(t2, 0.77, 2.6);
  397.  
  398.    glBegin(GL_QUADS);
  399.  
  400.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  401.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  402.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  403.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  404.    glEnd();
  405.    glPopMatrix();
  406.  
  407.  
  408. /** chao 3 **/
  409.  
  410. glPushMatrix();
  411.    glRotatef(90, 1 ,0 ,0);
  412.    glTranslatef(0, t3, 0);
  413.  
  414.    glBegin(GL_QUADS);
  415.  
  416.     glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  417.     glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  418.     glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  419.     glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  420.  
  421.    glEnd();
  422.    glPopMatrix();
  423.  
  424.  //   desenha_padroes(t3);
  425.  
  426.  /** parede 3 direita **/
  427.  glPushMatrix();
  428.  
  429.    glRotatef(90, 0 ,1 ,0);
  430.    glTranslatef(-t3, 1, 0);
  431.  
  432.    glBegin(GL_QUADS);
  433.  
  434.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  435.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  436.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  437.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  438.    glEnd();
  439.    glPopMatrix();
  440.  
  441. /** parede 3 esquerda **/
  442.  
  443. glPushMatrix();
  444.  
  445.    glRotatef(90, 0 , -1 ,0);
  446.    glTranslatef(t3, 0.77, 2.6);
  447.  
  448.    glBegin(GL_QUADS);
  449.  
  450.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  451.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  452.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  453.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  454.    glEnd();
  455.    glPopMatrix();
  456.  
  457.  
  458. /** chao 4 **/
  459.  
  460.    glPushMatrix();
  461.  
  462.    glRotatef(90, 1 ,0 ,0);
  463.    glTranslatef(0, t4, 0);
  464.  
  465.    glBegin(GL_QUADS);
  466.  
  467.     glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  468.     glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  469.     glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  470.     glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  471.  
  472.    glEnd();
  473.    glPopMatrix();
  474. //    desenha_padroes(t4);
  475.  
  476. /** parede 4 direita **/
  477.  
  478. glPushMatrix();
  479.  
  480.    glRotatef(90, 0 ,1 ,0);
  481.    glTranslatef(-t4, 1, 0);
  482.  
  483.    glBegin(GL_QUADS);
  484.  
  485.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  486.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  487.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  488.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  489.    glEnd();
  490.    glPopMatrix();
  491.  
  492.    /** parede 4 esquerda **/
  493.  
  494.    glPushMatrix();
  495.  
  496.    glRotatef(90, 0 , -1 ,0);
  497.    glTranslatef(t4, 0.77, 2.6);
  498.  
  499.    glBegin(GL_QUADS);
  500.  
  501.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  502.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  503.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  504.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  505.    glEnd();
  506.    glPopMatrix();
  507.  
  508.  
  509. /** chao 5 **/
  510.  
  511. glPushMatrix();
  512.  
  513.  glRotatef(90, 1 ,0 ,0);
  514.  glTranslatef(0, t5, 0);
  515.  
  516. glBegin(GL_QUADS);
  517.  
  518.     glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  519.     glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  520.     glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  521.     glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  522.  
  523.    glEnd();
  524.    glPopMatrix();
  525. /** parede 5 direita **/
  526.  
  527. glPushMatrix();
  528.  
  529.    glRotatef(90, 0 ,1 ,0);
  530.    glTranslatef(-t5, 1, 0);
  531.  
  532.    glBegin(GL_QUADS);
  533.  
  534.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  535.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  536.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  537.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  538.    glEnd();
  539.    glPopMatrix();
  540.  
  541.    /** parede 5 esquerda **/
  542.  
  543.    glPushMatrix();
  544.  
  545.    glRotatef(90, 0 , -1 ,0);
  546.    glTranslatef(t5, 0.77, 2.6);
  547.  
  548.    glBegin(GL_QUADS);
  549.  
  550.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  551.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  552.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  553.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  554.    glEnd();
  555.    glPopMatrix();
  556.  
  557. /** chao 6 **/
  558.  
  559. glPushMatrix();
  560.  
  561.  glRotatef(90, 1 ,0 ,0);
  562.  glTranslatef(0, t6, 0);
  563.  
  564. glBegin(GL_QUADS);
  565.  
  566.     glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  567.     glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  568.     glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  569.     glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  570.  
  571.    glEnd();
  572.    glPopMatrix();
  573.  
  574. /** parede 6 direita **/
  575.  
  576. glPushMatrix();
  577.  
  578.    glRotatef(90, 0 ,1 ,0);
  579.    glTranslatef(-t6, 1, 0);
  580.  
  581.    glBegin(GL_QUADS);
  582.  
  583.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  584.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  585.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  586.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  587.    glEnd();
  588.    glPopMatrix();
  589.  
  590.    /** parede 6 esquerda **/
  591.  
  592.    glPushMatrix();
  593.  
  594.    glRotatef(90, 0 , -1 ,0);
  595.    glTranslatef(t6, 0.77, 2.6);
  596.  
  597.    glBegin(GL_QUADS);
  598.  
  599.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  600.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  601.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  602.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  603.    glEnd();
  604.    glPopMatrix();
  605.  
  606.  
  607. /** chao 7 **/
  608.  
  609. glPushMatrix();
  610.  
  611.  glRotatef(90, 1 ,0 ,0);
  612.  glTranslatef(0, t7, 0);
  613.  
  614. glBegin(GL_QUADS);
  615.  
  616.     glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  617.     glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  618.     glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  619.     glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  620.  
  621.    glEnd();
  622.    glPopMatrix();
  623.  
  624. /** parede 7 direita **/
  625.  
  626. glPushMatrix();
  627.  
  628.    glRotatef(90, 0 ,1 ,0);
  629.    glTranslatef(-t7, 1, 0);
  630.  
  631.    glBegin(GL_QUADS);
  632.  
  633.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  634.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  635.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  636.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  637.    glEnd();
  638.    glPopMatrix();
  639.  
  640.    /** parede 7 esquerda **/
  641.  
  642.    glPushMatrix();
  643.  
  644.    glRotatef(90, 0 , -1 ,0);
  645.    glTranslatef(t7, 0.77, 2.6);
  646.  
  647.    glBegin(GL_QUADS);
  648.  
  649.    glTexCoord2f(0.0, 0.0); glVertex3f(-2.6, -1.6, 0.6);
  650.    glTexCoord2f(0.0, 1.0); glVertex3f(-2.6, 1.6, 0.6);
  651.    glTexCoord2f(1.0, 1.0); glVertex3f(0.6, 1.6, 0.6);
  652.    glTexCoord2f(1.0, 0.0); glVertex3f(0.6, -1.6, 0.6);
  653.    glEnd();
  654.    glPopMatrix();
  655. /** fim dos desenhos **/
  656.  
  657. desenho();
  658.  
  659.    glFlush();
  660.    glDisable(GL_TEXTURE_2D);
  661.  
  662. }
  663.  
  664. void reshape(int w, int h)
  665. {
  666.    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
  667.    glMatrixMode(GL_PROJECTION);
  668.    glLoadIdentity();
  669.    gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0);
  670.    glMatrixMode(GL_MODELVIEW);
  671.    glLoadIdentity();
  672.  
  673.    glTranslatef(1.0, 0.0, -3.6);
  674. }
  675.  
  676.  
  677.  
  678. int main(int argc, char** argv)
  679. {
  680.  
  681.     pos[0]= -2 ;
  682.     pos[1]= -1.5 ;
  683.     pos[2]= -1;
  684.     pos[3]= -0.5 ;
  685.     pos[4]= 0 ;
  686.     flag++;
  687.     vetor[0]= 0 ;
  688.     vetor[1]= 0 ;
  689.     vetor[2]= 0;
  690.     vetor[3]= 0 ;
  691.     vetor[4]= 0 ;
  692.    glutInit(&argc, argv);
  693.    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
  694.    glutInitWindowSize(600, 480);
  695.    glutInitWindowPosition(150, 150);
  696.    glutCreateWindow(argv[0]);
  697.    init();
  698.    glutDisplayFunc(display);
  699.    glutReshapeFunc(reshape);
  700.  
  701.  
  702.    glutTimerFunc(1, movimento_do_chao, 1);
  703.  
  704.    glutSpecialFunc(teclado);
  705.  
  706.  
  707.    glutMainLoop();
  708.    return 0;
  709. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement