Skip to content

Instantly share code, notes, and snippets.

@kylemcdonald
Created November 17, 2014 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemcdonald/0548cd9b02705ccd2649 to your computer and use it in GitHub Desktop.
Save kylemcdonald/0548cd9b02705ccd2649 to your computer and use it in GitHub Desktop.
Hairball in openFrameworks.
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
ofEasyCam cam;
vector<ofVec3f> vertices;
ofVboMesh mesh;
void setup() {
ofSetVerticalSync(false);
int n = 250;
for(int i = 0; i < n; i++) {
ofVec3f v(ofRandom(50, 250), 0, 0);
v.rotate(ofRandom(360), ofRandom(360), ofRandom(360));
vertices.push_back(v);
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
mesh.addVertex(vertices[i]);
mesh.addVertex(vertices[j]);
}
}
ofLog() << mesh.getNumVertices() / 2;
mesh.setMode(OF_PRIMITIVE_LINES);
ofBackground(0);
}
void draw() {
ofSetColor(255, 2);
cam.begin();
ofRotateY(ofGetElapsedTimef() * 90);
mesh.draw();
cam.end();
ofSetColor(255);
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
};
int main() {
ofSetupOpenGL(1280, 720, OF_WINDOW);
ofRunApp(new ofApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment