Life Questions

An animation with text redering on 3D shape.
An animation with text redering on 3D shape.

Description of this video.

I made this with Processing programming code and Kdenlive.
I learned text rendering on 3D shape with this code.

Thanks to nice music:
Introduction to Part 1 by Steve Combs
2017/01/17
http://freemusicarchive.org/music/Steve_Combs/The_Green_Album/01_Introduction_to_Part_1
Introduction to Part 1 by Steve Combs is licensed under a Attribution License.
For more permissions:
contact artist

クリエイティブ・コモンズ・ライセンス


Processing example code.


// Life Questions
// Processing 3.2.1
// 2017.02.10
import processing.opengl.*;

World wd;
Question[] qt;
int questions_cnt = 48;

float noise_s, noise_c, noise_i, noise_b;
int arise_cnt;

void setup() {
  size(1280, 720, OPENGL);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  frameRate(30);

  wd = new World();
  qt = new Question[questions_cnt];
  for (int i = 0; i < questions_cnt; i++) {
    qt[i] = new Question();
  }

  noise_s = random(100);
  noise_c = random(100);
  noise_i = random(100);
  noise_b = random(100);

  arise_cnt = 0;
}

void draw() {
  wd.redraw();

  // rotate the world
  wd.rotate();

  // questions
  for (int i = 0; i < questions_cnt; i++) {
    if (qt[i].arise(noise_s, noise_c, noise_i, noise_b, arise_cnt)) {
      noise_s += 0.13;
      noise_c += 0.10;
      noise_i += 0.07;
      noise_b += 0.08;
      ++arise_cnt;
    }
    qt[i].draw();
  }

  /*
    translate(width / 2, height / 2, 0);
    stroke(0, 0, 100, 100);
    line(0, 0, -1000, 0, 0, 1000);
    ellipse(0, 0, 50, 50);
  */
  
  /*
    saveFrame("frames/####.png");
    if (frameCount >= 2640) {
    exit();
    }
  */

}

class World {
  float r_X;
  float r_Y;
  float r_Z;
  float noise_seed;

  World() {
    r_X = 0;
    r_Y = 0;
    r_Z = 0;
    noise_seed = random(100);
  }

  void redraw() {
    background(200);
    ambientLight(0, 0, 50);
    lightFalloff(1, 0.0, 0.00002);
    pointLight(0,0,100,width / 2, height / 2, 580);
  }
    
  void rotate() {
    float cicle_rotate = (frameCount % 1081) / 3.0;
    float rollnoise = noise(noise_seed);
    r_X = 0.08 * sin(radians(cicle_rotate + (0.5 - rollnoise) * 30));
    r_Y = 0.12 * cos(radians(cicle_rotate)) + (0.5 - rollnoise) * 0.08;
    rotateX(r_X);
    rotateY(r_Y);
    noise_seed += 0.005;
  }

}

class Question {
  float div_x, div_y, div_z;
  float noise_x, noise_y, noise_r;
  float boxsize_x, boxsize_y;
  float box_x, box_y, box_z;
  float textsize;
  float size_factor;
  float color_factor, intent_factor, bright_factor, real_factor;

  Question() {
    div_x = 0;
    div_y = 0;
    div_z = 0;
    noise_x = random(10);
    noise_y = random(10);
    noise_r = random(10);
    boxsize_x = 80;
    boxsize_y = 50;
    box_x = 0;
    box_y = 0;
    box_z = 2000;
    textsize = 10;
    size_factor = 0.5;
    color_factor = 200;
    intent_factor = 0;
    bright_factor = 0;
    real_factor = 0;
  }

  boolean arise(float ns, float nc, float ni, float nb, int arise_cnt) {
    if (box_z > 1000) {
      float cicle_rotate = arise_cnt % 24;
      size_factor = 1.0 + noise(ns) * 3;

      box_x = 60 * cos(radians(cicle_rotate * 15));
      box_y = 60 * sin(radians(cicle_rotate * 15));
      box_z = -1000 * size_factor - random(2000);
      div_x = box_x / 160;
      div_y = box_y / 200;
      div_z = 6;

      if (size_factor > 3.2) {
        // red question
        size_factor = size_factor * 3 /2;
        div_x = div_x * 3;
        div_y = div_y * 3;
        div_z = 8;
        color_factor = 330 + noise(nc) * 30;
        intent_factor = 20 + noise(ni) * 20;
        bright_factor = 10 + noise(nb) * 20;
        real_factor = 50;
      } else {
        // blue question
        color_factor = 170 + noise(nc) * 100;
        intent_factor = noise(ni) * 40;
        bright_factor = noise(nb) * 30;
        real_factor = 0;
      }

      return true;
    }

    return false;
  }

  void draw() {


    this.grow();
    this.press();
    
    pushMatrix();
    
    translate(width / 2 + box_x, height / 2 + box_y, box_z);

    // question panel
    stroke(color_factor, 10, 10, real_factor);
    strokeWeight(1);
    fill(color_factor, 60 + intent_factor, 70 + bright_factor, real_factor);
    box(boxsize_x * size_factor, boxsize_y * size_factor, 5);

    // question text
    fill(0, 0, 100, real_factor);
    textSize(textsize * (1 + pow(size_factor, 2)));
    textAlign(CENTER, CENTER);
    text("?", 0, 0, 6);

    popMatrix();
  }

  void grow() {
    if (real_factor < 100) {
      real_factor += 0.8 * noise(noise_r);
      noise_r += 0.005;
    }
  }

  void press() {
    box_x += div_x * size_factor * (1.2 + 1.0 * (0.5 - noise(noise_x)));
    box_y += div_y * size_factor * (1.2 + 0.8 * (0.5 - noise(noise_y)));
    box_z += div_z * (0.3 + noise(noise_x, noise_y) * pow(size_factor, 2));

    noise_x += 0.005;
    noise_y += 0.005;
  }

}

/*
Copyright (C) 2017- 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 
*/



Next Post Previous Post
No Comment
Add Comment
comment url