More
See all Show me
4. Υπερφόρμα
4 days ago
3. Superformula
4 days ago
2. reacTable
6 months ago
import tuio.*;

TuiObjectList objectList;
TuiCursorList cursorList;
TuioClient client;

void setup()
{
size(1000,780,P3D);
background(255);
redraw();
objectList = new TuiObjectList();
cursorList = new TuiCursorList();
client = new TuioClient(this);
}

void draw()
{
cursorList.draw();
objectList.draw();
}

// called after each message bundle
void refresh() {
redraw();
}

// called when an object is added to the scene
void addTuiObject(Integer s_id, Integer f_id) {
objectList.activate(s_id,f_id);
//System.out.println("add object "+f_id+" ("+s_id+")");
}

// called when an object is removed from the scene
void removeTuiObject(Integer s_id,Integer f_id ) {
objectList.deactivate(s_id);
//System.out.println("remove object "+f_id+" ("+s_id+")");
}

// called when an object is moved
void updateTuiObject (Integer s_id, Integer f_id, Float xpos, Float ypos, Float angle) {
objectList.update(s_id,(int)(640*xpos.floatValue()),(int)(480*ypos.floatValue()),angle.floatValue());
//System.out.println("update object "+f_id+" ("+s_id+")");
}

// called when a cursor appears the scene
void addTuiCursor(Integer s_id) {
//System.out.println("add cursor "+s_id);
cursorList.add(s_id);
redraw();
}

// called when a cursor is removed from the scene
void removeTuiCursor(Integer s_id) {
//System.out.println("remove cursor "+s_id);
cursorList.remove(s_id);
redraw();
}

// called when a cursor is moved
void updateTuiCursor (Integer s_id, Float xpos, Float ypos) {
//System.out.println("update cursor "+s_id+" "+xpos+" "+ypos);
cursorList.update(s_id,(int)(640*xpos.floatValue()),(int)(480*ypos.floatValue()));
redraw();
}

void mousePressed() {
if (mousePressed == true) {
//u = v =10;
background(255);
}
}

//--------------------------------------------------------------------------------------------------
//helper classes

class TuiObjectList {

java.util.Hashtable objectList;

TuiObjectList() {
textFont(createFont("Sans", 12));
objectList = new Hashtable();
}

void draw() {
Enumeration e = objectList.elements();
while (e.hasMoreElements()) {
((TuiObject)e.nextElement()).draw();
}
}

TuiObject getObject(Integer s_id) {
return (TuiObject)objectList.get(s_id);
}

void activate(Integer s_id, Integer f_id) {
TuiObject nobj = new TuiObject(s_id.intValue(), f_id.intValue());
objectList.put(s_id,nobj);
}

void deactivate(Integer s_id) {
objectList.remove(s_id);
}
void update(Integer s_id, int x, int y, float a) {
TuiObject tobj = (TuiObject)objectList.get(s_id);
if (tobj!=null) tobj.update(x,y,a);
}
}

class TuiObject {
int session_id, fiducial_id;
int xpos, ypos;
float angle;

int dim=1000;
float theta = 283.8;
float R=4,N=100,H=1,P=1.4,L=4,K=1,u=100,v=100;
// radius of tube R
// number of turns N
// height H
// power P
// Controls spike length L
// Controls spike sharpness K
float[] W = new float[dim];
float[] Fx = new float[dim];
float[] Fy = new float[dim];
float[] Fz = new float[dim];

int num = 500;//Arithos Sformon se akthe Sforma
float x,y;
float r,th=0,step=.15;
float m=40,n1=1,n2=1,n3=1;
float b=1,a=1;
int counter=0,counter2=0,epi=400;

TuiObject(int s_id,int f_id) {
session_id = s_id;
fiducial_id = f_id;
xpos = 0;
ypos = 0;
angle = 0.0f;


}

void update(int x, int y, float a) {
xpos=x;
ypos=y;
angle=a;
}

void draw() {


if (fiducial_id == 0) {
//K = map(angle,0,TWO_PI,8,11); // Akyro
L = map(angle,0,TWO_PI,-10,10);
//R = map(xpos,0,width,1,20);
//N = map(ypos,0,height,1,100);

//background(255);
//ellipse(xpos,ypos,100,100);
for (int i = 1; i < dim; i++) {
u = u + .0005;
v = v + .00005;
W[i] = pow((u/(2*PI)*R),0.9);
Fx[i] = W[i]*cos(N*u)*(1+cos(v));
Fy[i] = W[i]*sin(N*u)*(1+cos(v));
Fz[i] = W[i]*(sin(v)+L*pow((sin(v/2)),K)) + H*pow((u/(2*PI)),P);
}
//ellipse(xpos,ypos,100,100);
fill(0,0,23,10);
stroke(10,0,43,5);

pushMatrix();
//translate(width/2,height/2);
translate(2*xpos,2*ypos);
rotateZ(PI/4);
rotateY(PI/4);
//rotateX(PI/2);
rotateX(angle);
scale(.5);
beginShape(TRIANGLES);
for (int j = 1; j < dim; j++) {
vertex(Fx[j],Fy[j],Fz[j]);
}
endShape();
popMatrix();
if (u > 700) {
v = u = 45;

}
redraw();

}
if (fiducial_id == 1) {
counter++;
n1 = angle;
//m = int(map(xpos,0,width,30,40));
//n3 = map(ypos,0,width,.0001,100);
pushMatrix();
translate(width/2,height/2);
beginShape();
for(int i=1; i < num; i++) {
r = epi*pow(((pow(abs(cos(m*th/4)/a),n2))+(pow(abs(sin(m*th/4)/b),n3))),(-1/n1));
th = th + step;
x = r*cos(th);//pow(abs(cos(th)),n1);
y = r*sin(th);//pow(abs(sin(th)),n1);
stroke(0,20);
point(x,y);
point(x+random(2),y+random(2));
}
endShape();
popMatrix();
if (counter == 1000) x=y=r=0;
}
}


}
class TuiCursorList {

java.util.Hashtable cursorList;

TuiCursorList() {
cursorList = new Hashtable();
}

void draw() {
stroke(0,0,255);
Enumeration e = cursorList.elements();
while (e.hasMoreElements()) {
Vector pointList = (Vector)e.nextElement();

if (pointList.size()>0) {
Point start_point = (Point)pointList.elementAt(0);
for (int i=0;i
Credits
Tags
1 Like
This conversation is missing your voice. Take five seconds to join Vimeo or log in.

Sponsored by:

Statistics
  •  
    plays
    likes
    comments
  • Total
    plays 114
    plays 1
    plays 0
  • Dec 2nd
    plays 0
    plays 0
    plays 0
  • Dec 1st
    plays 0
    plays 0
    plays 0
  • Nov 30th
    plays 2
    plays 0
    plays 0
  • Nov 29th
    plays 2
    plays 0
    plays 0
  • Nov 28th
    plays 1
    plays 0
    plays 0
  • Nov 27th
    plays 0
    plays 0
    plays 0
  • Nov 26th
    plays 0
    plays 0
    plays 0
  • Nov 25th
    plays 0
    plays 0
    plays 0
Previous Week

See referrers
Downloads
Please join Vimeo or log in to download the original file. It only takes a few seconds.