Skip to content
Snippets Groups Projects
Commit fa4f9469 authored by Jonathan Lane-Smith's avatar Jonathan Lane-Smith
Browse files

Add ability to have multiple windows

parent 6aaea726
No related branches found
No related tags found
No related merge requests found
......@@ -87,11 +87,11 @@ public class BowModel extends Model {
Vel_x.add(s.getAvatarVelocityX());
Acc_x.add(0.0);
world.draw();
//world.draw();
}
void draw_graphics() {
world.draw();
//world.draw();
}
......
......@@ -76,6 +76,11 @@ class CircleModel extends Model {
PShape pGraph, joint, endEffector;
CircleModel() {
this(false);
}
CircleModel(boolean isWindow) {
super(isWindow);
/* visual elements setup */
background(0);
......
public class Model {
public class Model extends PApplet {
protected PVector posEE;
protected PVector forceEE;
protected float[] message = {};
......@@ -8,10 +8,32 @@ public class Model {
forceEE = new PVector(0, 0);
}
Model(boolean isWindow) {
super();
posEE = new PVector(0, 0);
forceEE = new PVector(0, 0);
if (isWindow) {
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
}
}
public PVector get_force() { return forceEE; }
public float[] get_message() { return message; }
public void set_data(float[] angles, float[] pos) { posEE.set(pos); }
public void draw_graphics() {}
void settings() {
size(1000, 650);
}
void setup() {
background(255);
}
void draw() {
background(255);
draw_graphics();
}
}
class PluckMaterial {
float topY, bottomY, centerX;
PluckMaterial(float _topY, float _bottomY, float _centerX) {
topY = _topY;
bottomY = _bottomY;
centerX = _centerX;
}
void draw_graphics(PVector posEE) {
noFill();
stroke(0);
strokeWeight(5);
float cx = map(centerX, -1, 1, 0, width);
float px = map(posEE.x, -1, 1, 0, width);
beginShape();
curveVertex(cx, topY*height);
curveVertex(cx, topY*height);
if (posEE.x != 0) {
curveVertex(px, posEE.y*height);
}
curveVertex(cx, bottomY*height);
curveVertex(cx, bottomY*height);
endShape();
}
}
......@@ -10,7 +10,11 @@ class StringModel extends Model {
float pluckDist = 0.05;
StringModel(Range _range) {
super();
this(_range, false);
}
StringModel(Range _range, boolean isWindow) {
super(isWindow);
material = new PluckMaterial(0, 1, 0);
vel = new PVector(0, 0);
newVel = new PVector(0, 0);
......@@ -80,4 +84,34 @@ class StringModel extends Model {
}
circle(posEE.x*width + width/2, posEE.y*height, 10);
}
class PluckMaterial {
float topY, bottomY, centerX;
PluckMaterial(float _topY, float _bottomY, float _centerX) {
topY = _topY;
bottomY = _bottomY;
centerX = _centerX;
}
void draw_graphics(PVector posEE) {
println("draw string crphaics");
noFill();
stroke(0);
strokeWeight(5);
float cx = map(centerX, -1, 1, 0, width);
float px = map(posEE.x, -1, 1, 0, width);
beginShape();
curveVertex(cx, topY*height);
curveVertex(cx, topY*height);
if (posEE.x != 0) {
curveVertex(px, posEE.y*height);
}
curveVertex(cx, bottomY*height);
curveVertex(cx, bottomY*height);
endShape();
}
}
}
......@@ -17,15 +17,15 @@ boolean OSC = true;
void setup() {
println(Serial.list());
//leftHaply = new Haply(this, 3, new BowModel(this));
rightHaply = new Haply(this, 3, new StringModel(new Range(0.095, -0.095, 0.022, 0.149)));
leftHaply = new Haply(this, 0, new CircleModel(true));
rightHaply = new Haply(this, 3, new StringModel(new Range(0.2, -0.2, 0.0225, 0.1527), true));
//leftHaply = new FakeHaply(new StringModel(new Range(0.095, -0.095, 0.022, 0.149)));
Model modelA = new StringModel(new Range(0.095, -0.095, 0.022, 0.149));
Model modelB = new BowModel(this);
leftHaply = new FakeHaply(new MergeModel(modelA, modelB));
//rightHaply = new Haply(this, 3, new MergeModel(modelA, modelB));
size(1000, 650);
frameRate(baseFrameRate);
if (OSC) {
......@@ -42,8 +42,7 @@ void setup() {
}
void draw() {
if (leftHaply != null) leftHaply.draw_graphics();
if (rightHaply != null) rightHaply.draw_graphics();
}
void addMessage(OscBundle bundle, float[] content, String addr) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment