Guest User

Untitled

a guest
Apr 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include "Piece.h"
  2.  
  3. Piece::Piece(int x,int z,int color){
  4.  
  5.     this->x = x;
  6.     this->y = 1.6;
  7.     this->z = z;
  8.     this->color = color;
  9. }
  10.    
  11. void Piece::buildPiece(GLenum mode,GLUquadric* glQ){
  12.  
  13.     if (mode == GL_SELECT){
  14.             glLoadName (70);
  15.         }
  16.  
  17.     glEnable(GL_COLOR_MATERIAL);
  18.     if(color == 0)
  19.         glColor3f(1.0,0.0,0.0);
  20.     else if(color == 1)
  21.         glColor3f(0.0,0.0,1.0);
  22.    
  23.     //Esfera de baixo
  24.     glPushMatrix();
  25.     glTranslated(x,y,z);
  26.     gluSphere(glQ,1.0,16,8);
  27.     glPopMatrix();
  28.  
  29.     //Esfera de cima
  30.     glPushMatrix();
  31.     glTranslated(x,y*2,z);
  32.     gluSphere(glQ,0.6,16,8);
  33.     glPopMatrix();
  34.     glDisable(GL_COLOR_MATERIAL);
  35.    
  36.     //Olhos
  37.     glEnable(GL_COLOR_MATERIAL);
  38.     glColor3f(1.0,1.0,1.0);
  39.     glPushMatrix();
  40.     glTranslated(x,y+1,z+0.5);
  41.     gluSphere(glQ,0.2,16,8);
  42.     glPopMatrix();
  43.  
  44.     glPushMatrix();
  45.     glTranslated(x+0.5,y+1,z+0.4);
  46.     gluSphere(glQ,0.2,16,8);
  47.     glPopMatrix();
  48.     glDisable(GL_COLOR_MATERIAL);
  49.  
  50.     //Olhos2
  51.     glEnable(GL_COLOR_MATERIAL);
  52.     glColor3f(0.0,0.0,0.0);
  53.     glPushMatrix();
  54.     glTranslated(x,y+1.0,z+0.7);
  55.     gluSphere(glQ,0.1,16,8);
  56.     glPopMatrix();
  57.  
  58.     glPushMatrix();
  59.     glTranslated(x+0.6,y+1.0,z+0.5);
  60.     gluSphere(glQ,0.1,16,8);
  61.     glPopMatrix();
  62.     glDisable(GL_COLOR_MATERIAL);
  63. }
  64.  
  65. void Piece::setCoords(int x, int z){
  66.     this->x = x;
  67.     this->z = z;
  68. }
Add Comment
Please, Sign In to add comment