Muscle* IESoRWorld::addMuscleJoint(std::string sourceID, std::string targetID, Json::Value props) { //we add a standard distance joint Bone* addedJoint = addDistanceJoint(sourceID, targetID, props); //But our muscles have phase and amplitude, which adjust length during updates double phase = 0; //check if we defined phase value, if so fetch it from json if(!props["phase"].isNull()) { phase = props["phase"].asDouble(); } //amplitude is how much change each muscles exhibits double amplitude = 1; //check if it's in our props object if(!props["amplitude"].isNull()) { phase = props["amplitude"].asDouble(); } //muscle is just a container for our Muscle* ms = new Muscle(toString(this->muscleList.size()), addedJoint->GetJoint(), amplitude, phase); //track the muscle objects this way, pretty easy this->muscleList.push_back(ms); //send back the joint we added to physical world return ms; }