Advertisement
Benjamin_Loison

C++ Render User LemnosLife

Jul 12th, 2017 (edited)
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.73 KB | None | 0 0
  1. const void User::render()
  2. {
  3.     log(m_username + " " + m_view.getPosition().toString() + " " + m_view.getViewAngle().toString());
  4.     Position pos = m_view.getPosition();
  5.     double x = pos.getX(), y = pos.getY(), z = pos.getZ()
  6.     , tX = 1.0 / 64.0, tY = 1.0 / 32.0;
  7.     double n = 1.0 / 8.0;
  8.     glBindTexture(GL_TEXTURE_2D, m_texture);
  9.     x = 0; y = 0;
  10.  
  11.     /// HEAD
  12.  
  13.     glBegin(GL_QUADS); /// FRONT
  14.         glTexCoord2d(8 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1, headHeight);
  15.         glTexCoord2d(8 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1, headHeight + headSize);
  16.         glTexCoord2d(16 * tX, 24 * tY); glVertex3d(x + headSize / 2, y + 1, headHeight + headSize);
  17.         glTexCoord2d(16 * tX, 16 * tY); glVertex3d(x + headSize / 2, y + 1, headHeight);
  18.     glEnd();
  19.     glBegin(GL_QUADS); /// BACK
  20.         glTexCoord2d(32 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize, z + headHeight);
  21.         glTexCoord2d(32 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize, z + headHeight + headSize);
  22.         glTexCoord2d(24 * tX, 24 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize, z + headHeight + headSize);
  23.         glTexCoord2d(24 * tX, 16 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize, z + headHeight);
  24.     glEnd();
  25.     glBegin(GL_QUADS); /// RIGHT
  26.         glTexCoord2d(16 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1, z + headHeight);
  27.         glTexCoord2d(16 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1, z + headHeight + headSize);
  28.         glTexCoord2d(24 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 2 + headSize / 2, z + headHeight + headSize);
  29.         glTexCoord2d(24 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 2 + headSize / 2, z + headHeight);
  30.     glEnd();
  31.     glBegin(GL_QUADS); /// LEFT
  32.         glTexCoord2d(0, 16 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 2, z + headHeight);
  33.         glTexCoord2d(0, 24 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 2, z + headHeight + headSize);
  34.         glTexCoord2d(8 * tX, 24 * tY); glVertex3d(x + headSize / 2, y + 1, z + headHeight + headSize);
  35.         glTexCoord2d(8 * tX, 16 * tY); glVertex3d(x + headSize / 2, y + 1, z + headHeight);
  36.     glEnd();
  37.     glBegin(GL_QUADS); /// TOP
  38.         glTexCoord2d(8 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1, z + headHeight + headSize);
  39.         glTexCoord2d(8 * tX, 32 * tY); glVertex3d(x + headSize / 2, y + 1, z + headHeight + headSize);
  40.         glTexCoord2d(16 * tX, 32 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize, z + headHeight + headSize);
  41.         glTexCoord2d(16 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize, z + headHeight + headSize);
  42.     glEnd();
  43.     /*glBegin(GL_QUADS); /// BOTTOM
  44.         glTexCoord2d(16 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1, z + headHeight);
  45.         glTexCoord2d(16 * tX, 32 * tY); glVertex3d(x + headSize / 2, y + 1, z + headHeight);
  46.         glTexCoord2d(24 * tX, 32 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize, z + headHeight);
  47.         glTexCoord2d(24 * tX, 24 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize, z + headHeight);
  48.     glEnd();*/
  49.  
  50.     /// BODY
  51.  
  52.     glBegin(GL_QUADS); /// TOP
  53.         glTexCoord2d(20 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 4, z + headHeight);
  54.         glTexCoord2d(20 * tX, 16 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight);
  55.         glTexCoord2d(28 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight);
  56.         glTexCoord2d(28 * tX, 12 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 4, z + headHeight);
  57.     glEnd();
  58.     glBegin(GL_QUADS); /// BOTTOM
  59.         glTexCoord2d(28 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 4, z + headHeight / 2);
  60.         glTexCoord2d(28 * tX, 16 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight / 2);
  61.         glTexCoord2d(36 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight / 2);
  62.         glTexCoord2d(36 * tX, 12 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 4, z + headHeight / 2);
  63.     glEnd();
  64.         /// SHOULER
  65.     glBegin(GL_QUADS); /// LEFT
  66.         glTexCoord2d(40 * tX, 12 * tY); glVertex3d(x + headSize, y + 1 + headSize / 4, z + headHeight);
  67.         glTexCoord2d(40 * tX, 16 * tY); glVertex3d(x + headSize, y + 1 + headSize / 2 + headSize / 4, z + headHeight);
  68.         glTexCoord2d(44 * tX, 16 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight);
  69.         glTexCoord2d(44 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 4, z + headHeight);
  70.     glEnd();
  71.     glBegin(GL_QUADS); /// RIGHT
  72.         glTexCoord2d(44 * tX, 12 * tY); glVertex3d(x - headSize, y + 1 + headSize / 2 + headSize / 4, z + headHeight);
  73.         glTexCoord2d(44 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight);
  74.         glTexCoord2d(48 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 4, z + headHeight);
  75.         glTexCoord2d(48 * tX, 12 * tY); glVertex3d(x - headSize, y + 1 + headSize / 4, z + headHeight);
  76.     glEnd();
  77.         /// HAND
  78.     glBegin(GL_QUADS); /// LEFT
  79.         glTexCoord2d(48 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 4, z + headHeight / 2);
  80.         glTexCoord2d(48 * tX, 16 * tY); glVertex3d(x + headSize, y + 1 + headSize / 4, z + headHeight / 2);
  81.         glTexCoord2d(52 * tX, 16 * tY); glVertex3d(x + headSize, y + 1 + headSize / 2 + headSize / 4, z + headHeight / 2);
  82.         glTexCoord2d(52 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight / 2);
  83.     glEnd();
  84.     glBegin(GL_QUADS); /// RIGHT
  85.         glTexCoord2d(52 * tX, 12 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 2 + headSize / 4, z + headHeight / 2);
  86.         glTexCoord2d(52 * tX, 16 * tY); glVertex3d(x - headSize / 2, y + 1 + headSize / 4, z + headHeight / 2);
  87.         glTexCoord2d(56 * tX, 16 * tY); glVertex3d(x - headSize, y + 1 + headSize / 4, z + headHeight / 2);
  88.         glTexCoord2d(56 * tX, 12 * tY); glVertex3d(x - headSize, y + 1 + headSize / 2 + headSize / 4, z + headHeight / 2);
  89.     glEnd();
  90.    
  91.     /// LEGS
  92.    
  93.         /// FOOT
  94.     glBegin(GL_QUADS); /// LEFT
  95.         glTexCoord2d(48 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 4, z);
  96.         glTexCoord2d(48 * tX, 16 * tY); glVertex3d(x + headSize, y + 1 + headSize / 4, z);
  97.         glTexCoord2d(52 * tX, 16 * tY); glVertex3d(x + headSize, y + 1 + headSize / 2 + headSize / 4, z);
  98.         glTexCoord2d(52 * tX, 12 * tY); glVertex3d(x + headSize / 2, y + 1 + headSize / 2 + headSize / 4, z);
  99.     glEnd();
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement