Mercurial > hg > soniczoomios
changeset 6:34eba1046890
Scroll stopping sorted out.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 06 Dec 2012 13:55:58 +0000 |
parents | 5ee5ef99e117 |
children | 845ea04f8e33 |
files | testApp.h testApp.mm |
diffstat | 2 files changed, 27 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/testApp.h Wed Dec 05 18:42:02 2012 +0000 +++ b/testApp.h Thu Dec 06 13:55:58 2012 +0000 @@ -34,7 +34,7 @@ TwoVector prevTouch1; bool xLocked, yLocked; - int framesSinceLastScroll; + unsigned int lastMoveTime; TwoVector moveVel; // velocity at which we were moving the grid
--- a/testApp.mm Wed Dec 05 18:42:02 2012 +0000 +++ b/testApp.mm Thu Dec 06 13:55:58 2012 +0000 @@ -17,8 +17,7 @@ sender.setup( HOST, PORT ); ofSetFrameRate(30); // reciever - framesSinceLastScroll = 0; - + lastMoveTime = ofGetSystemTimeMicros(); prevTouchX = 0; prevTouchY = 0; @@ -341,7 +340,7 @@ theGridView.zoom(zoomVel + 1.0); // +1 because zoomVel factor is + or - , wheras zoom is a multiplier near 1 zoomVel = zoomVel*slowFactor; } - framesSinceLastScroll++; + } //-------------------------------------------------------------- void testApp::sendOSCParams(){ @@ -451,8 +450,7 @@ //-------------------------------------------------------------- void testApp::handleScroll(){ - - + TwoVector move = touch0 - prevTouch0; if(yLocked){ move.y = 0.0; @@ -461,7 +459,16 @@ move.x = 0.0; } - moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38)* (1.0/(float)framesSinceLastScroll); // use the time + // check time since last move - if + unsigned int moveTime = ofGetSystemTimeMicros(); + if(moveTime - lastMoveTime > 100000){ + moveVel = TwoVector(); // zero + }else{ + moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38); // use the time + + } + lastMoveTime = moveTime; + prevMove2 = prevMove; prevMove = move; @@ -472,7 +479,6 @@ // and get new parameter values setAllGUISliders(theGridView.getParams()); sendParametersToPD(); - framesSinceLastScroll = 0; } //-------------------------------------------------------------- void testApp::handleZoom(){ @@ -515,6 +521,19 @@ prevTouch1.setCoord(0,0); + + } + if(numActiveTouches == 0){ + // check time since last move + // check time since last move - if + unsigned int moveTime = ofGetSystemTimeMicros(); + if(moveTime - lastMoveTime > 100000){ + moveVel = TwoVector(); // zero + }else{ + moveVel = (move*0.3 + prevMove*0.34 + prevMove2*0.38); // use the time + + } + lastMoveTime = moveTime; } }