Too Much Information.

3D flying tube animation made with code.
Many color tube flying X-Y-Z axis.
Beautiful 3D animation of flying light tube.

Description of this creative coding work.

Creative coding work made with Processing programming code.

I improved the background animation in Zundoko Kiyoshi. It draws too many lines and blobs on XYZ axes.


Code examples in Processing (Java).

Please feel free to use it, if you like it.
To see other works based on my code is my pleasure. And my honor.

// Too Much Information.
// Processing 3.2.1
// 2018.03.04

/* laser X ---------------------------------------------------------------- */
class LaserX {

  float lineX, lineY, lineZ;
  float lineHue;
  float divX, divXSpeed;
  int pauseCnt, pauseCntMax;
  
  LaserX() {
    initialize();
  }

  void drawLaser() {
    ++pauseCnt;
    if (pauseCnt < pauseCntMax) {
      return;
    }
    
    if (abs(lineX) > 5000) {
      initialize();
    }

    divX += divX * divXSpeed;
    lineX += divX;

    translate(lineX, lineY, lineZ);
    strokeWeight(0.5);
    stroke(
           lineHue,
           20,
           10000 / (abs(lineX) + 200),
           100
           );
    line(-3000, 0, 0, 3000, 0, 0);

    noStroke();
    for (int i = -30; i <= 30; ++i) {
      float normalize = map(abs(i), 0, 30, 0.0, 1.0);
      translate(2.0, 0.0, 0.0);
      fill(
           lineHue,
           80,
           10 - normalize * 5,
           100
           );
      ellipse(
              0.0,
              0.0,
              20.0 + normalize * 60,
              20.0 - normalize * 16
              );
    }
    translate(-lineX - 122, -lineY, -lineZ); // reset
  }

  void initialize() {
    if (random(10) < 5) {
      divX = -1.0;
    } else {
      divX = 1.0;
    }
    
    lineX = -random(1000, 4900) * divX;
    lineY = random(-250, 250);
    lineY += 100 * lineY / (abs(lineY) + 1); // about -100 to -350 or 100 to 350
    lineZ = random(-2000, -300);
    divXSpeed = random(0.001, 0.01);
    lineHue = random(0.0, 360.0);

    pauseCnt = 0;
    pauseCntMax = ceil(random(300));
  }
}

/* laser Y ---------------------------------------------------------------- */
class LaserY {

  float lineX, lineY, lineZ;
  float lineHue;
  float divY, divYSpeed;
  int pauseCnt, pauseCntMax;
  
  LaserY() {
    initialize();
  }

  void drawLaser() {
    ++pauseCnt;
    if (pauseCnt < pauseCntMax) {
      return;
    }
    
    if (abs(lineY) > 2000) {
      initialize();
    }

    divY += divY * divYSpeed;
    lineY += divY;

    translate(lineX, lineY, lineZ);
    strokeWeight(0.5);
    stroke(
           lineHue,
           20,
           5000 / (abs(lineY) + 100),
           100
           );
    line(0, -3000, 0, 0, 3000, 0);

    noStroke();
    for (int i = -30; i <= 30; ++i) {
      float normalize = map(abs(i), 0, 30, 0.0, 1.0);
      translate(0.0, 2.0, 0.0);
      fill(
           lineHue,
           80,
           15 - normalize * 10,
           100
           );
      ellipse(
              0.0,
              0.0,
              20.0 - normalize * 16,
              20.0 + normalize * 60
              );
    }
    translate(-lineX, -lineY - 122, -lineZ); // reset
  }

  void initialize() {
    if (random(10) < 5) {
      divY = -1.0;
    } else {
      divY = 1.0;
    }
    
    lineX = random(-350, 350);
    lineX += 200 * lineX / (abs(lineX) + 1); // about -200 to -550 or 100 to 550
    lineY = -random(800, 1900) * divY;
    lineZ = random(-2000, -300);
    divYSpeed = random(0.001, 0.01);
    lineHue = random(0.0, 360.0);

    pauseCnt = 0;
    pauseCntMax = ceil(random(150));
  }
}

/* laser Z ---------------------------------------------------------------- */

class LaserZ {

  float lineX, lineY, lineZ;
  float lineHue;
  float divZ, divZSpeed;
  int pauseCnt, pauseCntMax;
  
  LaserZ() {
    initialize();
  }

  void drawLaser() {
    ++pauseCnt;
    if (pauseCnt < pauseCntMax) {
      return;
    }

    if (abs(lineZ) > 5000) {
      initialize();
    }

    divZ += divZ * divZSpeed;
    lineZ += divZ;

    translate(lineX, lineY, lineZ);
    strokeWeight(0.2);
    noFill();
    stroke(
           lineHue,
           20,
           6000 / (abs(lineZ + 200) + 200),
           100
           );
    line(0, 0, -5000, 0, 0, 5000);

    noStroke();
    for (int i = -50; i <= 50; ++i) {
      float normalize = map(abs(i), 0, 50, 0.0, 1.0);
      translate(0.0, 0.0, 2.0);
      fill(
           lineHue,
           80,
           10 - normalize * 5,
           100
           );
      ellipse(
              0.0,
              0.0,
              15.0 - normalize * 10,
              15.0 - normalize * 10
              );
    }
    translate(-lineX, -lineY, -lineZ - 202); // reset
  }

  void initialize() {
    if (random(10) < 5) {
      divZ = -1.0;
    } else {
      divZ = 1.0;
    }
    lineX = random(-400, 400);
    lineY = random(-150, 150);
    lineZ = -random(1000, 4900) * divZ;
    divZSpeed = random(0.001, 0.01);
    lineHue = random(0.0, 360.0);

    pauseCnt = 0;
    pauseCntMax = ceil(random(90));
  }
}


/* ---------------------------------------------------------------------- */
LaserX lx[];
LaserY ly[];
LaserZ lz[];
int laserCnt;
float angleX, angleY, angleZ;

void setup() {
  size(900, 556, P3D);
  colorMode(HSB, 360, 100, 100, 100);
  blendMode(SCREEN);
  hint(DISABLE_DEPTH_TEST);
  smooth(8);

  laserCnt = 1000;
  lx = new LaserX[laserCnt];
  ly = new LaserY[laserCnt];
  lz = new LaserZ[laserCnt];
  for (int i = 0; i < laserCnt; ++i) {
    lx[i] = new LaserX();
    ly[i] = new LaserY();
    lz[i] = new LaserZ();
  }

  angleX = random(-10, 10);
  angleY = random(-10, 10);
  angleZ = random(-30, 30);
}

void draw() {
  background(0, 0, 0, 100);
  lightFalloff(
               1.0,
               0.00005,
               0.000002
               );
  pointLight(
             0, 0, 100,
             0, 0, 100
             );
  camera(
         0, 0,  80,
         0, 0, 0,
         0, 1, 0
         );

  rotateX(radians(angleX));
  rotateY(radians(angleY));
  rotateZ(radians(angleZ));

  for (int i = 0; i < laserCnt; ++i) {
    lx[i].drawLaser();
    ly[i].drawLaser();
    lz[i].drawLaser();
  }
  /*
  saveFrame("frames/####.png");
  if (frameCount > 30 * 30) {
    exit ();
  }
  */
}



/*
Copyright (C) 2018 deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see 
*/




No comments :

Post a Comment