maluramichael
9/21/2014 - 4:10 PM

gistfile1.cpp

void Model::LoadFromFile(std::string const& file) {

	std::ifstream fileStream;
	fileStream.open(file);
	if (!fileStream.is_open())
	{
		Bridge::Helper::Logger::getInstance().writeLine(Bridge::Helper::Logger::Error, "Failed to open %s", file.c_str());
		return;
	}
	
	std::string line;
	
	while(std::getline(fileStream, line)) {
	
		std::stringstream stream(line);
		std::string type;
		stream >> type;
		
		if (type == "#"){ // Comment
		
		} else if  (type == "v"){ // Vertex coordinate
			Bridge::Helper::Logger::getInstance().writeLine(Bridge::Helper::Logger::Error, "%s", stream.str().c_str());		
			float x, y, z;
			stream >> x >> y >> z;
			Bridge::Helper::Logger::getInstance().writeLine(Bridge::Helper::Logger::Error, "%d %d %d", x, y, z);
		} else if  (line.compare(0, 2, "vt") == 0){ // Texture coordinate
		} else if  (line.compare(0, 2, "vn") == 0){ // Normal coordinate
		} else if  (line.compare(0, 1, "f") == 0){ // Face
		} else if  (line.compare(0, 1, "o") == 0){ // Name
		} else if  (line.compare(0, 6, "mtllib") == 0){ // 
		} else if  (line.compare(0, 6, "usemtl") == 0){ // 
		} else if  (line.compare(0, 1, "s") == 0){ // 
		}
	}
}