Skip to content

Instantly share code, notes, and snippets.

@elliotwoods
Created October 22, 2011 02:31
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 elliotwoods/1305465 to your computer and use it in GitHub Desktop.
Save elliotwoods/1305465 to your computer and use it in GitHub Desktop.
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
glEnable(GL_DEPTH_TEST);
ifstream file ( ofToDataPath("fcrun2.csv").c_str() );
int i=0;
string value[3];
ofstream out("out.raw", ios::binary | ios::out);
ofVec3f v;
ofColor c;
while ( file.good() )
{
if (i++%2 == 0) {
getline ( file, value[0], ',' );
getline ( file, value[1], ',' );
getline ( file, value[2], ',' );
v = ofVec3f(ofToFloat(value[0]), ofToFloat(value[1]), ofToFloat(value[2])) / 1000.0f;
m.addVertex(v);
out.write((char*)&v, sizeof(ofVec3f));
} else {
getline ( file, value[0], ',' );
getline ( file, value[1], ',' );
getline ( file, value[2] );
c = ofColor(ofToFloat(value[0]), ofToFloat(value[1]), ofToFloat(value[2]));
m.addColor(c);
out.write((char*)&c, sizeof(ofColor));
}
if (i % 100 == 0)
cout << i/2 << endl;
}
file.close();
out.close();
cout << i/2 << " points loaded";
cam.setDistance(100);
}
//--------------------------------------------------------------
void testApp::draw(){
cam.begin();
m.drawVertices();
cam.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment