Skip to content

Instantly share code, notes, and snippets.

@trentbrooks
trentbrooks / testApp.mm
Created October 3, 2012 06:02
Basic native bonjour server service to make a device discoverable in openframeworks ios
#include "testApp.h"
NSNetService *netService;
//--------------------------------------------------------------
void testApp::setup(){
// initialise bonjour server: broadcasts the type + name so you can see devices ip + port
// note: this is a basic example, and does not implement any of the Net Service Delegate Methods to see if the service was published successfully or not
netService = [[NSNetService alloc]
initWithDomain:@""
@trentbrooks
trentbrooks / MultitouchHitTestDemo.html
Created October 30, 2012 07:10
ProcessingJS Multitouch Demo
<html>
<head>
<title>Multitouch ProcessingJS Test</title>
<meta content='True' name='HandheldFriendly' />
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />
<meta name="viewport" content="width=device-width" />
<script type="text/javascript" src="http://trentbrooks.com/files/MultitouchHitTestDemo/processing-1.4.1.js"></script>
<script type="text/processing" data-processing-target="targetcanvas">
@trentbrooks
trentbrooks / BasicSendReceiveOsc.pd
Last active December 12, 2015 06:28
Basic Pure Data patch to view OSC messages on any given port, can also send a custom message to any ip.
#N canvas 20 473 496 184 10;
#X obj 239 110 sendOSC;
#X obj 25 89 print osc;
#X text 20 11 Receiving values on port XXXX:;
#X text 237 11 Send values to ip address and port:;
#X msg 276 76 send /someaddress/69;
#X obj 25 56 dumpOSC 4444;
#X msg 239 44 connect 127.0.0.1 4443;
#X connect 4 0 0 0;
#X connect 5 0 1 0;
@trentbrooks
trentbrooks / KinectIndices.h
Last active December 16, 2015 05:39
All the indices for the 121 face tracked points for the windows kinect. The windows examples work this out in a roundabout way, but it never changes so saving here for future ref (for use in Openframeworks).
/*
There are 206 triangles, 121 vertices, 618 indices when using the Kinect for Windows face tracking api.
The indices never change, so saving here for reference.
*/
static ofIndexType FACEMESH_INDICES[618] = {1,0,11,34,0,1,44,0,34,1,11,12,45,44,34,13,1,12,2,1,13,34,1,2,34,2,46,45,34,46,13,12,14,15,13,14,16,13,15,16,2,13,17,2,16,3,2,17,50,2,3,49,2,50,46,2,49,48,46,49,47,46,48,47,45,46,15,14,29,20,15,29,19,18,15,15,18,16,17,16,18,19,17,18,77,17,23,77,3,17,50,3,78,50,78,56,51,50,52,51,49,50,51,48,49,52,48,51,62,48,53,62,47,48,27,29,28,27,20,29,25,24,26,59,57,58,62,53,60,61,62,60,33,111,26,111,75,26,26,75,25,58,76,59,59,76,112,59,112,66,7,6,33,66,6,7,10,9,32,65,9,10,5,6,76,75,6,5,78,3,77,79,7,33,81,7,79,87,7,81,66,7,80,80,7,82,82,7,87,89,80,82,64,80,89,81,79,88,88,79,31,33,26,79,79,26,31,80,59,66,64,59,80,85,83,88,31,85,88,85,8,83,8,40,83,84,40,8,86,84,8,84,86,89,89,86,64,8,85,9,86,8,9,31,32,85,85,32,9,64,86,65,86,9,65,24,27,26,32,90,30,31,90,32,28,30,90,31,26,90,26,27,90,27,28,90,57,59,60,63,91,65,65,91,64
@trentbrooks
trentbrooks / .bash_profile
Created May 20, 2013 00:39
Lazy GitHub shortcut: copy file into your home directory next to '.bash_history' (if .bash_profile already exists, just copy/paste the function below). Launch terminal, cd into your local repo, then type- gitit "some commit". Note, function assumes your working with a 'develop' branch, if not change 'develop' to whatever your branch is, eg. 'mas…
function gitit {
git pull origin develop
git add -A
git commit -am "$1"
git push origin develop
}
@trentbrooks
trentbrooks / drawRibbonRainbow
Last active December 25, 2015 03:49
draw a rainbow ribbon (uses MeshUtils.h)
deque<ofVec3f> mousePts;
void testApp::drawRibbonRainbow() {
mousePts.push_back(ofVec3f(ofGetMouseX(), ofGetMouseY(), 0));
ofPolyline polyPoints;
for(int i = 0; i < mousePts.size(); i++) {
polyPoints.addVertex(mousePts[i]);
}
@trentbrooks
trentbrooks / gist:7206615
Created October 28, 2013 23:26
Icosahedron
ofMesh ico = createIcosahedron(120);
ofMesh testApp::createIcosahedron(float size) {
ofMesh mesh;
GLdouble vertexB[][3]= {
{0, -0.525731, 0.850651}, // vertices[0]
{0.850651, 0, 0.525731}, // vertices[1]
{0.850651, 0, -0.525731}, // vertices[2]
{-0.850651, 0, -0.525731}, // vertices[3]
@trentbrooks
trentbrooks / gist:7444679
Created November 13, 2013 06:33
Easy event listener adding/removing. Put below methods in the object's .h only, and make sure the testApp has the onSomething method.
template <class ListenerClass>
void addEventListener(ListenerClass * listener){
ofAddListener(onChangedEvent,listener,&ListenerClass::onSomething);
};
template <class ListenerClass>
void removeEventListener(ListenerClass * listener){
ofRemoveListener(onChangedEvent,listener,&ListenerClass::onSomething);
};
@trentbrooks
trentbrooks / gist:7496260
Created November 16, 2013 05:14
Point Grey modified
#include "FlyCapture2.h"
using namespace FlyCapture2;
@trentbrooks
trentbrooks / gist:8969897
Last active August 29, 2015 13:56
for kurt
int previousStatus = 0; // 0 = nothing, 1 = hand above head
int resetStatusCounter = 0;
int resetStatusThreshold = 100;
void draw() {
// do normal kinect updates and processing here (your code)
int status = ?; // you need to work out when hand is above, etc