summaryrefslogtreecommitdiff
path: root/futuregael/src
diff options
context:
space:
mode:
authorTim Redfern <redfernt@gmail.com>2023-09-20 08:35:26 +0100
committerTim Redfern <redfernt@gmail.com>2023-09-20 08:35:26 +0100
commit5c59ea6a5797bb44a46846008ddc235c8a5537af (patch)
tree2bfeb2af3c016bd51ce35ac1e606b4f6ed0769ac /futuregael/src
parentc02378a381cbb23ba56099a33fab38686c8d2b5b (diff)
basic playback
Diffstat (limited to 'futuregael/src')
-rw-r--r--futuregael/src/main.cpp2
-rw-r--r--futuregael/src/ofApp.cpp21
-rw-r--r--futuregael/src/show.h108
-rw-r--r--futuregael/src/vectortext.h2
4 files changed, 121 insertions, 12 deletions
diff --git a/futuregael/src/main.cpp b/futuregael/src/main.cpp
index 3e20ab7..79ed500 100644
--- a/futuregael/src/main.cpp
+++ b/futuregael/src/main.cpp
@@ -8,7 +8,7 @@ int main(int argc, char *argv[]){
ofGLFWWindowSettings settings;
- settings.setSize(1200,900);
+ settings.setSize(512,512); // 1/8 scale
//1200 = 13.2° = 42898 pts theoretical
diff --git a/futuregael/src/ofApp.cpp b/futuregael/src/ofApp.cpp
index 2393618..676b480 100644
--- a/futuregael/src/ofApp.cpp
+++ b/futuregael/src/ofApp.cpp
@@ -22,6 +22,25 @@ void ofApp::update(){
void ofApp::draw(){
ofBackground(0);
+
+
+ if (show.isPlaying()){
+ vector<colourPolyline>& outlines=show.getOutlines();
+
+ ofPushMatrix();
+ ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ for (auto o:outlines){
+ o.draw();
+ }
+ ofPopMatrix();
+
+ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+"fps, shapes: "+ofToString(outlines.size()));
+ }
+ else {
+ ofSetWindowTitle("idle");
+ }
+
+
}
@@ -52,7 +71,7 @@ void ofApp::keyReleased(int key){
break;
}
case ' ':{
- if (show.isPlaying){
+ if (show.isPlaying()){
show.stop();
}
else show.play();
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
diff --git a/futuregael/src/vectortext.h b/futuregael/src/vectortext.h
index 0f79e58..e5adbdb 100644
--- a/futuregael/src/vectortext.h
+++ b/futuregael/src/vectortext.h
@@ -46,10 +46,10 @@ public:
};
class SVGFont{
+public:
ofXml svg;
float enspace;
bool bisLoaded;
-public:
bool isLoaded() {
return bisLoaded;
}