Raphs Emergence Project
From Physical Programming
Contents |
The Initial Idea
My Emergence project is based around a school of fish. The plan is to create a simulation of a school of fish. The fish will react to ehttp://www.openobject.org/physicalprogramming/skins/common/images/button_italic.pngnvironment factors such as other fish & predetors. As well as multiply, get larger and group together based on factors such as size and age.
progression through processing
My initial idea for a project was based on creating a school of fish in processing. Initially I had thought about doing it in quartz to utilise a physical programming language. However after actually using quartz and processing I immediately realised that my project was much better suited to being created in processing.
So I began along the path of using processing in an attempt to create my emergent fish. This is my first foray into anything more complex in computer programming than HTML. Getting my head around the idea of classes and arrays was a very steep learning curve.
In the beginning I started out attempting to get objects moving through a 3D space. Over the course of the semester I have written a series of small processing scripts that explore movement in 3D space. This movement is constrained by a set of 3 Trigonometric equations.
Initially I started out with JPGs as instances and by the end of the semester I have progressed to 3D cubes, which are controlled by an array and are individual objects, in 3D space.
As I progressed it became apparent to me that my Emergent Fish were not going to become a reality within the time frame. So I refocused my project on a theme that has been running through each one of my processing scripts since day one. Patterns. The patterns initially started off as completely random.
initial script one
/**
* lerning to make background react to clicks * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. */
void setup () {
size (500, 400);
background (112,112,200);
}
void draw() {
if (mousePressed && (mouseButton == LEFT)) {
background(112,112,10);
}
else if (mousePressed && (mouseButton == RIGHT)) {
background(112,112,200);
} }
initial script two
/**
* rectangles that are emergent based on color of other rectangles * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. */
//setting variablez & setup
float a, need, cx, cy, cz;
void setup () {
size (500,500); background(255, 255, 255); frameRate(10); a = random(100);
}
//creating a function that refreshes the screen void clear () {
background (255,255,255);
}
//trying to create the reaction to the last squares colour - using random function to generate initail colours // first attmpt at if statements //maybe I could create something simliar to game of life but based on color // creating the squares
void draw () {
clear();
if (a > 50) {
cx = random(127);
cy = random(127);
cz = random(127);
} else {
cx = random(255); cy = random(255); cz = random(255);
}
rect (mouseX,mouseY,100,100); fill (cx,cy,cz);
}
Birds
Number 1 bird script
/**
* images of birds that create patterns * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. * Basis for code Simple 3D Bird by Ira Greenberg. * Triginomitry functions create the position of the rectangles */
float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0; float px = random(1000), py = random(1000), pz = random(1000);
PImage b; PImage a;
void setup () {
size (800, 800, P3D);
frameRate(30);
b = loadImage("bird.jpg");
a = loadImage("bird2.jpg");
background(random(255),random(255),random(255));
}
void draw () {
//flight px = tan(radians(ang3))*170; py = cos(radians(ang3))*300; pz = sin(radians(ang4))*500; translate(width/10+px, height/2+py, -800+pz); rotateX(sin(radians(ang2))*120); rotateY(cos(radians(ang2))*50); rotateZ(sin(radians(ang2))*65); pushMatrix(); image (b, mouseY + 40, py); popMatrix (); ang2+=.01; ang3+=2; ang4+=.75;
}
Number 2 bird script
/**
* images of birds that create patterns * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. * Basis for code Simple 3D Bird by Ira Greenberg. * Triginomitry functions create the position of the rectangles */
float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0; float px = 0, py = 0, pz = 0;
PImage b; PImage a;
void setup () {
size (800, 800, P3D);
frameRate(30);
b = loadImage("bird.jpg");
a = loadImage("bird2.jpg");
}
void draw () {
//flight px = sin(radians(ang3))*170; py = cos(radians(ang3))*300; pz = sin(radians(ang4))*500; translate(width/2+px, height/2+py, -700+pz); rotateX(sin(radians(ang2))*120); rotateY(sin(radians(ang2))*50); rotateZ(sin(radians(ang2))*65); pushMatrix(); image (a, mouseY, mouseX); popMatrix (); pushMatrix(); image (b, mouseY + 40, py); popMatrix (); ang2+=.01; ang3+=2; ang4+=.75;
}
Number 3 bird script
/**
* images of birds that create patterns * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. * Basis for code Simple 3D Bird by Ira Greenberg. * Triginomitry functions create the position of the rectangles */
float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0; float px = random(1000), py = random(10), pz = random(30);
PImage b; PImage a;
void setup () {
size (800, 800, P3D);
frameRate(30);
b = loadImage("bird.jpg");
a = loadImage("bird2.jpg");
background(random(255),random(255),random(255));
}
void draw () {
//flight px = tan(radians(ang3))*170; py = cos(radians(ang3))*300; pz = sin(radians(ang4))*500; translate(width/10+px, height/2+py, -800+pz); rotateX(sin(radians(ang2))*120); rotateY(cos(radians(ang2))*50); rotateZ(sin(radians(ang2))*65); pushMatrix(); image (b, mouseY + random(40), py); popMatrix (); ang2+=.01; ang3+=2; ang4+=.75;
}
More pattern madness
Pattern Madness 01
float px, py, pz, fx, x, y, ang = 0, ang2 = 0, ang3 = 0, ang4 = 0, xpos, ypos, cone, ctwo, cthree, fxtotal, amount; int fxother;
square in123;
void setup() {
size (500, 500, P3D); background (255, 255, 255); frameRate (25); cone = random(255); ctwo = random(255); cthree = random(255); fx = color (cone, ctwo, cthree); fxtotal= (cone + ctwo + cthree); amount = 4; in123 = new square(fxother, fxtotal, px, py, cone, ctwo, cthree, ang, ang2, ang3, ang4); noStroke();
}
class square {
square(color fxother, float fxtotal, float px,float py,float cone,float ctwo,float cthree, float ang, float ang2, float ang3, float ang4){
px = sin(radians(ang3))*170;
py = cos(radians(ang3))*300;
pz = sin(radians(ang4))*500;
translate(width/2+ px, height/2+py, -700+pz);
rotateX(sin(radians(ang2))*120);
rotateY(sin(radians(ang2))*50);
rotateZ(sin(radians(ang2))*65);
pushMatrix();
rect(px, py, 10, 10);
fill(cone, ctwo, cthree);
popMatrix();
if (fxtotal < 382) {
fx = color(cone + 10,ctwo + 10,cthree + 10);
}
else {
fx = color(cone -= 10, ctwo -= 10, cthree -= 10);
}
}
}
void draw () {
in123 = new square(fxother, fxtotal, px, py, cone, ctwo, cthree, ang, ang2, ang3, ang4); ang2+=.01; ang3+=2; ang4+=.75;
}
Pattern madness 02
/**
* the rectangle donut * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. * Basis for code Simple 3D Bird by Ira Greenberg. * Triginomitry functions create the position of the rectangles */
float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0, ang01 = random(360); float px = random(1000), py = random(10), pz = random(30);
void setup () {
size (800, 800, P3D); background(255,255,255); noStroke();
}
void draw () {
rotateY(radians(ang01)); rotateX(radians(ang01)); color one = color(random(255),random(255),random(255)); color two = color(random(255),random(255),random(255)); color cool = blendColor(one, two, EXCLUSION);
//pattern px = sin(radians(ang3))*170; py = cos(radians(ang3))*300; pz = sin(radians(ang4))*500; translate(width/2+ px, height/2+py, -700+pz); rotateX(sin(radians(ang2))*120); rotateY(sin(radians(ang2))*50); rotateZ(sin(radians(ang2))*65); rect(20,20,20,20); fill(cool); pushMatrix(); rotateY(sin(radians(ang))*20); rotateX(cos(radians(ang))*-20); rect(px, random(.5), py, random(.5)); popMatrix(); ang2+=random(100); ang3+=random(100); ang4+=random(100); ang01++; loop();
}
Pattern Madness 3
/**
* rectangles with outlines and reacting to mouse position * by Raphael Goldsworthy. * RMIT University - Physical Programming - Sem 1 2008. * Basis for code Simple 3D Bird by Ira Greenberg. * Triginomitry functions create the position of the rectangles */
float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0; float px = random(1000), py = random(10), pz = random(30);
void setup () {
size (800, 800, P3D); frameRate(30); background(random(255),random(255),random(255));
}
void draw () {
//flight px = tan(radians(ang3))*170; py = cos(radians(ang3))*300; pz = sin(radians(ang4))*500; translate(width/10+px, height/2+py, -800+pz); rotateX(sin(radians(ang2))*120); rotateY(cos(radians(ang2))*50); rotateZ(sin(radians(ang2))*65); rect(20,100,20,100); fill(random(225), random(255), random(255)); pushMatrix(); rotateY(sin(radians(ang))*-20); rect(px, mouseY + random(40), py, mouseX); popMatrix(); ang2+=random(2); ang3+=random(2); ang4+=random(2);
}
snap shots of various experiments
The Final works
The final outcome for this project is a set of 3D cubes that move through space. The cubes create patterns and I have introduced a measure of user interactivity via the mouse. Their movement is constrained by 3 Trigonometric equations. The angles of rotation of the cubes in space are also constrained by these equations.
The patterns can also be recorded by using the keyboard. One record can be produced each time the program runs. The record output is a DFX file. This allows a 3D span shot of the pattern at a particular moment in time. The DFX file can then be loaded into a 3D program, capable of reading DFX files, so that the snap shot of the pattern can be explored by the viewer. This also means that not only can the pattern be explored; it can also be altered or expanded upon by the user to create further work.
Media:dxfs.zip - two dxfs generated from my processing scripts view in you fav 3D program - eg: blender








