diff --git a/OdeWorld.cc b/OdeWorld.cc index 4b2961f..244b251 100644 --- a/OdeWorld.cc +++ b/OdeWorld.cc @@ -2,14 +2,16 @@ #include "OdeWorld.h" #include #include +#include using namespace std; #define WORLD_STEP 0.001 +#define WHITESPACE " \t\r\n\f" static string trim(const string & orig) { string result = orig; - size_t pos = result.find_first_not_of(" \t\r\n\f"); + size_t pos = result.find_first_not_of(WHITESPACE); if (pos == string::npos) { result = ""; @@ -18,7 +20,7 @@ static string trim(const string & orig) { if (pos > 0) result = result.substr(pos, result.length() - pos); - pos = result.find_last_not_of(" \t\r\n\f"); + pos = result.find_last_not_of(WHITESPACE); if (pos < result.length() - 1) result = result.substr(0, pos + 1); } @@ -92,6 +94,30 @@ vector OdeWorld::loadPhy(const std::string & path, line = trim(line); if (line == "" || line[0] == '#') continue; + size_t pos = line.find_first_of(WHITESPACE); + if (pos == string::npos) + continue; + string type = line.substr(0, pos); + pos = line.find("\"", pos); + if (pos == string::npos) + continue; + size_t pos2 = line.find("\"", pos + 1); + if (pos2 == string::npos) + continue; + string name = line.substr(pos + 1, pos2 - pos - 1); + pos = pos2 + 1; + vector args; + for (;;) + { + pos = line.find_first_not_of(WHITESPACE, pos); + if (pos == string::npos) + break; + pos2 = line.find_first_of(WHITESPACE, pos); + string n = line.substr(pos, pos2 - pos); + float f = atof(n.c_str()); + args.push_back(f); + } + cerr << "Found a '" << type << "' of name '" << name << "' with " << args.size() << " args" << endl; } }