roboforum.ruТехнический форум по робототехнике. |
|
|
float rotX = 0.0, rotY = 0.0;
int lastX, lastY;
float distX = 0.0, distY = 0.0;
byte i=0,j=0,k=0;//счётчики
void setup()
{ size(400, 400, P3D); noStroke(); fill(255, 0, 0); }
void draw()
{
background(0); lights();
translate(width/2, height/2);
rotateX(rotX + distY); rotateY(rotY + distX);
/////////////////////////////////////////////////
for (i=0;i<6;i++)
{
for (j=0;j<6;j++)
{
translate(20*i,20*j,0);
box(10, 10, 10);
}
}
/////////////////////////////////////////////////
}
void mousePressed() { lastX = mouseX; lastY = mouseY; }
void mouseDragged() { distX = radians(mouseX - lastX); distY = radians(lastY - mouseY); }
void mouseReleased() { rotX += distY; rotY += distX; distX = distY = 0.0; }
//3D processing //
float rotX = 0.0, rotY = 0.0;
int lastX, lastY;
float distX = 0.0, distY = 0.0;
int x=0,y=0,z=0;//счётчики - координаты
int i;//счётчик
int s=0;//счётчик
int ss=0;//счётчик
int sss=0;//счётчик
int R=25;//размер куба в окне
int []tabl_eff={0,7,14,21,28,35,36,43,50,57,64,71,72,79,86,93,100,107,108,115,122,129,136,143,144,151,158,165,172,179,180,187,194,201,208,215,227,
2,7,12,19,26,38,43,48,55,62,69,74,79,84,91,98,105,110,115,120,127,134,141,146,151,156,163,170,177,182,187,192,199,206,213,227,
3,8,13,18,25,32,39,44,49,54,61,68,75,80,85,90,97,104,111,116,121,126,133,140,147,152,157,162,169,176,183,188,193,198,205,212,227,
4,9,14,19,24,31,40,45,50,55,60,67,76,81,86,91,96,103,112,117,122,127,132,139,148,153,158,163,168,175,184,189,194,199,204,211,227,
5,10,15,20,25,30,41,46,51,56,61,66,77,82,87,92,97,102,113,118,123,128,133,138,149,154,159,164,169,174,185,190,195,200,205,210,227,
4,11,16,21,26,31,40,47,52,57,62,67,76,83,88,93,98,103,112,119,124,129,134,139,148,155,160,165,170,175,184,191,196,201,206,211,227,
3,10,17,22,27,32,39,46,53,58,63,68,75,82,89,94,99,104,111,118,125,130,135,140,147,154,161,166,171,176,183,190,197,202,207,212,227,
2,9,16,23,28,33,38,45,52,59,64,69,74,81,88,95,100,105,110,117,124,131,136,141,146,153,160,167,172,177,182,189,196,203,208,213,227,
1,8,15,22,29,34,37,44,51,58,65,70,73,80,87,94,101,106,109,116,123,130,137,142,145,152,159,166,173,178,181,188,195,202,209,214,227,
255};
////////////////////////////////////////////////////////////////////////
void setup()
{
size(500, 500, P3D); noStroke();
frameRate(10);//число кадров в секунду
}
void draw()
{
background(0); lights();
translate(width/2, height/2);
rotateX(rotX + distY); rotateY(rotY + distX);
/////////////////////////////////////////////////
/////////////////////////////////////////////////
for (i=s+1;i<tabl_eff.length;i++)
{
if(tabl_eff[i]==255){s=0;ss=sss;break;}
if(tabl_eff[i]==227){ss=i;if(s==0){sss=i;}break;}
}
////////////////////////////////////////////////
for (x=-2;x<4;x++)
{
for (y=-2;y<4;y++)
{
for (z=-2;z<4;z++)
{
translate(2*R*x,2*R*y,2*R*z);fill(0,40,20);box(R/2, R/2, R/2);translate(-2*R*x,-2*R*y,-2*R*z);
for (i=s;i<ss;i++)
{
if((x+2)+(y+2)*6+(z+2)*36==tabl_eff[i]){translate(2*R*x,2*R*y,2*R*z);fill(0, 255, 0);box(R/2, R/2, R/2);translate(-2*R*x,-2*R*y,-2*R*z);}
}
}
}
}
s=ss;
/////////////////////////////////////////////////
}
void mousePressed() { lastX = mouseX; lastY = mouseY; }
void mouseDragged() { distX = radians(mouseX - lastX); distY = radians(lastY - mouseY); }
void mouseReleased() { rotX += distY; rotY += distX; distX = distY = 0.0; }
void mouseWheel(MouseEvent event) {
R =R+5*event.getCount();//приближение-удаление куба
}
//3D processing //
float rotX = 0.0, rotY = 0.0;
int lastX, lastY;
float distX = 0.0, distY = 0.0;
int x=0,y=0,z=0;//счётчики - координаты
int i;//счётчик
int s=0;//счётчик
int ss=0;//счётчик
int sss=0;//счётчик
int R=25;//размер куба в окне
int fl=1;//флаг состояний
int k=0;//счётчик
int j=0;//счётчик
boolean fl_A=true;//флаг состояний
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////// массив данных нескольких эффектов ////////////////////////////////
int []tabl_dano={5,227,
4,11,41,227,
3,10,17,40,47,77,227,
2,9,16,23,39,46,53,76,83,113,227,
1,8,15,22,29,38,45,52,59,75,82,89,112,119,149,227,
0,7,14,21,28,35,37,44,51,58,65,74,81,88,95,111,118,125,148,155,185,227,
6,13,20,27,34,36,43,50,57,64,71,73,80,87,94,110,117,124,131,147,154,161,184,191,227,
12,19,26,33,42,49,56,63,70,72,79,86,93,100,107,109,116,123,130,137,146,153,160,167,183,190,227,
18,25,32,48,55,62,69,78,85,92,99,106,108,115,122,129,136,143,145,152,159,166,173,182,189,196,203,227,
24,31,54,61,68,84,91,98,105,114,121,128,135,142,144,151,158,165,172,179,181,188,195,202,209,227,
30,60,67,90,97,104,120,127,134,141,150,157,164,171,178,180,187,194,201,208,215,227,
66,96,103,126,133,140,156,163,170,177,186,193,200,207,214,227,
102,132,139,162,169,176,192,199,206,213,227,
138,168,175,198,205,212,227,
174,204,211,227,
210,227,
255,//ЭФФЕКТ СЛОЙ ДВИЖЕТСЯ ПО ДИАГОНАЛИ КУБА СНИЗУ ВВЕРХ, СЛЕВА НАПРОВО, ВГЛУБЬ//
0,7,14,21,28,35,36,43,50,57,64,71,72,79,86,93,100,107,108,115,122,129,136,143,144,151,158,165,172,179,180,187,194,201,208,215,227,
1,6,13,20,27,34,37,42,49,56,63,70,73,78,85,92,99,106,109,114,121,128,135,142,145,150,157,164,171,178,181,193,200,207,214,227,
2,7,12,19,26,38,43,48,55,62,69,74,79,84,91,98,105,110,115,120,127,134,141,146,151,156,163,170,177,182,187,192,199,206,213,227,
3,8,13,18,25,32,39,44,49,54,61,68,75,80,85,90,97,104,111,116,121,126,133,140,147,152,157,162,169,176,183,188,193,198,205,212,227,
4,9,14,19,24,31,40,45,50,55,60,67,76,81,86,91,96,103,112,117,122,127,132,139,148,153,158,163,168,175,184,189,194,199,204,211,227,
5,10,15,20,25,30,41,46,51,56,61,66,77,82,87,92,97,102,113,118,123,128,133,138,149,154,159,164,169,174,185,190,195,200,205,210,227,
4,11,16,21,26,31,40,47,52,57,62,67,76,83,88,93,98,103,112,119,124,129,134,139,148,155,160,165,170,175,184,191,196,201,206,211,227,
3,10,17,22,27,32,39,46,53,58,63,68,75,82,89,94,99,104,111,118,125,130,135,140,147,154,161,166,171,176,183,190,197,202,207,212,227,
2,9,16,23,28,33,38,45,52,59,64,69,74,81,88,95,100,105,110,117,124,131,136,141,146,153,160,167,172,177,182,189,196,203,208,213,227,
1,8,15,22,29,34,37,44,51,58,65,70,73,80,87,94,101,106,109,116,123,130,137,142,145,152,159,166,173,178,181,188,195,202,209,214,227,
255,//ЭФФЕКТ ВОЛНА//
4,5,10,11,40,41,46,47,227,
3,4,5,9,11,15,16,17,39,41,51,53,75,76,77,81,83,87,88,89,227,
2,3,4,5,8,11,14,17,20,21,22,23,38,41,56,59,74,77,92,95,110,111,112,113,116,119,122,125,128,129,130,131,227,
1,2,3,4,5,7,11,13,17,19,23,25,26,27,28,29,37,41,61,65,73,77,97,101,109,113,133,137,145,146,147,148,149,151,155,157,161,163,167,169,170,171,172,173,227,
0,1,2,3,4,5,6,11,12,17,18,23,24,29,30,31,32,33,34,35,36,41,66,71,72,77,102,107,108,113,126,138,143,144,149,174,179,180,181,182,183,184,185,186,191,192,197,198,203,204,209,210,211,212,213,214,215,227,
42,43,44,45,46,48,52,54,58,60,64,66,70,78,82,102,106,114,118,138,142,150,154,174,178,186,187,188,189,190,192,196,198,202,204,208,210,211,212,213,214,227,
84,85,86,87,90,93,96,99,102,103,104,105,120,123,138,141,156,159,174,177,192,193,194,195,198,201,204,207,210,211,212,213,227,
126,127,128,132,134,138,139,140,162,164,174,176,198,199,200,204,206,210,211,212,227,
168,169,174,175,204,205,210,211,227,
255,//ЭФФЕКТ НАРАСТАНИЕ И УМЕНЬШЕНИЕ КОНТУРА КУБА ПО ДИАГОНАЛИ//
3,8,26,33,38,49,55,68,79,84,90,97,115,120,126,133,146,157,163,176,183,188,206,213,227,
2,7,25,32,37,48,54,67,78,84,90,96,114,120,126,132,145,156,162,175,182,187,205,212,227,
1,6,24,31,36,48,54,66,78,84,90,96,114,120,126,132,144,156,162,174,181,186,204,211,227,
0,6,24,30,36,48,54,66,78,84,90,96,114,120,126,132,144,156,162,174,180,186,204,210,227,
0,6,24,30,36,48,54,66,78,85,91,96,114,121,127,132,138,144,156,162,174,180,186,204,210,227,
0,6,24,30,36,49,55,61,66,79,86,92,97,115,122,128,133,144,157,163,174,180,186,204,210,227,
0,7,25,30,37,50,56,67,80,87,93,98,116,123,129,134,145,158,164,175,180,187,205,210,227,
1,8,26,31,38,51,57,68,81,88,94,99,117,124,130,135,146,159,165,176,181,188,206,211,227,
2,9,27,32,39,52,58,69,82,89,95,100,118,125,131,136,147,160,166,177,182,189,207,212,227,
3,10,28,33,40,53,59,70,83,89,95,101,119,125,131,137,148,161,167,178,183,190,208,213,227,
4,11,29,34,41,53,59,71,83,89,95,101,107,119,125,131,137,149,161,167,179,184,191,209,214,227,
5,11,29,35,41,53,59,71,83,89,95,101,119,125,131,137,143,149,161,167,179,185,191,209,215,227,
5,11,29,35,41,53,59,71,83,88,94,101,119,124,130,137,149,161,167,179,185,191,209,215,227,
5,11,29,35,41,52,58,71,82,87,93,100,118,123,129,136,149,160,166,179,185,191,209,215,227,
5,10,28,35,40,51,57,70,81,86,92,99,117,122,128,135,148,159,165,178,185,190,208,215,227,
4,9,27,34,39,50,56,69,80,85,91,98,116,121,127,134,147,158,164,177,184,189,207,214,227,
255,//ЭФФЕКТ ВЫТРЯХИВАНИЯ КОВРА//
0,7,14,21,28,35,37,44,51,58,65,70,74,81,88,95,100,105,111,118,125,130,135,140,148,155,160,165,170,175,185,190,195,200,205,210,227,
1,8,15,22,29,34,38,45,52,59,64,69,75,82,89,94,99,104,112,119,124,129,134,139,149,154,159,164,169,174,184,189,194,199,204,211,227,
2,9,16,23,28,33,39,46,53,58,63,68,76,83,88,93,98,103,113,118,123,128,133,138,148,153,158,163,168,175,183,188,193,198,205,212,227,
3,10,17,22,27,32,40,47,52,57,62,67,77,82,87,92,97,102,112,117,122,127,132,139,147,152,157,162,169,176,182,187,192,199,206,213,227,
4,11,16,21,26,31,41,46,51,56,61,66,76,81,86,91,96,103,111,116,121,126,133,140,146,151,156,163,170,177,181,186,193,200,207,214,227,
5,10,15,20,25,30,40,45,50,55,60,67,75,80,85,90,97,104,110,115,120,127,134,141,145,150,157,164,171,178,180,187,194,201,208,215,227,
4,9,14,19,24,31,39,44,49,54,61,68,74,79,84,91,98,105,109,114,121,128,135,142,144,151,158,165,172,179,181,188,195,202,209,214,227,
3,8,13,18,25,32,38,43,48,55,62,69,73,78,85,92,99,106,108,115,122,129,136,143,145,152,159,166,173,178,182,189,196,203,208,213,227,
2,7,12,19,26,33,37,42,49,56,63,70,72,79,86,93,100,107,109,116,123,130,137,142,146,153,160,167,172,177,183,190,197,202,207,212,227,
1,6,13,20,27,34,36,43,50,57,64,71,73,80,87,94,101,106,110,117,124,131,136,141,147,154,161,166,171,176,184,191,196,201,206,211,227,
255,//ВОЛНА-ГОРА//
300};
int []tabl_eff=new int[600];
////////////////////////////////////////////////////////////////////////
void setup()
{
size(500, 500, P3D);
//noStroke();
stroke(0,100,100);
frameRate(10);//число кадров в секунду
}
////////////////////////////////////////////////////////////////////////
void draw()
{
//////////////////////////////////////////////////
i=0;
while(fl_A==true){tabl_eff[i]=tabl_dano[j];if(tabl_dano[j]==255){fl_A=false;s=0;}i++;j++;if(tabl_dano[j]==300){j=0;}}//запись в массив текущего эффекта
k++;if(k>100){fl_A=true;k=0;}//число циклов draw на 1 эффект
/////////////////////////////////////////////////
background(0); lights();
translate(width/2, height/2);
if (mousePressed && (mouseButton == LEFT)){rotateX(rotX + distY); rotateY(rotY + distX);fl=1;}// если нажата кнопка мыши и она левая вращаем видимым кубом
if (mousePressed && (mouseButton == RIGHT)){rotateX(rotX + distY); rotateY(rotY + distX);fl=0;}// если нажата кнопка мыши и она правая вращаем невидимым кубом
if (mousePressed && (mouseButton == CENTER)){noLoop();delay(3000);loop();}// если нажата центральная кнопка мыши то стоп кадр
/////////////////////////////////////////////////
/////////////////////////////////////////////////
for (i=s+1;i<tabl_eff.length;i++)
{
if(tabl_eff[i]==255){s=0;ss=sss;break;}
if(tabl_eff[i]==227){ss=i;if(s==0){sss=i;}break;}
}
////////////////////////////////////////////////
for (x=-2;x<4;x++)
{
for (y=-2;y<4;y++)
{
for (z=-2;z<4;z++)
{
if(fl==1){translate(2*R*x,2*R*y,2*R*z);strokeWeight(1);noFill();box(R/2);translate(-2*R*x,-2*R*y,-2*R*z);}// условие видимости всего куба
for (i=s;i<ss;i++)
{
if((x+2)+(y+2)*6+(z+2)*36==tabl_eff[i]){translate(2*R*x,2*R*y,2*R*z);strokeWeight(1);fill(0, 255, 0);box(R/2);translate(-2*R*x,-2*R*y,-2*R*z);}
}
}
}
}
s=ss;
if(fl==0){strokeWeight(3);translate(R,R,R);noFill();box(12*R);}//рамка - куб при невидимости всего куба
/////////////////////////////////////////////////
}
/////////////////// функции положения курсора и вращения колеса ////////////////////////////////////////////
void mousePressed() { lastX = mouseX; lastY = mouseY; }
void mouseDragged() { distX = radians(mouseX - lastX); distY = radians(lastY - mouseY); }
void mouseReleased() { rotX += distY; rotY += distX; distX = distY = 0.0; }
void mouseWheel(MouseEvent event){R=R+5*event.getCount();}//приближение-удаление куба с помощью колеса мыши
//3D processing //
//ВИРТУАЛЬНЫЙ ИСПОЛНИТЕЛЬ ЭФФЕКТОВ СВЕТОДИОДНОГО КУБА 6*6*6//
float rotX = 0.0, rotY = 0.0;
int lastX, lastY;
float distX = 0.0, distY = 0.0;
float X,Y;
int x=0,y=0,z=0;//счётчики - координаты
int i;//счётчик
int s=0;//счётчик
int ss=0;//счётчик
int sss=0;//счётчик
int R=25;//размер куба в окне
int fl=1;//флаг состояний
int k=0;//счётчик
int j=0;//счётчик
boolean fl_A=true;//флаг состояний
boolean fl_B=true;//флаг состояний
int r=0,g=255,b=0;//составляющие цвета
int color_=0;//счётчик цвета
int n=50;//скорость анимации
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////// массив данных нескольких эффектов ////////////////////////////////
int []tabl_dano={5,227,
4,11,41,227,
3,10,17,40,47,77,227,
2,9,16,23,39,46,53,76,83,113,227,
1,8,15,22,29,38,45,52,59,75,82,89,112,119,149,227,
0,7,14,21,28,35,37,44,51,58,65,74,81,88,95,111,118,125,148,155,185,227,
6,13,20,27,34,36,43,50,57,64,71,73,80,87,94,110,117,124,131,147,154,161,184,191,227,
12,19,26,33,42,49,56,63,70,72,79,86,93,100,107,109,116,123,130,137,146,153,160,167,183,190,227,
18,25,32,48,55,62,69,78,85,92,99,106,108,115,122,129,136,143,145,152,159,166,173,182,189,196,203,227,
24,31,54,61,68,84,91,98,105,114,121,128,135,142,144,151,158,165,172,179,181,188,195,202,209,227,
30,60,67,90,97,104,120,127,134,141,150,157,164,171,178,180,187,194,201,208,215,227,
66,96,103,126,133,140,156,163,170,177,186,193,200,207,214,227,
102,132,139,162,169,176,192,199,206,213,227,
138,168,175,198,205,212,227,
174,204,211,227,
210,227,
255,//ЭФФЕКТ СЛОЙ ДВИЖЕТСЯ ПО ДИАГОНАЛИ КУБА СНИЗУ ВВЕРХ, СЛЕВА НАПРОВО, ВГЛУБЬ//
0,7,14,21,28,35,36,43,50,57,64,71,72,79,86,93,100,107,108,115,122,129,136,143,144,151,158,165,172,179,180,187,194,201,208,215,227,
1,6,13,20,27,34,37,42,49,56,63,70,73,78,85,92,99,106,109,114,121,128,135,142,145,150,157,164,171,178,181,193,200,207,214,227,
2,7,12,19,26,38,43,48,55,62,69,74,79,84,91,98,105,110,115,120,127,134,141,146,151,156,163,170,177,182,187,192,199,206,213,227,
3,8,13,18,25,32,39,44,49,54,61,68,75,80,85,90,97,104,111,116,121,126,133,140,147,152,157,162,169,176,183,188,193,198,205,212,227,
4,9,14,19,24,31,40,45,50,55,60,67,76,81,86,91,96,103,112,117,122,127,132,139,148,153,158,163,168,175,184,189,194,199,204,211,227,
5,10,15,20,25,30,41,46,51,56,61,66,77,82,87,92,97,102,113,118,123,128,133,138,149,154,159,164,169,174,185,190,195,200,205,210,227,
4,11,16,21,26,31,40,47,52,57,62,67,76,83,88,93,98,103,112,119,124,129,134,139,148,155,160,165,170,175,184,191,196,201,206,211,227,
3,10,17,22,27,32,39,46,53,58,63,68,75,82,89,94,99,104,111,118,125,130,135,140,147,154,161,166,171,176,183,190,197,202,207,212,227,
2,9,16,23,28,33,38,45,52,59,64,69,74,81,88,95,100,105,110,117,124,131,136,141,146,153,160,167,172,177,182,189,196,203,208,213,227,
1,8,15,22,29,34,37,44,51,58,65,70,73,80,87,94,101,106,109,116,123,130,137,142,145,152,159,166,173,178,181,188,195,202,209,214,227,
255,//ЭФФЕКТ ВОЛНА//
4,5,10,11,40,41,46,47,227,
3,4,5,9,11,15,16,17,39,41,51,53,75,76,77,81,83,87,88,89,227,
2,3,4,5,8,11,14,17,20,21,22,23,38,41,56,59,74,77,92,95,110,111,112,113,116,119,122,125,128,129,130,131,227,
1,2,3,4,5,7,11,13,17,19,23,25,26,27,28,29,37,41,61,65,73,77,97,101,109,113,133,137,145,146,147,148,149,151,155,157,161,163,167,169,170,171,172,173,227,
0,1,2,3,4,5,6,11,12,17,18,23,24,29,30,31,32,33,34,35,36,41,66,71,72,77,102,107,108,113,126,138,143,144,149,174,179,180,181,182,183,184,185,186,191,192,197,198,203,204,209,210,211,212,213,214,215,227,
42,43,44,45,46,48,52,54,58,60,64,66,70,78,82,102,106,114,118,138,142,150,154,174,178,186,187,188,189,190,192,196,198,202,204,208,210,211,212,213,214,227,
84,85,86,87,90,93,96,99,102,103,104,105,120,123,138,141,156,159,174,177,192,193,194,195,198,201,204,207,210,211,212,213,227,
126,127,128,132,134,138,139,140,162,164,174,176,198,199,200,204,206,210,211,212,227,
168,169,174,175,204,205,210,211,227,
255,//ЭФФЕКТ НАРАСТАНИЕ И УМЕНЬШЕНИЕ КОНТУРА КУБА ПО ДИАГОНАЛИ//
3,8,26,33,38,49,55,68,79,84,90,97,115,120,126,133,146,157,163,176,183,188,206,213,227,
2,7,25,32,37,48,54,67,78,84,90,96,114,120,126,132,145,156,162,175,182,187,205,212,227,
1,6,24,31,36,48,54,66,78,84,90,96,114,120,126,132,144,156,162,174,181,186,204,211,227,
0,6,24,30,36,48,54,66,78,84,90,96,114,120,126,132,144,156,162,174,180,186,204,210,227,
0,6,24,30,36,48,54,66,78,85,91,96,114,121,127,132,138,144,156,162,174,180,186,204,210,227,
0,6,24,30,36,49,55,61,66,79,86,92,97,115,122,128,133,144,157,163,174,180,186,204,210,227,
0,7,25,30,37,50,56,67,80,87,93,98,116,123,129,134,145,158,164,175,180,187,205,210,227,
1,8,26,31,38,51,57,68,81,88,94,99,117,124,130,135,146,159,165,176,181,188,206,211,227,
2,9,27,32,39,52,58,69,82,89,95,100,118,125,131,136,147,160,166,177,182,189,207,212,227,
3,10,28,33,40,53,59,70,83,89,95,101,119,125,131,137,148,161,167,178,183,190,208,213,227,
4,11,29,34,41,53,59,71,83,89,95,101,107,119,125,131,137,149,161,167,179,184,191,209,214,227,
5,11,29,35,41,53,59,71,83,89,95,101,119,125,131,137,143,149,161,167,179,185,191,209,215,227,
5,11,29,35,41,53,59,71,83,88,94,101,119,124,130,137,149,161,167,179,185,191,209,215,227,
5,11,29,35,41,52,58,71,82,87,93,100,118,123,129,136,149,160,166,179,185,191,209,215,227,
5,10,28,35,40,51,57,70,81,86,92,99,117,122,128,135,148,159,165,178,185,190,208,215,227,
4,9,27,34,39,50,56,69,80,85,91,98,116,121,127,134,147,158,164,177,184,189,207,214,227,
255,//ЭФФЕКТ ВЫТРЯХИВАНИЯ КОВРА//
0,7,14,21,28,35,37,44,51,58,65,70,74,81,88,95,100,105,111,118,125,130,135,140,148,155,160,165,170,175,185,190,195,200,205,210,227,
1,8,15,22,29,34,38,45,52,59,64,69,75,82,89,94,99,104,112,119,124,129,134,139,149,154,159,164,169,174,184,189,194,199,204,211,227,
2,9,16,23,28,33,39,46,53,58,63,68,76,83,88,93,98,103,113,118,123,128,133,138,148,153,158,163,168,175,183,188,193,198,205,212,227,
3,10,17,22,27,32,40,47,52,57,62,67,77,82,87,92,97,102,112,117,122,127,132,139,147,152,157,162,169,176,182,187,192,199,206,213,227,
4,11,16,21,26,31,41,46,51,56,61,66,76,81,86,91,96,103,111,116,121,126,133,140,146,151,156,163,170,177,181,186,193,200,207,214,227,
5,10,15,20,25,30,40,45,50,55,60,67,75,80,85,90,97,104,110,115,120,127,134,141,145,150,157,164,171,178,180,187,194,201,208,215,227,
4,9,14,19,24,31,39,44,49,54,61,68,74,79,84,91,98,105,109,114,121,128,135,142,144,151,158,165,172,179,181,188,195,202,209,214,227,
3,8,13,18,25,32,38,43,48,55,62,69,73,78,85,92,99,106,108,115,122,129,136,143,145,152,159,166,173,178,182,189,196,203,208,213,227,
2,7,12,19,26,33,37,42,49,56,63,70,72,79,86,93,100,107,109,116,123,130,137,142,146,153,160,167,172,177,183,190,197,202,207,212,227,
1,6,13,20,27,34,36,43,50,57,64,71,73,80,87,94,101,106,110,117,124,131,136,141,147,154,161,166,171,176,184,191,196,201,206,211,227,
255,//ВОЛНА-ГОРА//
300};
int []tabl_eff=new int[600];
////////////////////////////////////////////////////////////////////////
void setup()
{
size(500, 500, P3D);
//noStroke();
stroke(0,100,100);
frameRate(70);//число кадров в секунду
}
////////////////////////////////////////////////////////////////////////
void draw()
{delay(n);//скорость анимации регулирует
//////////////////////////////////////////////////
i=0;
while(fl_A==true){tabl_eff[i]=tabl_dano[j];if(tabl_dano[j]==255){fl_A=false;s=0;}i++;j++;if(tabl_dano[j]==300){j=0;}}//запись в массив текущего эффекта
k++;if(k>300){fl_A=true;k=0;}//число циклов draw на 1 эффект
/////////////////////////////////////////////////
background(0); lights();
translate(width/2, (height/2)-50);
///////// навигация исполнения эффектов ////////
//if (mousePressed && (mouseButton == LEFT)){rotateX(rotX + distY); rotateY(rotY + distX);fl=1;}// если нажата кнопка мыши и она левая вращаем видимым кубом
//if (mousePressed && (mouseButton == RIGHT)){rotateX(rotX + distY); rotateY(rotY + distX);fl=0;}// если нажата кнопка мыши и она правая вращаем невидимым кубом
if (mousePressed && (mouseButton == LEFT)){X=rotX + distY; Y=rotY + distX;fl=1;}// если нажата кнопка мыши и она левая вращаем видимым кубом
if (mousePressed && (mouseButton == RIGHT)){X=rotX + distY; Y=rotY + distX;fl=0;}// если нажата кнопка мыши и она правая вращаем невидимым кубом
rotateX(X); rotateY(Y);
if (mousePressed && (mouseButton == CENTER)){noLoop();delay(3000);loop();}// если нажата центральная кнопка мыши то стоп кадр
if (keyPressed&&key == ' ') {fl_A=true;k=0;}//если нажат пробел переходим к следующему эффекту
if (keyPressed&&(key == 'ц'||key == 'Ц'||key == 'w'||key == 'W')) {color_++;//если нажата кнопка "W"(Ц) меняем цвет куба...
if(color_>6){color_=0;}if(color_==0){r=0;g=255;b=0;}if(color_==1){r=255;g=0;b=0;}if(color_==2){r=0;g=0;b=255;}if(color_==3){r=0;g=255;b=255;}if(color_==4){r=255;g=255;b=255;}
if(color_==5){r=255;g=255;b=0;}if(color_==6){r=255;g=0;b=255;}//... последовательно, на один из семи
}
if (keyPressed&&(key == 'v'||key == 'V'||key == 'м'||key == 'М')){n=n+50;if(n>150){n=50;}delay(100);}// если нажата кнопка "V"(М)меняем скорость исполнения
/////////////////////////////////////////////////
/////// перебор кадров в эффекте ///////////////
/////////////////////////////////////////////////
for (i=s+1;i<tabl_eff.length;i++)
{
if(tabl_eff[i]==255){s=0;ss=sss;break;}
if(tabl_eff[i]==227){ss=i;if(s==0){sss=i;}break;}
}
////////////////////////////////////////////////
////// построение изображения куба в кадре //////////////
///////////////////////////////////////////////
for (x=-2;x<4;x++)
{
for (y=-2;y<4;y++)
{
for (z=-2;z<4;z++)
{
if(fl==1){translate(2*R*x,2*R*y,2*R*z);strokeWeight(1);noFill();box(R/2);translate(-2*R*x,-2*R*y,-2*R*z);}// условие видимости всего куба
for (i=s;i<ss;i++)
{
if((x+2)+(y+2)*6+(z+2)*36==tabl_eff[i]){translate(2*R*x,2*R*y,2*R*z);strokeWeight(1);fill(r, g, b);box(R/2);translate(-2*R*x,-2*R*y,-2*R*z);}
}
}
}
}
s=ss;
if(fl==0){strokeWeight(R/5);translate(R,R,R);noFill();box(12*R);}//рамка - куб при невидимости всего куба
if(fl==1){strokeWeight(R/5);translate(R,8*R,R);noFill();box(13*R,2*R,13*R);}//рамка - основание куба при его видимости
/////////////////////////////////////////////////
}
/////////////////// функции положения курсора и вращения колеса ////////////////////////////////////////////
void mousePressed() { lastX = mouseX; lastY = mouseY; }
void mouseDragged() { distX = radians(mouseX - lastX); distY = radians(lastY - mouseY); }
void mouseReleased() { rotX += distY; rotY += distX;distX = distY = 0.0; }
void mouseWheel(MouseEvent event){R=R+5*event.getCount();}//приближение-удаление куба с помощью колеса мыши
Вернуться в Arduino и другие Xduino
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2