// ------------------------------------------------------------------------------------------------ void COBImporter::ReadMat1_Ascii(Scene& out, LineSplitter& splitter, const ChunkInfo& nfo) { if(nfo.version > 8) { return UnsupportedChunk_Ascii(splitter,nfo,"Mat1"); } ++splitter; if (!splitter.match_start("mat# ")) { ASSIMP_LOG_WARN_F( "Expected `mat#` line in `Mat1` chunk ", nfo.id ); return; } out.materials.push_back(Material()); Material& mat = out.materials.back(); mat = nfo; mat.matnum = strtoul10(splitter[1]); ++splitter; if (!splitter.match_start("shader: ")) { ASSIMP_LOG_WARN_F( "Expected `mat#` line in `Mat1` chunk ", nfo.id); return; } std::string shader = std::string(splitter[1]); shader = shader.substr(0,shader.find_first_of(" \t")); if (shader == "metal") { mat.shader = Material::METAL; } else if (shader == "phong") { mat.shader = Material::PHONG; } else if (shader != "flat") { ASSIMP_LOG_WARN_F( "Unknown value for `shader` in `Mat1` chunk ", nfo.id ); } ++splitter; if (!splitter.match_start("rgb ")) { ASSIMP_LOG_WARN_F( "Expected `rgb` line in `Mat1` chunk ", nfo.id); } const char* rgb = splitter[1]; ReadFloat3Tuple_Ascii(mat.rgb,&rgb); ++splitter; if (!splitter.match_start("alpha ")) { ASSIMP_LOG_WARN_F( "Expected `alpha` line in `Mat1` chunk ", nfo.id); } const char* tokens[10]; splitter.get_tokens(tokens); mat.alpha = fast_atof( tokens[1] ); mat.ka = fast_atof( tokens[3] ); mat.ks = fast_atof( tokens[5] ); mat.exp = fast_atof( tokens[7] ); mat.ior = fast_atof( tokens[9] ); }
// ------------------------------------------------------------------------------------------------ void COBImporter::ReadChunkInfo_Ascii(ChunkInfo& out, const LineSplitter& splitter) { const char* all_tokens[8]; splitter.get_tokens(all_tokens); out.version = (all_tokens[1][1]-'0')*100+(all_tokens[1][3]-'0')*10+(all_tokens[1][4]-'0'); out.id = strtoul10(all_tokens[3]); out.parent_id = strtoul10(all_tokens[5]); out.size = strtol10(all_tokens[7]); }