Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / remove_example.cpp
Created July 15, 2011 10:23
Remove particles from vector
// create some particles.
for(int i = 0; i < 10; ++i) {
Particle p;
parts.push_back(p);
}
cout << "We have:" << parts.size() << " particles." << endl;
// remove some
vector<Particle>::iterator it = parts.begin();
@roxlu
roxlu / parts.cpp
Created July 15, 2011 10:59
Remove particles using ofRemove
class Particle {
public:
Particle() {
alive = (int)ofRandom(0,5);
}
bool operator()(const Particle& p) {
return p.alive;
}
int alive;
};
@roxlu
roxlu / iso.cpp
Created July 15, 2011 13:30
ofxGeometry - PRE BETA - testing ofxGeometry with isosurfaces
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetFrameRate(60);
ofSetVerticalSync(true);
ofBackground(33);
ax.setup(15);
float s = 0.01;
@roxlu
roxlu / test.cpp
Created July 20, 2011 19:22
Defining outside loop?
inline std::vector<HE_Edge*> HE_Selection::getOuterEdges() {
HE_Selection copy = getCopy();
copy.collectEdges();
const std::vector<HE_Edge*>& copy_edges = copy.getEdgesRef();
const std::vector<HE_Edge*>::const_iterator it = copy_edges.begin();
HE_Edge* e = NULL;
HE_Face* f1 = NULL;
HE_Face* f2 = NULL;
@roxlu
roxlu / test.cpp
Created July 20, 2011 19:23
inside or outside
inline std::vector<HE_Edge*> HE_Selection::getOuterEdges() {
HE_Selection copy = getCopy();
copy.collectEdges();
const std::vector<HE_Edge*>& copy_edges = copy.getEdgesRef();
const std::vector<HE_Edge*>::const_iterator it = copy_edges.begin();
HE_Edge* e = NULL;
HE_Face* f1 = NULL;
HE_Face* f2 = NULL;
bool AMF3Serializer::WriteArray(IOBuffer &buffer, Variant &variant, bool writeType) {
WRITE_AMF3_TYPE(AMF3_ARRAY);
Variant v = variant;
uint32_t denseSize = v.MapDenseSize();
for (uint32_t i = 0; i < denseSize; i++) {
v.RemoveAt(i);
}
#include "Particle.h"
// constructor function - executed directly!
Particle::Particle() {
velocity.set(1,2);
position.set(0,0);
mass = ofRandom(0.2,10);
forces.set(0.4,0.1);
}
@roxlu
roxlu / testApp.cpp
Created December 20, 2011 20:03
Arithmic Motion Mistake
#include "testApp.h"
#define DOT(a,b) a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
#define LENGTH(p) sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
#define NORMALIZE(p) { float l = LENGTH(p); p[0] /= l; p[1] /= l; p[2] /= l; }
#define CROSS(a,b) { a[1] * b[2] - a[2] * b[1], \
a[2] * b[0] - a[0] * b[2], \
a[0] * b[1] - a[1] * b[0]};
#define SUBTRACT(a,b,d) d[0] = a[0] - b[0]; d[1] = a[1] - b[1]; d[2] = a[2] - b[2];
#define SCALE(a, s) { NORMALIZE(a); a[0] *= s; a[1] *= s; a[2] *= s; }
#pragma once
#include "ofMain.h"
#include "Roxlu.h"
class testApp : public ofBaseApp{
public:
testApp();
void setup();
void update();
@roxlu
roxlu / ptf.cpp
Created December 27, 2011 22:05
Parallel Transport Frames - TEST
//--------------------------------------------------------------
void testApp::setup(){
ofSetFrameRate(60);
ofSetVerticalSync(true);
ofBackground(33);
donnie.create(125);
donnie.si.drawUsingQuads();
//renderer.addSceneItem(donnie.si);