Skip to content

Instantly share code, notes, and snippets.

@hb3p8
Last active April 6, 2016 14:15
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 hb3p8/ef01afa46c77ad024737 to your computer and use it in GitHub Desktop.
Save hb3p8/ef01afa46c77ad024737 to your computer and use it in GitHub Desktop.
std::ofstream aFile ( "Mesh.obj" );
for (int i = 0; i < aMesh->numVertices(); ++i) {
aFile << "v " << aMesh->vertices()[i].x() << " "
<< aMesh->vertices()[i].y() << " "
<< aMesh->vertices()[i].z() << std::endl;
}
for (int i = 0; i < aMesh->numVertices(); ++i) {
aFile << "vn " << aMesh->normals()[i].x() << " "
<< aMesh->normals()[i].y() << " "
<< aMesh->normals()[i].z() << std::endl;
}
for (int i = 0; i < aMesh->numElements(); ++i) {
aFile << "f " << (aMesh->elements()[i].x() + 1) << " "
<< (aMesh->elements()[i].y() + 1) << " "
<< (aMesh->elements()[i].z() + 1) << std::endl;
}
aFile.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment