#pragma once #include "ofMain.h" #include "ofxSvg.h" #include "ofxGui.h" #include "ofxXmlSettings.h" #include "ofxHelios.h" #include "lineTransformer.h" #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 rate 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 { return (operator[](0).x < line[0].x); } }; class star{ public: star(ofVec2f p,ofVec2f v,float l){ pos=p; vel=v; birthday=ofGetElapsedTimef(); lifespan=l; } void update(vector& stars){ pos+=vel; } ofVec2f pos; ofVec2f vel; float birthday; float lifespan; }; class starSystem{ public: vector stars; float agevar; float last; ofxPanel gui; ofParameter x; ofParameter y; ofParameter rate; ofParameter radius; 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){ agevar=v; gui.setup(name,"",_gx,_gy); gui.add(x.set("x", _x, -3000.0f, 3000.0f)); gui.add(y.set("y", _y, -3000.0f, 3000.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){ //ofLog()<<"erase star"; it = stars.erase(it); } else { //ofLog()<<"update star"; it->update(stars); ++it; } } if (ofRandom(this_rate) getPoints(){ float now=ofGetElapsedTimef(); vector s; for(auto& star:stars){ scannableColourPolyline l; //ofLog()<<"get star"; l.addVertex(x+star.pos.x,y+star.pos.y,ofColor(1.0f-((now-star.birthday)/star.lifespan)*128.0f)); l.addVertex(x+star.pos.x+1,y+star.pos.y+1,ofColor(1.0f-((now-star.birthday)/star.lifespan)*128.0f)); s.push_back(l); } if (bScan){ std::sort(s.begin(),s.end()); } vector o; int numstars=0; for (auto& shape: s) { shape.draw(); o.push_back((colourPolyline)shape); } return o; } }; class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void exit(); void keyPressed(ofKeyEventArgs &keyargs); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(int x, int y); void mouseExited(int x, int y); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); void default_settings(); void save_settings(); ofxHelios laser; ofDirectory fonts; int currentFont; string displaytext; glyphbanner banner; glyphbanner override_banner; ofxPanel textgui; ofParameter laser_scale; ofParameter laser_pos_x; ofParameter laser_pos_y; ofParameter text_speed; //======= laser gui ofxPanel lasergui; ofParameter laser_power; ofParameter laser_intensity; ofParameter laser_points; ofParameter laser_subdivide; ofParameter laser_blank_num; ofParameter laser_max_angle; ofxXmlSettings XML; //vector stars //!!not easy starSystem stars1; starSystem stars2; glm::vec2 warpframe[4]; int select_warpframe; bool bDrawFrame; ofPoint outputWindowSize; ofPoint outputPosition; float outputScale; };