SuperShapes!

April 6, 2018

Hi peeps! another update on stuff i'm working on, this time in the program Processing!!

 

 

 

 

So I recently discovered a programming language/environment called Processing. The GUI syntax and everything is really similar to the Arduino IDE so I thought YES THIS IS IT. So a little background story, Ive been trying to create visuals for music for a while now, mostly with Max/Jitter but also using lasers and mirrors, both really unreliable ^^ My problem with Max/Jitter is that it always takes soooooo much cpu and ram and usually lags quite a bit, buggs out and completely crashes on me. By using lasers and mirrors i kinda got away from that but it was a pain in the ass on its own with several lasers burning out and not being bright enough. 

Then in 2018 I started watching The Coding Train on youtube. Daniel Shiffman, the guy behind it makes some amazing tutorials for processing and the graphics he made using Processing looked really good! So I started of looking at his tutorials and did what I usually do with the Arduino platform where  I take bits of code from other people and adapt it to my project, lets just say its like sampling audio in music ^^ Anyway I then made this: 

 

 

This is a combination of the processing sketch as well as some small edits in Adobe aftereffects :0 

Its based on a sketch by Daniel Shiffman where he adapted a formula for super shapes or super ellipses into a Processing sketch. Some info on super shapes can be found HERE and HERE.   s

This was one of my first attempt at doing anything in Processing so its kinda really using a lot of Shiffmans sketch but i feel like i gave it my own stamp somehow :3 I'm deffinately going to use Processing in the future because I feel its a well documented and open platform that i can connect to pretty much anything!! 

 

Btw I need a pint now soooooooooo see ya later peeps!! Enjoy

and yeah heres my processing sketch: 

 


import netP5.*;
import oscP5.*;
int fader1 = 0;
int noise = 20;
int drums = 20;
int bass = 10;
int rotateX = 0;
int rotateY = 0;
int zoom = 100;
int colorR = 100;
int colorG = 100;
int colorB = 100;
int synth1 = 100; 
int synth2 = 100; 
int synth3 = 100; 
OscP5 oscP5;
NetAddress myRemoteLocation;


import peasy.*;

PeasyCam cam;


PVector[][] sphere;
int total = 100;

float offset = 0;


void setup() {
  fullScreen(P3D);

  cam = new PeasyCam(this, 500);
 
oscP5 = new OscP5(this,12000);
  myRemoteLocation = new NetAddress("127.0.0.1", 12000);
  
sphere = new PVector[total][total];
  
 
}

float a = 1;
float b = 1;

float superShape(float theta, float m, float n1, float n2, float n3) {
  float t1 = abs((1/a)*cos(m * theta / 4));
  t1 = pow(t1, n2);
    float t2 = abs((1/b)*sin(m * theta/4));
  t2 = pow(t2, n3);
  float t3 = t1 + t2;
  float r = pow(t3, - 1 / n1);
  return r;
}

void draw() { 
  
  
  /*
    canvas.beginDraw();
  canvas.background(127);
  canvas.lights();
  canvas.translate(width/2, height/2);
  canvas.rotateX(frameCount * 0.01);
  canvas.rotateY(frameCount * 0.01);  
  canvas.box(150);
  canvas.endDraw();
  image(canvas, 0, 0);
  server.sendImage(canvas);
  */ //Use this for all of the stuff to piåpe it to siphon 
  
  
  
  int total = bass; // this is the setting that changes the resolution of the object
 background(0);
noStroke();
lights();


rotateX(-rotateX/127.);
rotateY(-rotateY/127.);
 
 float r = (zoom); // this is the scale of the object
  for (int i = 0; i < total+1; i++) {
        float lat = map(i, 0, total, -HALF_PI, HALF_PI);
  //      float r2 = superShape(lat, 2, 10, 10, 10);
      float r2 = superShape(lat, 0.3, drums/10.+0.1, 1.7, drums/20.+0.1+synth1); // shape of the object
  for (int j = 0; j < total+1; j++) {
    float lon = map(j, 0, total, -PI, PI);
// float r1 = superShape(lon, 8, 60, 100, 30);
        float r1 = superShape(lat, 0.9, 1.1, synth1/10.+0.1, 0.2);
    float x = r * r1 * cos(lon) * r2 * cos(lat);
    float y = r * r1 * sin(lon) * r2 * cos(lat);
    float z = r * r2 * sin(lat);    
sphere[i][j] = new PVector(x, y, z);

  }
  }
//   canvas.translate(width/2, height/2, 0); // unmute this when removing mousecam
stroke(255);
noFill();


  

   for (int i = 0; i < total; i++) {
    
stroke(255, 255, 255);
beginShape(TRIANGLE_STRIP); 

  for (int j = 0; j < total+1; j++) {

PVector v1 = sphere[i][j]; // ad numbers to this to change it dramaticly
vertex(v1.x, v1.y, v1.z);
    PVector v2 = sphere[i][j]; // ad numbers to this to change it dramaticly
vertex(v2.x, v2.y, v2.z);

  }
endShape();
  }

  for (int i = 0; i < total; i++) {
    float colorchange = map(i, 0, total, 0, 255*6);
    stroke((colorchange) % colorR , colorG, colorB+drums);
stroke(colorR+synth3, colorG, colorB+drums); // color of the object
beginShape(TRIANGLE_STRIP); 
  for (int j = 0; j < total+1; j++) {
    
   

    stroke((colorchange) % colorR+synth1 , colorG, colorB);
PVector v1 = sphere[i][j];
vertex(v1.x, v1.y, v1.z);
    PVector v2 = sphere[i+1][j];
vertex(v2.x, v2.y, v2.z);
  }


endShape();
  }
  
  
}


// signals coming from max 
void oscEvent(OscMessage theOscMessage) {

if(theOscMessage.checkAddrPattern("/drums")==true){  
 drums = theOscMessage.get(0).intValue();
}

             if(theOscMessage.checkAddrPattern("/bass")==true){  
    bass = theOscMessage.get(0).intValue();
          }
                 if(theOscMessage.checkAddrPattern("/rotateX")==true){  
   rotateX = theOscMessage.get(0).intValue();
          }
                   if(theOscMessage.checkAddrPattern("/rotateY")==true){  
   rotateY = theOscMessage.get(0).intValue();
          }
                      if(theOscMessage.checkAddrPattern("/zoom")==true){  
   zoom = theOscMessage.get(0).intValue();
          }
                                if(theOscMessage.checkAddrPattern("/colorR")==true){  
   colorR = theOscMessage.get(0).intValue();
          }
                                if(theOscMessage.checkAddrPattern("/colorG")==true){  
   colorG = theOscMessage.get(0).intValue();
          }
                                if(theOscMessage.checkAddrPattern("/colorB")==true){  
   colorB = theOscMessage.get(0).intValue();
    
        }
                                        if(theOscMessage.checkAddrPattern("/synth1")==true){  
   synth1 = theOscMessage.get(0).intValue();
          }
                                        if(theOscMessage.checkAddrPattern("/synth2")==true){  
   synth2 = theOscMessage.get(0).intValue();
          }
                                        if(theOscMessage.checkAddrPattern("/synth3")==true){  
   synth3 = theOscMessage.get(0).intValue();
          }

   }

 

 

 

 

Please reload

Siste innlegg

April 6, 2018

January 11, 2018

December 8, 2017

October 26, 2017

September 26, 2017

January 13, 2017

October 11, 2016

Please reload

Arkiv
Please reload

Søk etter tags
Please reload

Følg oss
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square