From 03eacae3ff028f7e565b3aebf28af48a0b08c585 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 18 Aug 2023 15:53:23 +0100 Subject: starfield randomisation --- lasertext/src/ofApp.cpp | 85 ++++++++++++++++++++++++++++++---------------- lasertext/src/ofApp.h | 53 +++++++++++++++++++++++++---- lasertext/src/vectortext.h | 13 +++++-- 3 files changed, 113 insertions(+), 38 deletions(-) diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp index 391aa37..e58e361 100644 --- a/lasertext/src/ofApp.cpp +++ b/lasertext/src/ofApp.cpp @@ -22,20 +22,15 @@ void ofApp::setup(){ ofLogNotice()<<"found "< laserstars=stars.getPoints(); + vector laserstars; + int numstars=0; + + laserstars=stars1.getPoints(); + num+=laser.draw(laserstars); + numstars+=laserstars.size(); - num+=laser.draw(laserstars); + laserstars=stars2.getPoints(); + num+=laser.draw(laserstars); + numstars+=laserstars.size(); if (num>0){ - ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)+", stars: "+ofToString(laserstars.size())); + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)+", stars: "+ofToString(numstars)); } else { - ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off, stars: "+ofToString(laserstars.size())); + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off, stars: "+ofToString(numstars)); } diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h index bd92da1..38038e3 100644 --- a/lasertext/src/ofApp.h +++ b/lasertext/src/ofApp.h @@ -10,6 +10,25 @@ #include "colourPolyline.h" #include "vectortext.h" +/* +priorities 2023 + +1. make the starfields dynamic / colour + +- different modes: + + gravity + + parameters changing on a cycle ie life, speed + + overall + +2. make the text display take an override sentence + +3. artnet receiver that makes (for instance) each letter of the text addreessable as if it was an LED + +*/ + class scannableColourPolyline: public colourPolyline{ public: bool operator < (const scannableColourPolyline& line) const { @@ -47,6 +66,12 @@ public: ofParameter speed; ofParameter lifespan; ofParameter bScan; + ofParameter mixprob; + ofParameter bRandomise; + + float this_rate; + float last_rate; + starSystem(){ } void init(string name="",int _gx=5, int _gy=5, float _x=0, float _y=0, float _rad=100,float r=0.5,float s=5.0,float l=5.0,float v=1.0){ @@ -54,18 +79,34 @@ public: agevar=v; gui.setup(name,"",_gx,_gy); - gui.add(x.set("x", _x, -2000.0f, 2000.0f)); - gui.add(y.set("y", _y, -2000.0f, 2000.0f)); + gui.add(x.set("x", _x, -4000.0f, 4000.0f)); + gui.add(y.set("y", _y, -4000.0f, 4000.0f)); gui.add(rate.set("rate", r, 0.01f, 3.0f)); gui.add(radius.set("radius", _rad, 10.0f, 500.0f)); gui.add(speed.set("speed", s, 0.0f, 10.0f)); gui.add(lifespan.set("life", l, 3.0f, 10.0f)); gui.add(bScan.set("scan", true)); + gui.add(mixprob.set("mix probability", 0.001f, 0.0f, 0.01f)); + gui.add(bRandomise.set("randomise", true)); + + this_rate=rate; + last_rate=rate; } void update(){ float now=ofGetElapsedTimef(); float segment=now-last; last=now; + + if (rate!=last_rate){ + last_rate=rate; + this_rate=rate; + } + + if (bRandomise&&(ofRandom(1.0f)birthday>it->lifespan){ @@ -78,7 +119,7 @@ public: ++it; } } - if (ofRandom(rate) stars; - - starSystem stars; + //vector stars //!!not easy + starSystem stars1; + starSystem stars2; glm::vec2 warpframe[4]; int select_warpframe; diff --git a/lasertext/src/vectortext.h b/lasertext/src/vectortext.h index 088ee96..69ea98c 100644 --- a/lasertext/src/vectortext.h +++ b/lasertext/src/vectortext.h @@ -68,6 +68,11 @@ class glyphbanner{ ofColor::fromHex(0x102ADC), ofColor::fromHex(0x9FA1AC) }; + vector als23={ + ofColor::fromHex(0x00A8FF), + ofColor::fromHex(0xFFB700), + ofColor::fromHex(0xFF3082) + }; }palettes; vector split(string s) { size_t pos_start = 0, pos_end; @@ -85,10 +90,10 @@ class glyphbanner{ } public: glyphbanner(){ - palette=palettes.uneasy; + palette=palettes.als23; }; void init(string message){ - createWords(message); + createWords(message,true); lastUpdateTime=ofGetElapsedTimef(); playhead=0.0f; } @@ -214,6 +219,10 @@ public: lastUpdateTime=ofGetElapsedTimef(); playhead+=delta*speed; + if (ofRandom(1.0f)<.001){ + playhead=ofRandom(100); + } + int theword=0; float segment=0.0f; if (false){ //1 word per second -- cgit v1.2.3