working on OdeWorld::loadPhy()
git-svn-id: svn://anubis/misc/OdeWorld@145 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
91517f2931
commit
aed3841f1e
43
OdeWorld.cc
43
OdeWorld.cc
@ -1,8 +1,30 @@
|
||||
|
||||
#include "OdeWorld.h"
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
#define WORLD_STEP 0.001
|
||||
|
||||
static string trim(const string & orig)
|
||||
{
|
||||
string result = orig;
|
||||
size_t pos = result.find_first_not_of(" \t\r\n\f");
|
||||
if (pos == string::npos)
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos > 0)
|
||||
result = result.substr(pos, result.length() - pos);
|
||||
pos = result.find_last_not_of(" \t\r\n\f");
|
||||
if (pos < result.length() - 1)
|
||||
result = result.substr(0, pos + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* used by ODE to perform collision detection */
|
||||
void OdeWorld_collide_callback(void * data, dGeomID o1, dGeomID o2)
|
||||
{
|
||||
@ -54,3 +76,24 @@ void OdeWorld::worldStep()
|
||||
dWorldQuickStep(m_world, WORLD_STEP);
|
||||
dJointGroupEmpty(m_contactJointGroup);
|
||||
}
|
||||
|
||||
vector<dGeomID> OdeWorld::loadPhy(const std::string & path,
|
||||
bool static_data)
|
||||
{
|
||||
vector<dGeomID> ret;
|
||||
|
||||
ifstream ifs(path.c_str());
|
||||
if (ifs.is_open())
|
||||
{
|
||||
while (!ifs.eof())
|
||||
{
|
||||
string line;
|
||||
getline(ifs, line);
|
||||
line = trim(line);
|
||||
if (line == "" || line[0] == '#')
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#define ODEWORLD_H
|
||||
|
||||
#include <ode/ode.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class OdeWorld
|
||||
{
|
||||
@ -14,6 +16,8 @@ class OdeWorld
|
||||
dWorldSetGravity(m_world, x, y, z);
|
||||
}
|
||||
void worldStep();
|
||||
std::vector<dGeomID> loadPhy(const std::string & path,
|
||||
bool static_data = false);
|
||||
|
||||
friend void OdeWorld_collide_callback(void * data,
|
||||
dGeomID o1, dGeomID o2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user