Code: Select all
Json::Value jointValue;
b2Joint *tmpJoint;
tmpJoint=json->getJointByName("jointName");
jointValue=json->b2j(tmpJoint);
json->j2b2Joint(World,jointValue);
Code: Select all
b2Assert(def->bodyA != def->bodyB);
Code: Select all
Json::Value jointValue;
b2Joint *tmpJoint;
tmpJoint=json->getJointByName("jointName");
jointValue=json->b2j(tmpJoint);
json->j2b2Joint(World,jointValue);
Code: Select all
b2Assert(def->bodyA != def->bodyB);
Code: Select all
//reading functions
...
b2Joint* j2b2NewJoint(b2World* world, Json::Value jointValue, b2Body *bodyA, b2Body *bodyB);
...
Code: Select all
b2Joint* b2dJson::j2b2NewJoint(b2World* world, Json::Value jointValue, b2Body *bodyA, b2Body *bodyB)
{
b2Joint* joint = NULL;
////////////* comment out these four lines *////
// int bodyIndexA = jointValue["bodyA"].asInt();
// int bodyIndexB = jointValue["bodyB"].asInt();
// if ( bodyIndexA >= (int)m_bodies.size() || bodyIndexB >= (int)m_bodies.size() )
// return NULL;
...
if ( jointDef ) {
//set features common to all joints
////////////* replace with parameters *////
jointDef->bodyA = bodyA;//m_bodies[bodyIndexA];
jointDef->bodyB = bodyB;//m_bodies[bodyIndexB];
...
}
return joint;
}
Code: Select all
json->j2b2NewJoint(World,jointValue,bodyA,bodyB);