summaryrefslogtreecommitdiff
path: root/gui/src/chainImage.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2017-10-13 17:20:53 +0100
committerTim Redfern <tim@getdrop.com>2017-10-13 17:20:53 +0100
commit5116dea8815de81ddaef299fdcae15f56ae3a87b (patch)
tree815f04c61b88d2a7e7a612cba194ec8ae0c136ce /gui/src/chainImage.cpp
parent182049bfe89913be4149b3b82ec1154107438406 (diff)
heisenbug
Diffstat (limited to 'gui/src/chainImage.cpp')
-rw-r--r--gui/src/chainImage.cpp107
1 files changed, 80 insertions, 27 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp
index d91a633..4eb0417 100644
--- a/gui/src/chainImage.cpp
+++ b/gui/src/chainImage.cpp
@@ -30,10 +30,48 @@ void chainImage::start(bool reverse){
*/
}
+void chainImage::updateRotationTimeline(){
+
+ rotationTimeline.clear();
+
+ //need to compare 5 points to generate this segment
+
+ //quick and dirty approach, bezier handles take the slope between the
+ //previous and subsequent points, unless it's a horizontal turning point
+
+ //rotation curve always starts at the origin as it's relative to where we have already rotated to
+ rotationTimeline.addVertex(0,0);
+
+ ofPoint cp1,cp2,p;
+
+ if(linked->linkRot==0.0f){ //hmm, shouldn't use float equality
+ cp1=ofPoint(ROTATION_BEZIER_FRACTION, 0);
+ }
+ else {
+ float slope=link->linkRot-linked->linkRot;
+ cp1=ofPoint(ROTATION_BEZIER_FRACTION,slope/ROTATION_BEZIER_FRACTION);
+ }
+
+ if(link->linkRot==link->link->linkRot){ //hmm, shouldn't use float equality
+ cp2=ofPoint(1.0f-ROTATION_BEZIER_FRACTION, link->linkRot);
+ }
+ else {
+ float slope=link->link->linkRot-linkRot;
+ cp2=ofPoint(1.0f-ROTATION_BEZIER_FRACTION, link->linkRot);
+ }
+
+ p=ofPoint(1.0f, link->linkRot);
+
+ rotationTimeline.bezierTo(cp1,cp2,p);
+
+}
+
int chainImage::updateOutput(float decayRatio){
//where there is rotation of the link, the path needs to be rotated
+ updateRotationTimeline();
+
path.clear();
path.addVertex(linkPos);
@@ -112,7 +150,8 @@ float chainImage::getRotation(){
//when we switch image, link->linkRot becomes linkRot
//linkRot is no longer seen
- return linkRot+(transition*link->linkRot); //linkRot+
+ //return linkRot+(transition*link->linkRot); //linkRot+
+ return linkRot+rotationTimeline.getPointAtPercent(transition).y;
};
void chainImage::makeThumbnail(){
thumbnail.setUseTexture(false);
@@ -143,50 +182,64 @@ void chainImage::makeThumbnail(){
thumbnail.setAnchorPoint(thumbnail.getWidth()/2,thumbnail.getHeight()/2);
}
-void chainImage::drawChain(float fadeIn,bool additive, float intensity){
+void chainImage::drawChain(float fadeIn,bool additive,float intensity,float zoomMultiplier){
//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?
glPushMatrix();
- if (additive){
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- ofSetColor(255,255,255,255*(1.0f-min(1.0,transition/fadeIn))*intensity);
- }
- else {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- ofSetColor(255,255,255,255*intensity);
- }
+ if (additive){
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ ofSetColor(255,255,255,255*(1.0f-min(1.0,transition/fadeIn))*intensity);
+ }
+ else {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ ofSetColor(255,255,255,255*intensity);
+ }
- //ofDisableAlphaBlending();
+ //ofDisableAlphaBlending();
-
+
+
+ setAnchorPoint(getWidth()/2,getHeight()/2);
+
+ //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;
- setAnchorPoint(getWidth()/2,getHeight()/2);
+ //this is worse why?
+ float zoomFactor=pow(zoomMultiplier,1.0f+transition);
- draw(0,0,getWidth(),getHeight());
+ glScalef(zoomFactor,zoomFactor,zoomFactor);
- glTranslatef(linkPos.x,linkPos.y,0);
+ draw(0,0,getWidth(),getHeight());
- glRotatef(linkRot,0,0,1);
+ glPopMatrix();
- glScalef(linkScale,linkScale,linkScale);
+ glTranslatef(linkPos.x,linkPos.y,0);
- //ofEnableAlphaBlending();
- glEnable(GL_BLEND);
-
- ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity);
+ glRotatef(linkRot,0,0,1);
- link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2);
+ glScalef(linkScale,linkScale,linkScale);
- link->draw(0,0,link->getWidth(),link->getHeight());
+ //ofEnableAlphaBlending();
+ glEnable(GL_BLEND);
+
+ ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity);
+
+ link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2);
- glDisable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ link->draw(0,0,link->getWidth(),link->getHeight());
+
+ glDisable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPopMatrix();
}