Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- allVertices.clear();
- allVertexNormals.clear();
- allIndices.clear();
- std::ifstream file_(path);
- std::string line;
- if (file_.is_open()) {
- while (!file_.eof()) {
- std::getline(file_, line);
- std::string header = line.substr(0, line.find_first_of(" ",0));
- if (!header.compare("#")) continue;
- if (!header.compare("v")) {
- glm::vec3 vertex;
- std::stringstream ss (line.substr(2));
- ss >> vertex.x >> vertex.y >> vertex.z;
- allVertices.push_back(vertex);
- }
- if (!header.compare("vn")) {
- glm::vec3 normal;
- std::stringstream ss(line.substr(3));
- ss >> normal.x >> normal.y >> normal.z;
- allVertexNormals.push_back(normal);
- }
- if (!header.compare("f")) {
- std::stringstream ss(line.substr(2));
- int i;
- while (ss >> i) {
- allIndices.push_back(i);
- //skip all space and /
- while(ss.peek() == ' ' || ss.peek() == '/'){
- ss.ignore();
- }
- }
- }
- }
- }
- else {
- std::cout << "Fail to open" << std::endl;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement