Skip to content

Instantly share code, notes, and snippets.

@patriciogonzalezvivo
patriciogonzalezvivo / AutoReLoad Scrip
Created April 27, 2013 15:24
Re loads an app after it crash
#!/bin/sh
while : ;
do /path/app;
sleep 30;
done
@patriciogonzalezvivo
patriciogonzalezvivo / MakingGeometries.md
Last active June 15, 2024 11:09
Creating Geometries in openFrameworks

Face by Face

void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) {
	ofVec3f normal = ((b - a).cross(c - a)).normalize();
	mesh.addNormal(normal);
	mesh.addVertex(a);
	mesh.addNormal(normal);
	mesh.addVertex(b);
	mesh.addNormal(normal);
@patriciogonzalezvivo
patriciogonzalezvivo / get string from ofSerial
Created April 27, 2013 15:27
Getting strings from ofSerial
string serialIn;
unsigned char buffer[1];
while( readBytes( buffer, 1) > 0){
if (buffer[0] == '\n'){
break;
}
serialIn.push_back(buffer[0]);
};
@patriciogonzalezvivo
patriciogonzalezvivo / StringShaders.md
Last active February 27, 2021 14:04
GLSL shaders on a strings (OF)

Stringify Macro

#define STRINGIFY(A) #A

Default Vertex

string vertexShader = STRINGIFY(	
@patriciogonzalezvivo
patriciogonzalezvivo / SmoothEdgeApp.md
Last active December 16, 2015 17:59
Smooth edges on OSX
ofAppGlutWindow window;
#if defined (TARGET_OSX) 
window.setGlutDisplayString("rgba double samples>=4 depth"); 
#endif

ofSetupOpenGL(&window, 1280,1024, OF_WINDOW);
@patriciogonzalezvivo
patriciogonzalezvivo / billboards.md
Last active July 14, 2018 06:43
Billboards on OF
void billBoard(){
	ofVec3f objectLookAt = ofVec3f(0,0,1);
	ofVec3f objToCam = cam.getGlobalPosition();
	objToCam.normalize();
	float theta = objectLookAt.angle(objToCam);
	
	ofVec3f axisOfRotation = objToCam.crossed(objectLookAt);
	axisOfRotation.normalize();
 
void rotateTo(ofPoint _dir){
ofVec3f newTarget = _dir;
newTarget.normalize();
ofVec3f up( 0, -1, 0 );
ofVec3f axis = up.crossed( newTarget );
axis.normalize();
float angle = up.angle( newTarget );
ofRotate( angle, axis.x, axis.y, axis.z );
}
@patriciogonzalezvivo
patriciogonzalezvivo / csv.md
Last active December 27, 2015 19:39
Reading a CSV on OF
ofBuffer buffer = ofBufferFromFile(_file);

while(!buffer.isLastLine()) {
	string temp = buffer.getNextLine();
        
    if(temp.length() != 0) {
        vector<string> values = ofSplitString(temp, ",");
            
 // ofToInt(value[0]);
@patriciogonzalezvivo
patriciogonzalezvivo / rpi.md
Last active March 25, 2018 09:28
RaspberryPi post-installation

THE BASIC

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install avahi-daemon 

Apache Server

@patriciogonzalezvivo
patriciogonzalezvivo / dd.md
Last active August 29, 2015 14:01
DiskImage Backup and restore

Backup

diskutil list
sudo dd if=/dev/disk1 of=~/Desktop/diskImg.dmg

Restore