diff --git a/cocos/3d/CCObjLoader.cpp b/cocos/3d/CCObjLoader.cpp index 0c54442d95..2facde285d 100644 --- a/cocos/3d/CCObjLoader.cpp +++ b/cocos/3d/CCObjLoader.cpp @@ -273,6 +273,15 @@ void InitMaterial(ObjLoader::material_t& material) material.unknown_parameter.clear(); } +static std::string& replacePathSeperator(std::string& path) +{ + for (int i = 0; i < path.size(); i++) { + if (path[i] == '\\') + path[i] = '/'; + } + return path; +} + std::string LoadMtl ( std::map& material_map, const char* filename, const char* mtl_basepath) { material_map.clear(); @@ -451,6 +460,7 @@ std::string LoadMtl ( std::map& material_map { token += 7; material.ambient_texname = trim(token); + replacePathSeperator(material.ambient_texname); continue; } @@ -459,6 +469,7 @@ std::string LoadMtl ( std::map& material_map { token += 7; material.diffuse_texname = trim(token); + replacePathSeperator(material.diffuse_texname); continue; } @@ -467,6 +478,7 @@ std::string LoadMtl ( std::map& material_map { token += 7; material.specular_texname = trim(token); + replacePathSeperator(material.specular_texname); continue; } @@ -475,6 +487,7 @@ std::string LoadMtl ( std::map& material_map { token += 7; material.normal_texname = trim(token); + replacePathSeperator(material.normal_texname); continue; }