void C3DMeshSkin::copyFrom(C3DMeshSkin* skin, C3DNode::CloneContext& context) { _bindShape = skin->_bindShape; std::map<const C3DNode*, C3DNode*>::iterator it = context.cloneMap.find(skin->_rootJoint); C3DBone* rootbone = NULL; if (it == context.cloneMap.end()) rootbone = (C3DBone*)skin->_rootJoint->clone(context); else rootbone = (C3DBone*)it->second; setJointCount(skin->getJointCount()); setRootJoint(rootbone); size_t i; for (i = 0; i < skin->_joints.size(); i++) { std::string strid = skin->_joints[i]->getId(); // strid += context.idSuffix; //C3DBone* bone = (strid == rootbone->getId() ? rootbone : (C3DBone*)rootbone->findNode(strid.c_str())); //C3DBone* bone = (C3DBone*)context.cloneMap[skin->_joints[i]]; ///.... std::map<const C3DNode*, C3DNode*>::iterator itr = context.cloneMap.find(skin->_joints[i]); C3DBone* bone = NULL; if (itr != context.cloneMap.end()) { bone = static_cast<C3DBone*>(itr->second); } else { C3DBone* newNode = static_cast<C3DBone*>(skin->_joints[i]->clone(context)); if (newNode) { context.cloneMap[skin->_joints[i]] = newNode; bone = newNode; } } //..... setJoint(bone, i); //bone->release(); } for (i = 0; i < skin->_partCount; i++) { addPart(skin->_parts[i]->_batchID, skin->_parts[i]->_offsetVertexIndex, skin->_parts[i]->_numVertexIndex); _parts[i]->setIndexData(&skin->_parts[i]->_indices[0], skin->_parts[i]->_indices.size()); } setBonePartIndex(skin->getBonePartIndex()); }
void MakeHSkeleton::fitToMakeHMesh(const std::vector<vec3>& _V) { if(_V.size() != 19811) { PRINTERROR("no make human topology used"); return; } for(unsigned int i = 0; i < 19; ++i) { vec3 jPos = REAL(0.5) * (_V[skelIdsMakeH[i][0]] + _V[skelIdsMakeH[i][1]]); setJoint(i, jPos); } updateBonesByJoints(_V); }
void ColladaBodyLoaderImpl::buildLinks(DaeNode* extNode, DaeNode* parentNode, Link* parentLink, Body& body, int& jointId) { bool duplicate; Link* link = NULL; if (DaeLink* extLink = dynamic_cast<DaeLink*>(extNode)) { // It will record the link. // The link and joint is one in two. // In addition, link will be child relationship (except root) in the parent joint always. setLink(extNode, parentLink, body); setMass(extLink, parentLink); for (DaeLinkChildren::iterator iterl = extLink->children.begin(); iterl != extLink->children.end(); iterl++) { DaeNode* extJoint = parser->findJointByLink(*iterl); buildLinks(extJoint, extLink, parentLink, body, jointId); } } else if (DaeJoint* extJoint = dynamic_cast<DaeJoint*>(extNode)) { if (!parentLink) { throwException((format(_("joint node can not be root link"))).str()); } // It will record the link. link = createLink(body, static_cast<DaeJoint*>(extNode)->name, &duplicate); // The joint and link is one in the link. setJoint(extNode, parentNode, link, jointId); parentLink->appendChild(link); for (DaeJointChildren::iterator iterj = extJoint->children.begin(); iterj != extJoint->children.end(); iterj++) { // Joint is same as link. (Comprehension) DaeNode* extLink = parser->findLinkByJoint(*iterj); buildLinks(extLink, extJoint, link, body, jointId); } } else { return; } }