problem with reactivision fid volume
in
Contributed Library Questions
•
7 months ago
hi guy's
I wrote a program based on tuiodemo. on the side of the fiducial, I have a volume. volume function works with tcur.getY (); tcur.getY () works with the height of the window of the program.
(0 at the top and 1 at the bottom of screen)
if I put the finger on top of the screen, the circle go to the top of the arc, if I put my finger on down of the screen, the circle go to the bottom of the arc.
tcur.getY (); must work with the height of the arc next to the fiducial
So if I put the finger on the top of the arc, the circle must go to the top of the arc
and if I should put the finger on the bottom of the arc, the circle must go to the bottom of the arc
look the problem with TUIO simulator
Thx
this is the code;
I wrote a program based on tuiodemo. on the side of the fiducial, I have a volume. volume function works with tcur.getY (); tcur.getY () works with the height of the window of the program.
(0 at the top and 1 at the bottom of screen)
if I put the finger on top of the screen, the circle go to the top of the arc, if I put my finger on down of the screen, the circle go to the bottom of the arc.
tcur.getY (); must work with the height of the arc next to the fiducial
So if I put the finger on the top of the arc, the circle must go to the top of the arc
and if I should put the finger on the bottom of the arc, the circle must go to the bottom of the arc
look the problem with TUIO simulator
Thx
this is the code;
- import TUIO.*;
- TuioProcessing tuioClient;
- // these are some helper variables which are used
- // to create scalable graphical feedback
- int circlex=25;
- int circley=-2;
- int circleSize = 60;
- int SIZE = 69;
- float tobjAngle;
- float xpos,ypos;
- float yposTcur, yposTcur1,yposTcur2;
- float circleX, circleY;
- float angle,angle1;
- float BPM = 120;
- float millisPerBeat = 1000/(BPM/60.0);
- 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();
- smooth();
- loop();
- 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(125,125,255);
- textFont(font,18*scale_factor);
- Tobject();
- }
- // 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();
- }
- void Tobject()
- {
- float obj_size = object_size*scale_factor;
- Vector tuioObjectList = tuioClient.getTuioObjects();
- for (int i=0;i<tuioObjectList.size();i++) {
- TuioObject tobj = (TuioObject)tuioObjectList.elementAt(i);
- noStroke();
- tobjAngle = tobj.getAngle();
- if (+tobj.getSymbolID() == 0) {
- pushMatrix();
- fill (0,0,255);
- translate(tobj.getScreenX(width),tobj.getScreenY(height));
- fidgui();
- gain();
- rotate(tobj.getAngle());
- bezierRect(-obj_size/2,-obj_size/2,obj_size,obj_size,2,2);
- popMatrix();
- }
- else if (+tobj.getSymbolID() == 1) {
- pushMatrix();
- fill (255,0,0);
- translate(tobj.getScreenX(width),tobj.getScreenY(height));
- fidgui();
- gain();
- rotate(tobj.getAngle());
- bezierRect(-obj_size/2,-obj_size/2,obj_size,obj_size,2,2);
- popMatrix();
- }
- }
- }
- void bezierRect(float x, float y, float w, float h, float xr, float yr) {
- float w2=w/2f, h2=h/2f, cx=x+w2, cy=y+h2;
- beginShape();
- vertex(cx,cy-h2);
- bezierVertex(cx+w2-xr, cy-h2, cx+w2, cy-h2+yr, cx+w2, cy);
- bezierVertex(cx+w2, cy+h2-yr, cx+w2-xr, cy+h2, cx, cy+h2);
- bezierVertex(cx-w2+xr, cy+h2, cx-w2, cy+h2-yr, cx-w2, cy);
- bezierVertex(cx-w2, cy-h2+yr, cx-w2+xr, cy-h2, cx, cy-h2);
- endShape();
- }
- void octogone()
- {
- float obj_size = object_size*scale_factor;
- rect(-obj_size/2,-obj_size/2,obj_size,obj_size);
- rotate(PI/4.0);
- rect(-obj_size/2,-obj_size/2,obj_size,obj_size);
- }
- void gain() {
- float obj_size = object_size*scale_factor;
- pushMatrix();
- pushStyle();
- fill(255,255,255,230);
- noStroke();
- float X = SIZE / 2 * cos(angle);
- float Y = SIZE / 2 * sin(angle);
- circleX = obj_size-38.5+X;
- circleY = obj_size-39+Y;
- ellipse(circleX, circleY, SIZE / 5, SIZE / 5);
- popStyle();
- popMatrix();
- Vector tuioCursorList = tuioClient.getTuioCursors();
- for (int i=0;i<tuioCursorList.size();i++) {
- TuioCursor tcur = (TuioCursor)tuioCursorList.elementAt(i);
- Vector pointList = tcur.getPath();
- angle = tcur.getY(); //there is the problem
- angle = map(angle,0,1.0,-0.7,0.6);
- angle = constrain(angle,-0.7,0.6);
- }}
- void fidgui() {
- float obj_size = object_size*scale_factor;
- float a = map(tobjAngle,0,6.30,1.5,4.8);
- pushStyle();
- noFill();
- stroke(255,255,255,130);
- strokeWeight(4);
- strokeCap(ROUND);
- arc(-obj_size/2+18,-obj_size/2+18,70,70,1.5,4.8);
- arc(-obj_size/2+18,-obj_size/2+18,70,70,1.5,(a)%4.8);
- arc(-obj_size/2+18,-obj_size/2+18,70,70,5.5,7);
- pushStyle();
- fill(255,255,255,230);
- noStroke();
- ellipse(circleX, circleY, SIZE / 5, SIZE / 5);
- popStyle();
- pushStyle();
- noStroke();
- fill(255,255,255,130);
- ellipse(-obj_size/2+34,-obj_size/2+50,15,15);
- popStyle();
- popStyle();
- }
1