summaryrefslogtreecommitdiff
path: root/gistanalysis/src/ofApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gistanalysis/src/ofApp.cpp')
-rw-r--r--gistanalysis/src/ofApp.cpp84
1 files changed, 74 insertions, 10 deletions
diff --git a/gistanalysis/src/ofApp.cpp b/gistanalysis/src/ofApp.cpp
index d5fdf65..43c6f29 100644
--- a/gistanalysis/src/ofApp.cpp
+++ b/gistanalysis/src/ofApp.cpp
@@ -64,7 +64,7 @@ void ofApp::setup(){
- chaosgui.setup("chaos","",230,10); // most of the time you don't need a name but don't forget to call setup
+ chaosgui.setup("chaos","",230,10);
chaosgui.add(plotter.usechaos.set("use",false));
chaosgui.add(plotter.chaosamount.set("amount", 0.5f, 0.0f, 1.0f));
chaosgui.add(plotter.chaos_a.set("a", 0.85f, 0.0f, 10.0f));
@@ -72,6 +72,12 @@ void ofApp::setup(){
chaosgui.add(plotter.chaos_k.set("k", 0.4f, 0.0f, 10.0f));
chaosgui.add(plotter.chaos_p.set("p", 7.7f, 0.0f, 10.0f));
+ lasergui.setup("laser","",230,200);
+ lasergui.add(drawWarpFrame.set("show warp", false));
+ lasergui.add(intensity.set("intensity", 30, 0, 255));
+ lasergui.add(subdivide.set("subdivide", 15, 1, 100));
+ lasergui.add(blank_num.set("blank points", 8, 0, 32));
+ lasergui.add(max_angle.set("max angle", 15.0f, 1.0f, 90.0f));
/*
//add special crest graph
ofxHistoryPlot*crest = addGraph("CREST_AVG",1.0,ofColor(ofRandom(100)+150,ofRandom(100)+150,ofRandom(100)+150));
@@ -199,6 +205,7 @@ void ofApp::draw(){
ofBackground(0);
gui.draw();
chaosgui.draw();
+ lasergui.draw();
}
//--------------------------------------------------------------
void ofApp::drawOutput(ofEventArgs & args){
@@ -299,26 +306,83 @@ void ofApp::drawOutput(ofEventArgs & args){
*/
+ //ofLoadIdentityMatrix();
-
ofMatrix4x4 t;
t.makeTranslationMatrix(xform->x,xform->y,0);
ofMatrix4x4 r;
- r.makeRotationMatrix(rotate,ofVec3f(0,1,07));
+ r.makeRotationMatrix(rotate,0,0,1);
ofMatrix4x4 s;
- r.makeScaleMatrix(scale->x,scale->y,1.0f);
+ s.makeScaleMatrix(scale->x,scale->y,1.0f);
- ofMatrix4x4 x=s*r*t;
+ ofMatrix4x4 x=r*t*s;
vector <colourPolyline> lines=plotter.output(x,scalePlot,decayPlot);
- int num=laser.draw(lines,30);
- ofTranslate(0,ofGetHeight()/2);
-
- for (auto line=lines.begin();line!=lines.end();line++){
- line->draw();
+//PROJECTION MAPPING
+//how best to move this to it's own class?
+
+ glm::vec2 src[]={
+ glm::vec2(0,0),
+ glm::vec2(ofGetWidth(),0),
+ glm::vec2(ofGetWidth(),ofGetWidth()),
+ glm::vec2(0,ofGetHeight())
+ };
+
+ glm::vec2 mp=glm::vec2(ofGetWidth()/2,ofGetWidth()/2);
+
+ glm::vec2 scaled_dest[]={
+ ((warpframe[0]-mp)*outputScale)+mp,
+ ((warpframe[1]-mp)*outputScale)+mp,
+ ((warpframe[2]-mp)*outputScale)+mp,
+ ((warpframe[3]-mp)*outputScale)+mp
+ };
+
+ ofMatrix4x4 scaled_warp =lineTransformer::getPerspectiveTransformMatrix(src,scaled_dest);
+ ofMatrix4x4 warp =lineTransformer::getPerspectiveTransformMatrix(src,warpframe);
+
+ vector <colourPolyline> warpedOutput;
+ vector <colourPolyline> scaledWarpedOutput;
+
+ for (auto s:lines){
+ warpedOutput.push_back(lineTransformer::polyLineTransform(warp,s));
+ scaledWarpedOutput.push_back(lineTransformer::polyLineTransform(scaled_warp,s));
}
+
+//PREVIEW
+
+ //ofTranslate(0,ofGetHeight()/2);
+ //for (auto& line:lines){
+ // line->draw();
+ //}
+
+ int pnum=0;
+
+ for (auto& shape:warpedOutput){
+ shape.draw();
+ pnum+=shape.size();
+ }
+
+ if (drawWarpFrame){
+ lineTransformer::drawWarpFrame(warpframe);
+ }
+
+//LASER
+
+ laser.set_subdivide(subdivide);
+ laser.set_blanknum(blank_num);
+ laser.set_maxangle(max_angle);
+
+ laser.set_intensity(intensity);
+
+ //int num=laser.draw(lines,30);
+
+ int num=laser.draw(scaledWarpedOutput);
+
+
+
+
ofSetWindowTitle(ofToString(ofGetFrameRate())+" fps, "+ofToString(num)+" pts");
}