diff options
Diffstat (limited to 'futuregael/src/show.h')
| -rw-r--r-- | futuregael/src/show.h | 108 |
1 files changed, 99 insertions, 9 deletions
diff --git a/futuregael/src/show.h b/futuregael/src/show.h index 7261d8d..e3aeebe 100644 --- a/futuregael/src/show.h +++ b/futuregael/src/show.h @@ -42,16 +42,96 @@ public: } else duration=0.0f; + enspace=font.enspace; + } void clear(){ words.clear(); } + vector<colourPolyline>& getOutlines(float time){ + float phase=time/avgWordDuration; + float phaseseg=fmod(phase,(int)phase); + + //ofLog()<<"phase "<<phase<<" phaseseg "<<phaseseg; + + /* + int word1=(int)(phase+0.5f); + //segment 1 plays word 0 out for the first half + //then word 1 solid + int word2=(int)(phase+1.5f); + //segment 2 plays word 1 solid for the first half + //then word 2 in + + //deal with the ends? + //extra padding words, 2 per end + + float word1amt=0.5-phaseseg; + + if (word1amt<0.0f) word1amt=1.0f; + + float word2mat=phaseseg-0.5f; + + if (word2amt<0.0f) word2amt=1.0f; + */ + + //segment 1 plays word 0 solid for the first half + //then word 0 out + //at the very beginning, there's a buffer + + int word1=(int)(phase)-1; + + //segment 2 plays word 1 in for the first half + //then word 1 solid + + int word2=word1+1; + + float word1amt=2.0-(phaseseg*2.0); + if (word1amt>1.0f) word1amt=1.0f; + + float word2amt=phaseseg*2.0; + if (word2amt>1.0f) word2amt=1.0f; + + outlines.clear(); + float p=-ofGetWidth()/2; + + float s=0.1f; + + if (word1>-1&&word1<words.size()){ + for (auto& g:words[word1].glyphs){ + for (auto& o:g.outline){ + auto q=o; + q.scale(s,-s); + q.translate(glm::vec3(p*s,-ofGetHeight()/3,0)); + outlines.push_back(colourPolyline(q,g.colour*word1amt)); + } + p+=g.width; + } + p+=enspace; + } + + if (word2<words.size()){ + for (auto& g:words[word2].glyphs){ + for (auto& o:g.outline){ + auto q=o; + q.scale(s,-s); + q.translate(glm::vec3(p*s,-ofGetHeight()/3,0)); + outlines.push_back(colourPolyline(q,g.colour*word2amt)); + } + p+=g.width; + } + } + + return outlines; + + } vector<ofColor> palette; vector<glyphWord> words; ofSoundPlayer audio; float duration; float avgWordDuration; + vector<colourPolyline> outlines; + float enspace; }; @@ -62,7 +142,7 @@ public: return font.load(fontpath); } Show(){ - isPlaying=false; + bisPlaying=false; } Show(filesystem::path fontpath){ font.load(fontpath); @@ -103,25 +183,27 @@ public: if (playline->audio.isLoaded()){ playline->audio.play(); startTime=ofGetElapsedTimef(); - isPlaying=true; + bisPlaying=true; ofLog()<<"Line playing "<<playline->duration; } } void stop(){ - if (isPlaying){ + if (isPlaying()){ playline->audio.stop(); - isPlaying=false; + bisPlaying=false; ofLog()<<"Line stopped"; } } void update(){ - if (isPlaying){ - if (ofGetElapsedTimef()-startTime>playline->duration){ + if (isPlaying()){ + if (ofGetElapsedTimef()-startTime> + (playline->avgWordDuration* + playline->words.size()+2)){ playline->audio.stop(); - isPlaying=false; - ofLog()<<"Line finished! "<<playline->duration;; + bisPlaying=false; + ofLog()<<"Line ended, "<<playline->duration;; playline++; if (playline==script.end()){ ofLog()<<"Show finished!"; @@ -130,6 +212,11 @@ public: } } + vector<colourPolyline>& getOutlines(){ + + return playline->getOutlines(ofGetElapsedTimef()-startTime); + } + ofxCsv csv; vector<ScriptLine> script; @@ -137,7 +224,10 @@ public: vector<ScriptLine>::iterator playline; float startTime; - bool isPlaying; + bool bisPlaying; + bool isPlaying() { + return bisPlaying; + } SVGFont font; };
\ No newline at end of file |
