Skip to content

Instantly share code, notes, and snippets.

@elliotwoods
Created October 22, 2011 01:55
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/1305428 to your computer and use it in GitHub Desktop.
Save elliotwoods/1305428 to your computer and use it in GitHub Desktop.
void testApp::setup(){
ifstream file ( ofToDataPath("fcrun2.csv").c_str() );
int i=0;
string value[3];
ofstream out("out.raw", ios::binary | ios::out);
ofVec2f v;
ofColor c;
while ( file.good() )
{
getline ( file, value[0], ',' );
getline ( file, value[1], ',' );
getline ( file, value[2], ',' );
if (i++/2 == 0) {
v = ofVec3f(ofToFloat(value[0]), ofToFloat(value[1]), ofToFloat(value[2])) / 1000.0f;
m.addVertex(v);
out.write((char*)&v, sizeof(ofVec3f));
} else {
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";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment