Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9701bc5
commit ae8ddaa
Showing
19 changed files
with
2,747 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
# ofxLaser | ||
An openFrameworks addon for rendering shapes with a laser projector. Work in progress, not ready for general use. | ||
|
||
Currently requires my forks of ofxEtherdream and ofxIlda. | ||
|
||
https://github.com/sebleedelisle/ofxEtherdream | ||
https://github.com/sebleedelisle/ofxIlda | ||
|
||
More information / guidance to come. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// DragHandle.cpp | ||
// | ||
// Created by Seb Lee-Delisle on 17/08/2015. | ||
// | ||
// | ||
|
||
#include "DragHandle.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// | ||
// DragHandle.h | ||
// | ||
// Created by Seb Lee-Delisle on 17/08/2015. | ||
// | ||
// | ||
#pragma once | ||
|
||
#include "ofMain.h" | ||
|
||
class DragHandle : public ofPoint{ | ||
|
||
|
||
public : | ||
DragHandle() { | ||
set(0,0); | ||
}; | ||
|
||
// DragHandle(float xpos, float ypos) { | ||
// set(xpos, ypos); | ||
// | ||
// }; | ||
// | ||
void set(float xpos, float ypos, float r = 8) { | ||
|
||
x = xpos; | ||
y = ypos; | ||
radius = r; | ||
}; | ||
|
||
void set(ofPoint pos) { | ||
ofPoint::set(pos); | ||
|
||
}; | ||
|
||
void draw() { | ||
ofPushStyle(); | ||
ofNoFill(); | ||
ofSetLineWidth(1); | ||
ofCircle(*this, radius); | ||
ofPopStyle(); | ||
}; | ||
|
||
void startDrag(ofPoint clickPos, bool dragXAxis = true, bool dragYAxis = true) { | ||
offset = clickPos - *this; | ||
isDragging = true; | ||
xAxis = dragXAxis; | ||
yAxis = dragYAxis; | ||
|
||
|
||
}; | ||
|
||
bool updateDrag(ofPoint pos) { | ||
if(isDragging) { | ||
if(xAxis) x = pos.x - offset.x; | ||
if(yAxis) y = pos.y - offset.y; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
bool stopDrag(){ | ||
if(isDragging) { | ||
isDragging = false; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
|
||
bool hitTest(ofPoint hitpoint) { | ||
return(distance(hitpoint)<radius); | ||
} | ||
|
||
ofPoint offset; | ||
bool isDragging = false; | ||
|
||
float radius = 5; | ||
bool xAxis; | ||
bool yAxis; | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// LaserCircle.h | ||
// | ||
// Created by Seb Lee-Delisle on 01/08/2013. | ||
// | ||
// | ||
|
||
#pragma once | ||
|
||
#include "LaserShape.h" | ||
|
||
class LaserCircle : public LaserShape{ | ||
|
||
public : | ||
|
||
LaserCircle(const ofPoint& circleCentre, float circleRadius, ofFloatColor circleColour, float circleSpeed, float circleAcceleration, float overlap = 0){ | ||
reversable = true; | ||
//set(position, colour, circleRadius, circleIntensity, overlap); | ||
|
||
|
||
|
||
|
||
pos = circleCentre; | ||
radius = circleRadius; | ||
colour = circleColour; | ||
speed = circleSpeed; | ||
acceleration = circleAcceleration; | ||
|
||
if(overlap>0) { | ||
|
||
float circumference = PI*2*radius; | ||
overlapDistance = overlap; | ||
overlapAngle = overlap / circumference * 360; | ||
|
||
startPos.set(0,-radius); | ||
endPos = startPos; | ||
startPos.rotate(-overlapAngle/2, ofPoint(0,0,1)); | ||
startPos+=pos; | ||
endPos.rotate(overlapAngle/2, ofPoint(0,0,1)); | ||
endPos+=pos; | ||
|
||
|
||
} else { | ||
|
||
startPos = pos; | ||
startPos.y-=radius; | ||
|
||
endPos = startPos; | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
void appendPointsToVector(vector<ofxLaserPoint>& points) { | ||
|
||
|
||
float distanceTravelled = 2 * PI * radius + overlapDistance; | ||
vector<float> unitDistances = getPointsAlongDistance(distanceTravelled, acceleration, speed); | ||
|
||
ofPoint p; | ||
ofColor segmentColour; | ||
|
||
for(int i = 0; i<unitDistances.size(); i++) { | ||
|
||
float unitDistance = unitDistances[i]; | ||
float angle; | ||
if(!reversed) angle = ofMap(unitDistance,0,1,-overlapAngle/2,360+(overlapAngle/2)) ; | ||
else angle = ofMap(unitDistance,1,0,-overlapAngle/2,360+(overlapAngle/2)) ; | ||
|
||
segmentColour = colour; | ||
|
||
// an attempt to fade out the overlap. Not sure if it works. | ||
// TODO check that it works! | ||
|
||
if(angle<overlapAngle/2) { | ||
segmentColour*= ofMap(angle, -overlapAngle/2,overlapAngle/2, 0, 1); | ||
} if(angle> 360 - overlapAngle/2) { | ||
segmentColour *= ofMap(angle, 360 -overlapAngle/2,360 + overlapAngle/2, 1, 0); | ||
} | ||
|
||
p.set(pos); | ||
p.x+=sin(ofDegToRad(angle))*radius; | ||
p.y-=cos(ofDegToRad(angle))*radius; | ||
|
||
points.push_back(ofxLaserPoint(p, colour)); | ||
} | ||
|
||
|
||
}; | ||
|
||
float overlapAngle = 0; | ||
float overlapDistance = 0; | ||
ofFloatColor colour; | ||
|
||
ofPoint pos; | ||
float radius; | ||
float speed; | ||
float acceleration; | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// LaserDot.h | ||
// | ||
// Created by Seb Lee-Delisle on 01/08/2013. | ||
// | ||
// | ||
|
||
#pragma once | ||
|
||
#include "LaserShape.h" | ||
|
||
class LaserDot : public LaserShape{ | ||
|
||
public : | ||
|
||
LaserDot(const ofPoint& dotPosition, ofFloatColor& dotColour, float dotIntensity = 1, int dotMaxPoints = 5){ | ||
set(dotPosition, dotColour, dotIntensity); | ||
maxPoints = dotMaxPoints; | ||
} | ||
|
||
void set(const ofPoint& dotPosition, ofFloatColor& dotColour, float dotIntensity = 1) { | ||
colour = dotColour; | ||
startPos.set(dotPosition); | ||
endPos.set(dotPosition); | ||
intensity = dotIntensity; | ||
tested = false; | ||
} | ||
|
||
void appendPointsToVector(vector<ofxLaserPoint>& points) { | ||
int particlecount = maxPoints * intensity;// ceil(dotMaxPoints* dot->intensity); | ||
|
||
for(int i = 0; i<particlecount; i++) { | ||
//addIldaPoint(dot.getStartPos(), dot.colour); | ||
points.push_back(ofxLaserPoint(getStartPos(), colour)); | ||
} | ||
}; | ||
|
||
|
||
float intensity = 1; | ||
int maxPoints = 5; | ||
ofFloatColor colour; | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// LaserLine.h | ||
// | ||
// Created by Seb Lee-Delisle on 01/08/2013. | ||
// | ||
// | ||
|
||
#pragma once | ||
|
||
#include "LaserShape.h" | ||
|
||
class LaserLine : public LaserShape{ | ||
|
||
public : | ||
|
||
LaserLine(const ofPoint& startpos, const ofPoint& endpos, ofFloatColor& col, float lineSpeed, float lineAcceleration){ | ||
|
||
reversable = true; | ||
colour = col; | ||
|
||
startPos = startpos; | ||
endPos = endpos; | ||
|
||
tested = false; | ||
|
||
speed = lineSpeed; | ||
acceleration = lineAcceleration; | ||
//cout<<"LINE SET : " << startPos << " " << endPos << " " <<endl; | ||
|
||
} | ||
|
||
|
||
void appendPointsToVector(vector<ofxLaserPoint>& points) { | ||
|
||
ofPoint& start = getStartPos(); | ||
ofPoint& end = getEndPos(); | ||
ofVec2f v = end-start; | ||
|
||
float distanceTravelled = ofDist(start.x, start.y, end.x, end.y); | ||
vector<float> unitDistances = getPointsAlongDistance(distanceTravelled, acceleration, speed); | ||
|
||
ofPoint p; | ||
ofColor segmentColour; | ||
|
||
for(int i = 0; i<unitDistances.size(); i++) { | ||
|
||
float unitDistance = unitDistances[i]; | ||
|
||
points.push_back(ofxLaserPoint(start + (v*unitDistance), colour)); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
}; | ||
|
||
ofFloatColor colour; | ||
float speed; | ||
float acceleration; | ||
|
||
}; | ||
|
Oops, something went wrong.