Please, I need hepl !!!!
in
Contributed Library Questions
•
1 year ago
Hello mates,
I am new here and I want to ask you something, which is for you probably not a big deal. So I want to match Tuio (Reactivision fiducial markers) with a processing code from processing. so I added the library and so on, everything works perfect. So, now i wrote a code unter processing , which simulates a couple of blue rings with a yellow point in the middle. The only thing I want is to integrate that code in the default Tuio_Demo code, so I have these rings with the point in the middle instead of the black rectangles which are shown everytime i play with the fiducial markers fromt the Tuio in front of the camera ). I hope you could help me to make my homework on time!
So, the default code Tuio_Demo (i will delete the things with cursor and so on, because i dont need the finger touching:
import TUIO.*;
TuioProcessing tuioClient;
// these are some helper variables which are used
// to create scalable graphical feedback
float cursor_size = 15;
float object_size = 60;
float table_size = 760;
float scale_factor = 1;
PFont font;
void setup()
{
//size(screen.width,screen.height);
size(640,480);
noStroke();
fill(0);
loop();
frameRate(30);
//noLoop();
hint(ENABLE_NATIVE_FONTS);
font = createFont("Arial", 18);
scale_factor = height/table_size;
// we create an instance of the TuioProcessing client
// since we add "this" class as an argument the TuioProcessing class expects
// an implementation of the TUIO callback methods (see below)
tuioClient = new TuioProcessing(this);
}
// within the draw method we retrieve a Vector (List) of TuioObject and TuioCursor (polling)
// from the TuioProcessing client and then loop over both lists to draw the graphical feedback.
void draw()
{
background(255);
textFont(font,18*scale_factor);
float obj_size = object_size*scale_factor;
float cur_size = cursor_size*scale_factor;
Vector tuioObjectList = tuioClient.getTuioObjects();
for (int i=0;i<tuioObjectList.size();i++) {
TuioObject tobj = (TuioObject)tuioObjectList.elementAt(i);
stroke(0);
fill(0);
pushMatrix();
translate(tobj.getScreenX(width),tobj.getScreenY(height));
rotate(tobj.getAngle());
rect(-obj_size/2,-obj_size/2,obj_size,obj_size);
popMatrix();
fill(255);
text(""+tobj.getSymbolID(), tobj.getScreenX(width), tobj.getScreenY(height));
}
}
// these callback methods are called whenever a TUIO event occurs
// called when an object is added to the scene
void addTuioObject(TuioObject tobj) {
println("add object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle());
}
// called when an object is removed from the scene
void removeTuioObject(TuioObject tobj) {
println("remove object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+")");
}
// called when an object is moved
void updateTuioObject (TuioObject tobj) {
println("update object "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle()
+" "+tobj.getMotionSpeed()+" "+tobj.getRotationSpeed()+" "+tobj.getMotionAccel()+" "+tobj.getRotationAccel());
}
// called when a cursor is added to the scene
void addTuioCursor(TuioCursor tcur) {
println("add cursor "+tcur.getCursorID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY());
}
// called when a cursor is moved
void updateTuioCursor (TuioCursor tcur) {
println("update cursor "+tcur.getCursorID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY()
+" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel());
}
// called when a cursor is removed from the scene
void removeTuioCursor(TuioCursor tcur) {
println("remove cursor "+tcur.getCursorID()+" ("+tcur.getSessionID()+")");
}
// called after each message bundle
// representing the end of an image frame
void refresh(TuioTime bundleTime) {
redraw();
}
And here is my code:
int segs = 2;
int steps = 6;
float rotAdjust = PI/60 / segs / 2;
float radius;
float segWidth;
float interval = TWO_PI / segs;
void setup() {
size(1024, 768);
background(255);
smooth();
noLoop();
stroke(57,193,190,300);
strokeWeight(15);
// make the diameter 90% of the sketch area
radius = 200;
segWidth = radius / 5;
draw();
}
void draw() {
for (int j = 0; j < segs; j++) {
color[] cols = {
color(55,55,55,20),
color(55,55,55,20),
};
fill(254,255,0);
arc(512, 384, 80, 80, PI/2, PI);
fill(254,255,0);
arc(512, 384, 80, 80, 0, PI/2);
fill(254,255,0);
arc(512, 384, 80, 80, TWO_PI-PI/2, TWO_PI);
fill(254,255,0);
arc(512, 384, 80, 80, PI, TWO_PI-PI/2);
for (int i = 0; i < segs; i++) {
fill(cols[i]);
arc(width/2, height/2, radius, radius,
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
}
radius -= segWidth;
}
}
thank you
1