Microcosmos

Microcosmos from Armando Rodriguez on Vimeo.

Mexico City 2016

Made with Processing
Visual by José Armando Rodríguez
Source Code: armyrdz.wordpress.com
Music: Noche Y Dia (Night and Day) Senor Coconut Remix

Source Code:

import punktiert.math.Vec;
import punktiert.physics.*;

// world object
VPhysics physics;
VPhysics physics2;
VPhysics physics3;
ArrayList strings = new ArrayList();
ArrayList strings2 = new ArrayList();
ArrayList strings3 = new ArrayList();
int numStrings=200;
int radio = 350;
int radio2 = 450;

float ladx1 = 0, lady1=0, lady2 = height, divi, divi2;
float ladxx = 0, ladyy=0, ladxx2 = width;

public void setup() {
smooth();
size(1920, 1080);
// create world object with bouncing behavior
physics = new VPhysics();
physics2 = new VPhysics();
physics3 = new VPhysics();
physics.setfriction(.001);
physics2.setfriction(.001);
physics3.setfriction(.001f);

//for (int i=0; i<numStrings; i++) {
// float anguloA = random(0, 2*PI);
// VParticle particleA = new VParticle((width/3) +(sin(anguloA)*radio), ((height/2)+cos(anguloA)*radio));
// particleA.isLocked();
// particleA.lock();
// VParticle particleB = new VParticle((width/3) +(sin(anguloA)*-radio), ((height/2)+cos(anguloA)*-radio));
// particleB.isLocked();
// particleB.lock();
// //create a ParticleString: input: VPhysics, particleA, particleB, resolution, strength
// strings.add(new VParticleString(physics, particleB, particleA, .5f, .01f));
// physics.addGroup(strings.get(i));
//}

////BAttractionLocal(float radius, float strength)
//physics.addBehavior(new BAttractionLocal(20, 30));
//physics.addBehavior(new BCollision());
//// physics.addBehavior(new BSeparate(60));
//physics.addBehavior(new BCohesion() );

for (int i=0; i<numStrings; i++) {
float anguloA = random(0, 2*PI);
// float anguloAA = random(-PI, PI);
VParticle particleA = new VParticle( ((width/3)+sin((anguloA))*radio2),(height/2) +(cos((anguloA))*radio2));
// particleA.isLocked();
// particleA.lock();
VParticle particleB = new VParticle((width/3) +(sin(sin(anguloA+30))*radio2*cos(anguloA)), ((height/2)+sin(cos(anguloA+30))*radio2*cos(anguloA)));
particleB.isLocked();
particleB.lock();
//create a ParticleString: input: VPhysics, particleA, particleB, resolution, strength
strings2.add(new VParticleString(physics2, particleB, particleA, .1f, .01f));
physics2.addGroup(strings2.get(i));
}
for (int i=0; i<numStrings; i++) {
// float anguloA = random(0, 2*PI);
float anguloA = random(0,2* PI);
VParticle particleA = new VParticle( ((width*0.6)+sin(cos(anguloA))*radio2*0.7),(height/2) +(sin(sin(anguloA))*radio2*0.7));
// particleA.isLocked();
// particleA.lock();
VParticle particleB = new VParticle((width*0.6) +(sin(sin(anguloA+20))*radio2*0.4), ((height/2)+sin(cos(anguloA+20))*radio2*0.4));
// particleB.isLocked();
// particleB.isLocked();
// particleB.lock();
//create a ParticleString: input: VPhysics, particleA, particleB, resolution, strength
strings2.add(new VParticleString(physics2, particleB, particleA, .1f, .01f));
physics2.addGroup(strings2.get(i));
}

/////Vertical
//divi = width/200;
//for (int i=0; i<200; i++) {

// VParticle particleA = new VParticle(ladx1 + random(-10, 10), lady1);
// particleA.isLocked();
// particleA.lock();
// VParticle particleB = new VParticle(ladx1+ random(-10, 10), height);
// particleB.isLocked();
// particleB.lock();
// ladx1+=divi;
// //create a ParticleString: input: VPhysics, particleA, particleB, resolution, strength
// strings2.add(new VParticleString(physics2, particleB, particleA, .1f, .01f));
// physics2.addGroup(strings2.get(i));
//}

//BAttractionLocal(float radius, float strength)
physics2.addBehavior(new BAttractionLocal(60, 80));
physics2.addBehavior(new BCollision());
physics.addBehavior(new BSeparate(60));
physics2.addBehavior(new BCohesion() );

//Horizontal
divi2 = height/100;
for (int i=0; i<100; i++) {
VParticle particleA = new VParticle(ladxx, ladyy+ random(-10,10));
particleA.isLocked();
particleA.lock();
VParticle particleB = new VParticle(width, ladyy+ random(-10,10));
particleB.isLocked();
particleB.lock();
ladyy+=divi2;
//create a ParticleString: input: VPhysics, particleA, particleB, resolution, strength
strings3.add(new VParticleString(physics3, particleB, particleA, .1f, .5f));
physics3.addGroup(strings3.get(i));
}

//BAttractionLocal(float radius, float strength)
physics3.addBehavior(new BAttractionLocal(6, 7));
physics3.addBehavior(new BCollision());
physics3.addBehavior(new BSeparate(10));
physics3.addBehavior(new BCohesion() );
}

public void draw() {
background(255, 160);
stroke(0);
strokeWeight(0.9);
physics.update();
physics2.update();
physics3.update();
for (VSpring s : physics3.springs) {
line(s.a.x, s.a.y, s.b.x, s.b.y);

}
resetMatrix();
fill(255);
noStroke();
//ellipse(width/3, height/2, 650, 650);
stroke(0);
strokeWeight(0.9);
for (VSpring s : physics.springs) {

line(s.a.x, s.a.y, s.b.x, s.b.y);
}
//fill(255);
//noStroke();
//ellipse(width/2, height/2, 500, 500);
//stroke(0);
//strokeWeight(0.9);
for (VSpring s : physics2.springs) {

line(s.a.x, s.a.y, s.b.x, s.b.y);
}
//saveFrame(“screen-####.jpg”);
}

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s