diff options
| -rw-r--r-- | gui/src/chainImage.cpp | 126 | ||||
| -rw-r--r-- | gui/src/chainImage.h | 9 | ||||
| -rw-r--r-- | gui/src/chainImageSet.cpp | 34 | ||||
| -rw-r--r-- | gui/src/chainImageSet.h | 2 | ||||
| -rw-r--r-- | gui/src/ofApp.cpp | 23 | ||||
| -rw-r--r-- | gui/src/ofApp.h | 2 |
6 files changed, 185 insertions, 11 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp index 7192fdc..61ea55d 100644 --- a/gui/src/chainImage.cpp +++ b/gui/src/chainImage.cpp @@ -1,8 +1,5 @@ #include "chainImage.h" -#define min(a,b) ((a) < (b) ? (a) : (b)) -#define max(a,b) ((a) > (b) ? (a) : (b)) - float distance(ofPoint p1,ofPoint p2){ return pow(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2),0.5); } @@ -155,7 +152,7 @@ int chainImage::updateOutput(float decayRatio){ ofPoint previous=getLinkPos()+(rotated_destination*getLinkScale()*(1.0f-BEZIER_IN)); path.bezierTo( - getLinkPos().x*(1.0f+(BEZIER_OUT*linkScale)),getLinkPos().y*(1.0f+(BEZIER_OUT*linkScale)), + getLinkPos().x*(1.0f+(BEZIER_OUT*linkScale)),getLinkPos().y*(1.0f+(BEZIER_OUT*linkScale)) , previous.x,previous.y, destination.x,destination.y); @@ -220,7 +217,35 @@ float chainImage::getRotation(){ //linkRot is no longer seen //return linkRot+(transition*link->linkRot); //linkRot+ - return getLinkRot()+rotationTimeline.getPointAtPercent(transition).y; + //return getLinkRot()+rotationTimeline.getPointAtPercent(transition).y; + + //it doesn't seem that beziers are useful for this unless we can intersect a line +/* vector<ofPolyline> rv; + rv.push_back(rotationTimeline); + ofxSweepLine Sweep= ofxSweepLine(rv); + ofPolyline line; + line.addVertex(transition,-1.0f); + line.addVertex(transition,357.0f); + vector<ofPolyline> lv; + lv.push_back(line); + vector<ofVec2f> result=Sweep.sweep(lv); + + printf("ofxSweepLine: got %f intersections\n",result.size()); + + if (result.size()) { + return result[0].y; + } + + ofxSweepLine crashes + */ + + float transitionInterpolated=pow(transition,ROTATION_EASE_POWER); + + //printf("rotation: %f at point %f\n",transitionInterpolated,transition); + + + return getLinkRot()+(transitionInterpolated*link->getLinkRot()); + }; ofPoint chainImage::getLinkPos(){ return linkPos+dragPos; @@ -259,7 +284,98 @@ void chainImage::makeThumbnail(){ thumbnail.setAnchorPoint(thumbnail.getWidth()/2,thumbnail.getHeight()/2); } +/* +void chainImage::drawRecursive(float fadeIn,bool additive,float intensity,float zoomMultiplier, float fadeStart, float fadeEnd){ + + //printf("Drawing chain transition: %f\n",transition); + //we are correctly geting to 1 + //the transformw don't quite add up? + //we are drawing each image twice? + + float thisAmount=max(0.0,min(1.0((transition-fadeStart)/(fadeEnd-fadeStart))))*intensity; + + (0,1) , 0 = 0 + (0,1) , 0.5 = 0.5 + (0,1) , 1.0 = 1.0 + (0.5,1) , 0 = 0.0 + (0.5,1) , 0.5 = 0.0 + (0.5,1) , 0.75 = 0.5 + (0.5,1) , 1.0 = 1.0 + (0,2) , 0 = 0 + (0,2) , 1 = 0.5 + (0,2) , = 0.5 + + glPushMatrix(); + + if (thisAmount>0){ + + if (additive){ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + ofSetColor(255,255,255,255*thisAmount); + } + else { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + ofSetColor(255,255,255,255*intensity); + } + + //ofDisableAlphaBlending(); + + setAnchorPoint(getWidth()/2,getHeight()/2); + + draw(0,0,getWidth(),getHeight()); + //the animated transform of the zoom is set before calling the first image + + //add a scale factor to the outgoing image that builds up over the transition + + +// glPushMatrix(); +// //if this is linear we see the jump from the unaccelerated phase +// //float zoomFactor=((zoomMultiplier-1.0f)*transition)+1.0f; + +// //this is worse why? +// float zoomFactor=pow(zoomMultiplier,1.0f+transition); + +// glScalef(zoomFactor,zoomFactor,zoomFactor); + +// //ofSetColor(colour); + + +// glPopMatrix(); + + + } + + if (fadeEnd>1.0){ + + glTranslatef(getLinkPos().x,getLinkPos().y,0); + + glRotatef(getLinkRot(),0,0,1); + + glScalef(getLinkScale(),getLinkScale(),getLinkScale()); + + //ofEnableAlphaBlending(); + glEnable(GL_BLEND); + + ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity); + + //link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2); + + //ofSetColor(link->colour); + //link->draw(0,0,link->getWidth(),link->getHeight()); + + link->drawRecursive(fadeIn,additive,intensity,zoomMultiplier,fadeStart-1.0f,fadeEnd-1.0f); + + glDisable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + } + + glPopMatrix(); +} +*/ void chainImage::drawChain(float fadeIn,bool additive,float intensity,float zoomMultiplier){ //printf("Drawing chain transition: %f\n",transition); diff --git a/gui/src/chainImage.h b/gui/src/chainImage.h index 2567e3c..b318c79 100644 --- a/gui/src/chainImage.h +++ b/gui/src/chainImage.h @@ -3,12 +3,16 @@ #include "ofMain.h" #include "ofxJSON.h" +#define min(a,b) ((a) < (b) ? (a) : (b)) +#define max(a,b) ((a) > (b) ? (a) : (b)) + #define THUMB_BORDER_RATIO 0.8 #define THUMB_SIZE 160 #define DEFAULT_FADEIN 1.0 #define BEZIER_OUT 0.5 #define BEZIER_IN 0.5 -#define ROTATION_BEZIER_FRACTION 0.2 +#define ROTATION_BEZIER_FRACTION 0.0 +#define ROTATION_EASE_POWER 3.0 #define SWITCH_NONE 0 #define SWITCH_FORWARD 1 @@ -63,6 +67,9 @@ class chainImage : public ofImage{ void gpu_drawChain(float fadeIn=DEFAULT_FADEIN,bool additive =false, float intensity=1.0f, float zoomMultiplier=1.0f); void gpu_drawImage(); + void drawRecursive(float fadeIn,bool additive,float intensity,float zoomMultiplier, float fadeStart, float fadeEnd); + + ofImage thumbnail; void makeThumbnail(); void setupTextures(); diff --git a/gui/src/chainImageSet.cpp b/gui/src/chainImageSet.cpp index 65ea5f9..e5c4ca6 100644 --- a/gui/src/chainImageSet.cpp +++ b/gui/src/chainImageSet.cpp @@ -1,5 +1,15 @@ #include "chainImageSet.h" +//alternative algorithm +//allow more images, and fade them up before they become full screen +//possibly do no fading.. just draw until down to a single pixel + +//retouch canal images +//practice wth controller + +//control the fadein +// + void chainImageSet::drawOutput(){ float camera_throw= (float)outputSize.y/(float)outputSize.x; //the ratio of z distance to x width @@ -27,7 +37,9 @@ void chainImageSet::drawOutput(){ (*currentImage)->getTransform().x*4 ); */ - glScalef(8,8,8); //easy way to limit camera cutoff + glScalef(ZOOM_FUDGE_FACTOR,ZOOM_FUDGE_FACTOR,ZOOM_FUDGE_FACTOR); //easy way to limit camera cutoff + + printf("drawing rotation %f for transition %f\n",(*currentImage)->getRotation(),(*currentImage)->transition); gluLookAt( (*currentImage)->getTransform().x, (*currentImage)->getTransform().y, // i1.linkPos.y+(xform.y*intervalpoint), @@ -484,8 +496,24 @@ void chainImageSet::mouseDragged(int x, int y, int button){ //-------------------------------------------------------------- void chainImageSet::mousePressed(int x, int y, int button){ - //todo: select - clickPoint=ofPoint(x,y); + + if (button==OF_MOUSE_BUTTON_4){ + int toSelect=max(0,x/(((*selected)->thumbnail.getWidth())*1.2)); + if (toSelect<images.size()){ + currentImage=images.begin(); + int counter=toSelect; + while(counter>0){ + currentImage++; + counter--; + } + + ofLogNotice() << "Selected image " << toSelect << " :" << (*currentImage)->filename; + + (*currentImage)->start(false); + (*currentImage)->updateOutput(decayFactor); + } + } + else clickPoint=ofPoint(x,y); } //-------------------------------------------------------------- diff --git a/gui/src/chainImageSet.h b/gui/src/chainImageSet.h index 6620923..58734be 100644 --- a/gui/src/chainImageSet.h +++ b/gui/src/chainImageSet.h @@ -4,6 +4,8 @@ #include "threadedChainImageLoader.h" #include "threadedSystemDialogs.h" +#define ZOOM_FUDGE_FACTOR 5 + class chainImageSet{ public: diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index 43f51f1..cbfb139 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -41,6 +41,8 @@ void ofApp::setup(){ sets[0].init(); sets[1].init(); + + commandPressed=false; } //-------------------------------------------------------------- @@ -256,6 +258,11 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) { //-------------------------------------------------------------- void ofApp::keyPressed(ofKeyEventArgs &args){ + + if (args.key==OF_KEY_COMMAND){ + commandPressed=true; + } + sets[selected_set].keyPressed(args); if(args.key == '\''){ @@ -293,7 +300,9 @@ void ofApp::outputKeyPressed(ofKeyEventArgs &args){ //-------------------------------------------------------------- void ofApp::keyReleased(int key){ - + if (key==OF_KEY_COMMAND){ + commandPressed=false; + } } //-------------------------------------------------------------- @@ -308,7 +317,17 @@ void ofApp::mouseDragged(int x, int y, int button){ //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ - sets[selected_set].mousePressed(x,y,button); + if (commandPressed){ + if (y<200){ + sets[0].mousePressed(x,y,OF_MOUSE_BUTTON_4); + } + else { + sets[1].mousePressed(x,y,OF_MOUSE_BUTTON_4); + } + } + else { + sets[selected_set].mousePressed(x,y,button); + } } //-------------------------------------------------------------- diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index 82db257..03120e4 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -135,4 +135,6 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ float next_update; + bool commandPressed; + }; |
