summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-02-03 11:41:22 +0000
committerTim Redfern <tim@getdrop.com>2018-02-03 11:41:22 +0000
commit4154f89b1ebff83228f51252de6b93a49fc6ed96 (patch)
treeeb19eadfaa8e3a79feb54b2c3a4995b9eec489e9
parent022563c4bdc832b1177ed12ef0bac7f85912db95 (diff)
warping positioning interface working
-rw-r--r--gui/src/lineTransformer.cpp10
-rw-r--r--gui/src/lineTransformer.h2
-rw-r--r--gui/src/ofApp.cpp31
3 files changed, 41 insertions, 2 deletions
diff --git a/gui/src/lineTransformer.cpp b/gui/src/lineTransformer.cpp
index a21d020..080eb9d 100644
--- a/gui/src/lineTransformer.cpp
+++ b/gui/src/lineTransformer.cpp
@@ -1,5 +1,6 @@
#include "lineTransformer.h"
+
void lineTransformer::drawWarpFrame(glm::vec2 warpframe[4]){
ofSetColor(255,255,255);
ofNoFill();
@@ -97,6 +98,15 @@ ofPolyline lineTransformer::polyLineTransform(const ofMatrix4x4 xform, const ofP
return tempPoly;
}
+colourPolyline lineTransformer::polyLineTransform(const ofMatrix4x4 xform,colourPolyline& poly){
+ colourPolyline tempPoly;
+ for (int i=0;i<poly.size();i++){
+ tempPoly.addVertex(ofVec3f(poly[i])*xform,poly.getColourAt(i));
+ }
+ return tempPoly;
+}
+
+
ofPolyline lineTransformer::makePolygon(int num,float diam){
ofPolyline poly;
float step=PI*2/num;
diff --git a/gui/src/lineTransformer.h b/gui/src/lineTransformer.h
index 54424d0..4eabf14 100644
--- a/gui/src/lineTransformer.h
+++ b/gui/src/lineTransformer.h
@@ -1,6 +1,7 @@
#pragma once
#include "ofMain.h"
+#include "colourPolyline.h"
class lineTransformer {
@@ -11,6 +12,7 @@ class lineTransformer {
void static gaussianElimination(float * input, int n);
glm::mat4 static getPerspectiveTransformMatrix(const glm::vec2 src[4], const glm::vec2 dst[4]);
ofPolyline static polyLineTransform(const ofMatrix4x4 xform,const ofPolyline& poly);
+ colourPolyline static polyLineTransform(const ofMatrix4x4 xform,colourPolyline& poly);
ofPolyline static makePolygon(int num,float diam);
void static drawPoly(ofPolyline poly,float x,float y);
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index 3b24b43..fb179e9 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -412,12 +412,39 @@ void ofApp::drawOutput(ofEventArgs & args){
}
}
+ glm::vec2 src[]={
+ glm::vec2(0,0),
+ glm::vec2(ofGetWidth(),0),
+ glm::vec2(ofGetWidth(),ofGetHeight()),
+ glm::vec2(0,ofGetHeight())
+ };
+
+ glm::vec2 mp=glm::vec2(outputWindowSize.x/2,outputWindowSize.y/2);
+
+ glm::vec2 scaled_dest[]={
+ ((warpframe[0]-mp)*outputScale*outputOffsetScale)+mp,
+ ((warpframe[1]-mp)*outputScale*outputOffsetScale)+mp,
+ ((warpframe[2]-mp)*outputScale*outputOffsetScale)+mp,
+ ((warpframe[3]-mp)*outputScale*outputOffsetScale)+mp
+ };
+
+ ofMatrix4x4 scaled_warp =lineTransformer::getPerspectiveTransformMatrix(src,scaled_dest);
+ ofMatrix4x4 warp =lineTransformer::getPerspectiveTransformMatrix(src,warpframe);
+
+ vector <colourPolyline> warpedOutput;
+ vector <colourPolyline> scaledWarpedOutput;
+
+ for (auto s:laserOutput){
+ warpedOutput.push_back(lineTransformer::polyLineTransform(warp,s));
+ scaledWarpedOutput.push_back(lineTransformer::polyLineTransform(scaled_warp,s));
+ }
+
int num = 0;
if (laserOutput.size()){
- num=laser.draw(laserOutput);
+ num=laser.draw(scaledWarpedOutput);
- for (auto& shape:laserOutput){
+ for (auto& shape:warpedOutput){
shape.draw();
}
}