Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.46 KB | None | 0 0
  1.     glNormal3f(0, 0, 1);
  2.     glColor4fv(colour_);
  3.     glBegin(GL_POLYGON); //Naive.  Why are triangles better?
  4.     glVertex3f(53.0, -20.0, 0);
  5.     glVertex3f(53.0, 18.0, 0);
  6.     glVertex3f(25.0, 40.0, 0);
  7.     glVertex3f(-10.0, 40, 0);
  8.     glVertex3f(-30.0, 35, 0);
  9.     glVertex3f(-60.0, 20, 0);
  10.     glVertex3f(-70.0, 15, 0);
  11.     glVertex3f(-80.0, 12, 0);
  12.     glVertex3f(-80.0, -10, 0);
  13.     glVertex3f(-60.0, -15, 0);
  14.     glEnd();
  15.    
  16.     // Salmon tail (sans fins).
  17.     glBegin(GL_TRIANGLES);
  18.    
  19.     glVertex3f(-80.0, 12, 0);
  20.     glVertex3f(-130.0, 30, 0);
  21.     glVertex3f(-80.0, -10, 0);
  22.    
  23.     glVertex3f(-80.0, 12, 0);
  24.     glVertex3f(-130.0, -30, 0);
  25.     glVertex3f(-80.0, -10, 0);
  26.     glEnd();
  27.    
  28.     // Salmon belly, dorsal fins, and contours (lighter).
  29.     float belly_[] = { 0.98, 0.45, 0.04, 1.0 };
  30.     glColor4fv(belly_);
  31.     glPushMatrix();
  32.     glScalef(1, 0.4, 0.0);
  33.     glBegin(GL_POLYGON);
  34.     for (double i = (6.8 / 6 ) * M_PI; i < 1.9 * M_PI; i += M_PI / 6) {
  35.         glVertex3f(cos(i) * (1.2 * length_), sin(i) * length_, 0.0);
  36.     }
  37.     glEnd();
  38.     glPopMatrix();
  39.    
  40.     glBegin(GL_TRIANGLES);
  41.    
  42.     glVertex3f(-40.0, 25, 0);
  43.     glVertex3f(-70.0, 10, 0);
  44.     glVertex3f(-80.0, 10, 0);
  45.    
  46.     glVertex3f(25.0, -5.0, 0);
  47.     glVertex3f(45.0, 20.0, 0);
  48.     glVertex3f(35.0, 15.0, 0);
  49.    
  50.     glVertex3f(-90.0, 0, 0);
  51.     glVertex3f(-130.0, 30, 0);
  52.     glVertex3f(-110.0, 0, 0);
  53.    
  54.     glVertex3f(-90.0, 0, 0);
  55.     glVertex3f(-130.0, -30, 0);
  56.     glVertex3f(-110.0, 0, 0);
  57.    
  58.     glVertex3f(-60.0, 20, 0);
  59.     glVertex3f(-70.0, 15, 0);
  60.     glVertex3f(-75.0, 22, 0);
  61.  
  62.     glVertex3f(-10.0, 40, 0);
  63.     glVertex3f(-30.0, 35, 0);
  64.     glVertex3f(-30.0, 60, 0);
  65.    
  66.     glVertex3f(-30.0, 35, 0);
  67.     glVertex3f(-30.0, 60, 0);
  68.     glVertex3f(-50.0, 35, 0);
  69.    
  70.     glVertex3f(-30.0, 35, 0);
  71.     glVertex3f(-40.0, 30, 0);
  72.     glVertex3f(-50.0, 35, 0);
  73.    
  74.     glEnd();
  75.    
  76.     // Green lowlights.
  77.     float lowlights_[] = { 0.17, 0.49, 0.27, 1.0 };
  78.     glColor4fv(lowlights_);
  79.     glBegin(GL_TRIANGLES);
  80.    
  81.     glVertex3f(-85.0, 0, 0);
  82.     glVertex3f(-125.0, -28, 0);
  83.     glVertex3f(-90.0, 0, 0);
  84.    
  85.     glEnd();
  86.    
  87.     // Green highlights.
  88.     float highlights_[] = { 0.37, 0.67, 0.35, 1.0 };
  89.     glColor4fv(highlights_);
  90.     glBegin(GL_TRIANGLES);
  91.  
  92.     glVertex3f(-90.0, 0, 0);
  93.     glVertex3f(-130.0, 30, 0);
  94.     glVertex3f(-110.0, 0, 0);
  95.    
  96.     glVertex3f(-90.0, 0, 0);
  97.     glVertex3f(-130.0, -30, 0);
  98.     glVertex3f(-110.0, 0, 0);
  99.    
  100.     glEnd();
  101.    
  102.     // Salmon fins (same colour as body to contrast with belly).
  103.     glColor4fv(colour_);
  104.     glBegin(GL_TRIANGLES);
  105.    
  106.     glVertex3f(40.0, -15.0, 0);
  107.     glVertex3f(15.0, -20.0, 0);
  108.     glVertex3f(30.0, -40, 0);
  109.    
  110.     glVertex3f(0.0, -25.0, 0);
  111.     glVertex3f(-20.0, -25.0, 0);
  112.     glVertex3f(-25.0, -35, 0);
  113.    
  114.     glVertex3f(-60.0, -20, 0);
  115.     glVertex3f(-70.0, -15, 0);
  116.     glVertex3f(-75.0, -22, 0);
  117.    
  118.     glEnd();
  119.    
  120.     // Face and top mandible (greenish).
  121.     float face_[] = { 0.37, 0.67, 0.35, 1.0 };
  122.     glColor4fv(face_);
  123.     glNormal3f(0, 0, 1);
  124.     glBegin(GL_TRIANGLES);
  125.    
  126.     glVertex3f(35.0, -5.0, 0);
  127.     glVertex3f(55.0, 17.0, 0);
  128.     glVertex3f(100.0, 10, 0);
  129.    
  130.     glVertex3f(35.0, -5.0, 0);
  131.     glVertex3f(100.0, 10, 0);
  132.     glVertex3f(60.0, -17, 0);
  133.  
  134.     glVertex3f(100.0, 10, 0);
  135.     glVertex3f(93.0, -5, 0);
  136.     glVertex3f(86.0, 10, 0);
  137.    
  138.     glEnd();
  139.    
  140.     // Lower mandible (darker green).
  141.     float jaw_[] = { 0.17, 0.49, 0.27, 1.0 };
  142.     glColor4fv(jaw_);
  143.     glBegin(GL_TRIANGLES);
  144.    
  145.     glVertex3f(37.0, -7.0, 0);
  146.     glVertex3f(37.0, -25.0, 0);
  147.     glVertex3f(75.0, -22, 0);
  148.    
  149.     glVertex3f(55.0, -20.0, 0);
  150.     glVertex3f(100.0, -10.0, 0);
  151.     glVertex3f(75.0, -22, 0);
  152.    
  153.     glEnd();
  154.  
  155.     // Eye
  156.     glPushMatrix();
  157.     glTranslatef(50, 0, 0);
  158.     const float white[] = {1.0, 1.0, 1.0, 1.0};
  159.     glColor4fv(white);
  160.     glNormal3f(0, 0, 1);
  161.     glBegin(GL_POLYGON);
  162.     for (double i = 0.0; i < 2 * M_PI; i += M_PI / 6)
  163.         glVertex3f(cos(i) * 4, sin(i) * 4, 0.0);
  164.     glEnd();
  165.     glTranslatef(1, 0, 0);
  166.     const float black[] = {0.0, 0.0, 0.0, 1.0};
  167.     glColor4fv(black);
  168.     glNormal3f(0, 0, 1);
  169.     glBegin(GL_POLYGON);
  170.     for (double i = 0.0; i < 2 * M_PI; i += M_PI / 6)
  171.         glVertex3f(cos(i) * 2, sin(i) * 2, 0.0);
  172.     glEnd();
  173.     glPopMatrix();
  174.  
  175.     // Restore the transformation matrix.
  176.     glPopMatrix();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement