filling out more of loadPhy()
git-svn-id: svn://anubis/misc/OdeWorld@146 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
aed3841f1e
commit
6723e1bf3b
30
OdeWorld.cc
30
OdeWorld.cc
@ -2,14 +2,16 @@
|
||||
#include "OdeWorld.h"
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
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<dGeomID> 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<float> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user