Skip to content

Commit

Permalink
Initial (very rough!) commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebleedelisle committed Aug 18, 2015
1 parent 9701bc5 commit ae8ddaa
Show file tree
Hide file tree
Showing 19 changed files with 2,747 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 sebleedelisle
Copyright (c) 2012-2015 sebleedelisle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 7 additions & 0 deletions README.md
@@ -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.
8 changes: 8 additions & 0 deletions src/DragHandle.cpp
@@ -0,0 +1,8 @@
//
// DragHandle.cpp
//
// Created by Seb Lee-Delisle on 17/08/2015.
//
//

#include "DragHandle.h"
84 changes: 84 additions & 0 deletions src/DragHandle.h
@@ -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;


};
102 changes: 102 additions & 0 deletions src/LaserCircle.h
@@ -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;

};

44 changes: 44 additions & 0 deletions src/LaserDot.h
@@ -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;

};

63 changes: 63 additions & 0 deletions src/LaserLine.h
@@ -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;

};

0 comments on commit ae8ddaa

Please sign in to comment.