Hello,
I'm working on the code below for a college project. I need to set it up as following but have no idea where to start. The original sketch was not developed by me and can be viewed here: http://www.openprocessing.org/sketch/58970
Basically what I am trying to do is position the dust particles in the center of the stage and remove all mouse interaction.
I am using an Epoc headset with Mind My OSCs to import five readings. What I am hoping to do is use one of the readings (most likely excitement) to control the entire sketch.
Rather than using a mouse click function, I want the sketch to run constantly.
int longness = 10000; This line controls the amount of lines/particles on the canvas and I was wondering if it would be possible to increase and decrease this value based on the headset reading (excitement level).
I have spent days at this and have gotten nowhere. I would appreciate any help you can give me.
Thanks,
Keelan
import oscP5.*;
import netP5.*;
public float engBor = 0; // Engaged/Bored
public float exc = 0; // Excitement
public float excLon = 0; // Excitement Long Term
public float med = 0; // Meditation
public float fru = 0; // Frustration
OscP5 oscP5;
int longness = 10000;
spring[] springs = new spring[longness];
void setup() {
background(0, 0, 0);
size(500, 500, P2D);
colorMode(HSB);
for (int i = 0; i < longness; i++) {
springs[i] = new spring(random(width), random(height), i);
oscP5 = new OscP5(this, 7400);
// plug the OSC messages for the Affectiv values
oscP5.plug(this,"updateEngBor","/AFF/Engaged/Bored");
oscP5.plug(this,"updateExc","/AFF/Excitement");
oscP5.plug(this,"updateExcLon","/AFF/Excitement Long Term");
oscP5.plug(this,"updateMed","/AFF/Meditation");
oscP5.plug(this,"updateFru","/AFF/Frustration");
}
}
void draw() {
if(!keyPressed&&key!='p') {
fill(0, 0, 0, 40);
strokeWeight(10);
rect(0, 0, width, height);
}
if (keyPressed&&key=='p') {//possible cog function to take snapshot
saveFrame("output.png");
}
for (int i = 0; i < longness; i++) {
springs[i] = new spring(random(width), random(height), i);
}
for (int i = 0; i < longness ; i++) {
springs[i].render();
}
}
class spring {
float Xpos;
float Ypos;
float Xvel;
float Yvel;
float Pxpos;
float Pypos;
float colorness;
spring(float tempXpos, float tempYpos, int colortemp) {
Xpos = tempXpos;
Ypos = tempYpos;
colorness = colortemp;
}
void render() {
Xpos += Xvel;
Ypos += Yvel;
if (mousePressed) {
Xvel += (4000 / dist(mouseX, mouseY, Xpos, Ypos) * ((0.009 * (mouseX - Xpos))) / 50);
Yvel += (4000 / dist(mouseX, mouseY, Xpos, Ypos) * ((0.009 * (mouseY - Ypos))) / 50);
} else {
Xvel = Xvel / 1.04;
Yvel = Yvel / 1.04;
}
colorness = dist(Xpos, Ypos, Pxpos, Pypos) * 10;
strokeWeight(2);
fill(colorness, 255, 255);
stroke(colorness, 255, 255, 20);
line(Xpos, Ypos, Pxpos, Pypos);
Pxpos = Xpos;
Pypos = Ypos;
}
}
I'm working on the code below for a college project. I need to set it up as following but have no idea where to start. The original sketch was not developed by me and can be viewed here: http://www.openprocessing.org/sketch/58970
Basically what I am trying to do is position the dust particles in the center of the stage and remove all mouse interaction.
I am using an Epoc headset with Mind My OSCs to import five readings. What I am hoping to do is use one of the readings (most likely excitement) to control the entire sketch.
Rather than using a mouse click function, I want the sketch to run constantly.
int longness = 10000; This line controls the amount of lines/particles on the canvas and I was wondering if it would be possible to increase and decrease this value based on the headset reading (excitement level).
I have spent days at this and have gotten nowhere. I would appreciate any help you can give me.
Thanks,
Keelan
import oscP5.*;
import netP5.*;
public float engBor = 0; // Engaged/Bored
public float exc = 0; // Excitement
public float excLon = 0; // Excitement Long Term
public float med = 0; // Meditation
public float fru = 0; // Frustration
OscP5 oscP5;
int longness = 10000;
spring[] springs = new spring[longness];
void setup() {
background(0, 0, 0);
size(500, 500, P2D);
colorMode(HSB);
for (int i = 0; i < longness; i++) {
springs[i] = new spring(random(width), random(height), i);
oscP5 = new OscP5(this, 7400);
// plug the OSC messages for the Affectiv values
oscP5.plug(this,"updateEngBor","/AFF/Engaged/Bored");
oscP5.plug(this,"updateExc","/AFF/Excitement");
oscP5.plug(this,"updateExcLon","/AFF/Excitement Long Term");
oscP5.plug(this,"updateMed","/AFF/Meditation");
oscP5.plug(this,"updateFru","/AFF/Frustration");
}
}
void draw() {
if(!keyPressed&&key!='p') {
fill(0, 0, 0, 40);
strokeWeight(10);
rect(0, 0, width, height);
}
if (keyPressed&&key=='p') {//possible cog function to take snapshot
saveFrame("output.png");
}
for (int i = 0; i < longness; i++) {
springs[i] = new spring(random(width), random(height), i);
}
for (int i = 0; i < longness ; i++) {
springs[i].render();
}
}
class spring {
float Xpos;
float Ypos;
float Xvel;
float Yvel;
float Pxpos;
float Pypos;
float colorness;
spring(float tempXpos, float tempYpos, int colortemp) {
Xpos = tempXpos;
Ypos = tempYpos;
colorness = colortemp;
}
void render() {
Xpos += Xvel;
Ypos += Yvel;
if (mousePressed) {
Xvel += (4000 / dist(mouseX, mouseY, Xpos, Ypos) * ((0.009 * (mouseX - Xpos))) / 50);
Yvel += (4000 / dist(mouseX, mouseY, Xpos, Ypos) * ((0.009 * (mouseY - Ypos))) / 50);
} else {
Xvel = Xvel / 1.04;
Yvel = Yvel / 1.04;
}
colorness = dist(Xpos, Ypos, Pxpos, Pypos) * 10;
strokeWeight(2);
fill(colorness, 255, 255);
stroke(colorness, 255, 255, 20);
line(Xpos, Ypos, Pxpos, Pypos);
Pxpos = Xpos;
Pypos = Ypos;
}
}
1