Advertisement
rakoczyn

[OpenGL] Planety

Apr 19th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. if (angle1 >= 360)
  2.             angle1 = 0;
  3.  
  4.         if (angle2 >= 360)
  5.             angle2 = 0;
  6.  
  7.         if (angle3 >= 360)
  8.             angle3 = 0;
  9.  
  10.         angle1 += 0.04f;
  11.         angle2 += 0.01f;
  12.         angle3 += 0.006f;
  13.  
  14.         //SŁONCE
  15.         glColor3f(1,1,0);
  16.         glutWireSphere(0.4,30,30);
  17.  
  18.         //ORBITA 1
  19.         glColor3f(1,1,1);
  20.         glutWireTorus(0.01,1,10,40);
  21.  
  22.         //PLANETA 1
  23.         glPushMatrix();
  24.             glRotatef(angle1,0,0,1);
  25.             glTranslatef(1,0,0);
  26.             glColor3f(1,0,0);
  27.             glutWireSphere(0.1,30,30);
  28.         glPopMatrix();
  29.  
  30.         //ORBITA 2
  31.         glColor3f(1,1,1);
  32.         glutWireTorus(0.01,1.5,10,40);
  33.  
  34.         //PLANETA 2
  35.         glPushMatrix();
  36.             glRotatef(angle2,0,0,1);
  37.             glTranslatef(1.5,0,0);
  38.             glColor3f(0,1,0);
  39.             glutWireSphere(0.2,30,30);
  40.         glPopMatrix();
  41.  
  42.         //ORBITA 3
  43.         glColor3f(1,1,1);
  44.         glutWireTorus(0.01,2.1,10,40);
  45.  
  46.         //PLANETA 3
  47.         glPushMatrix();
  48.             glRotatef(angle3,0,0,1);
  49.             glTranslatef(2.1,0,0);
  50.             glColor3f(0,0,1);
  51.             glPushMatrix();
  52.                 glRotatef(angle3*8,0,0,1);
  53.                 glutWireSphere(0.26,30,30);
  54.             glPopMatrix();
  55.         glPopMatrix();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement