Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. struct Color{
  2.   int wavelength;
  3.   double R;
  4.   double G;
  5.   double B;
  6.  
  7.   Color(){}
  8.   Color(int w,double r,double g,double b):wavelength(w),R(r),G(g),B(b){}
  9. };
  10.  
  11. Color szinek[115];
  12.  
  13.  
  14. void cut(Point* t, int size){
  15.         Point* temp = new Point[size];
  16.         int temp_size = size;
  17.         int j = 0;
  18.         for(int i = 0; i < size; i++)
  19.           temp[i] = t[i];
  20.         float* color_t = new float[3];
  21.         glBegin(GL_TRIANGLES);
  22.         for(int i = 2; i < temp_size; i++){
  23.           if(isEar(temp[i-2],temp[i-1],temp[i], t, size)){
  24.                 glShadeModel(GL_SMOOTH);
  25.                 color(color_t,j);
  26.                 glColor3f(color_t[0],color_t[1],color_t[2]);
  27.                 glVertex2f(temp[i-2].x,temp[i-2].y);
  28.                 glVertex2f(temp[i-1].x,temp[i-1].y);
  29.                 glVertex2f(temp[i].x,temp[i].y);
  30.                 temp = delete_point(temp, i-1, temp_size);
  31.                 temp_size--;
  32.                 j++;
  33.                 //cout << j << ". HAROMSZOG RAJZOL" << endl;
  34.                 //cout << "HATRALEVO PONTOK SZAMA: " << temp_size << endl;
  35.                 i = 2;
  36.           }
  37.          
  38.         }
  39.         glVertex2f(temp[0].x,temp[0].y);
  40.         glVertex2f(temp[1].x,temp[1].y);
  41.         glVertex2f(temp[2].x,temp[2].y);
  42.         cout << "CUT OK" << endl;
  43.         glEnd();
  44.   }
  45.  
  46.   void color(float* color_t,int i){
  47.      int color_index = (i % 115);
  48.      cout << color_index << endl;
  49.      color_t[0] = (float)szinek[color_index].R;
  50.      color_t[1] = (float)szinek[color_index].G;
  51.      color_t[2] = (float)szinek[color_index].B;
  52.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement