tuio dist between object and cursor
in
Contributed Library Questions
•
2 years ago
hi i am trying to detect if the cursor is near an object. i have lost myself in an overly complecated cursor thingy:
- // 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());
- fingerx[tcur.getCursorID()]=tcur.getX()*width;
- fingery[tcur.getCursorID()]=tcur.getY()*height;
- for (int i = 0; i < controls.length; i++) {
- println("lenght= "+controls.length+" "+objectx[i]+" "+fingerx[tcur.getCursorID()]+" "+objecty[i]+" "+fingery[tcur.getCursorID()]+"distance is= "+dist(objectx[i],objecty[i],fingerx[tcur.getCursorID()],fingerx[tcur.getCursorID()]));
- if(objectstatus[i]==1 && visstrob[i]==1 && dist(objectx[i],objecty[i],fingerx[tcur.getCursorID()],fingerx[tcur.getCursorID()])<30) {
- controls[i].arcbutton(1);
- }
- else if(objectstatus[i]==1 && visstrob[i]==1 && dist(objectx[i],objecty[i],fingerx[tcur.getCursorID()],fingerx[tcur.getCursorID()])>30) {
- controls[i].arcbutton(0);
- }
- }
- }
where objectx and so is collected in another rutine.
do anybody have any idea on how to detect if the cursor is near the object?
_____
allways on the lookout for new toys to mod
_____
1