// we need to add a bone to the list - find a free one and see if we can find a corresponding bone in the gla file int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) { int i, x; mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; boneInfo_t tempBone; offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find for (x=0; x< mod->mdxa->numBones; x++) { skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); // if name is the same, we found it if (!stricmp(skel->name, boneName)) { break; } } // check to see we did actually make a match with a bone in the model if (x == mod->mdxa->numBones) { // didn't find it? Error assert(0); return -1; } // look through entire list - see if it's already there first for(i=0; i<blist.size(); i++) { // if this bone entry has info in it, bounce over it if (blist[i].boneNumber != -1) { skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); // if name is the same, we found it if (!stricmp(skel->name, boneName)) { return i; } } else { // if we found an entry that had a -1 for the bonenumber, then we hit a bone slot that was empty blist[i].boneNumber = x; blist[i].flags = 0; return i; } } // ok, we didn't find an existing bone of that name, or an empty slot. Lets add an entry tempBone.boneNumber = x; tempBone.flags = 0; blist.push_back(tempBone); return blist.size()-1; }
// we need to add a bone to the list - find a free one and see if we can find a corresponding bone in the gla file int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) { int i, x; mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; boneInfo_t tempBone; offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find for (x=0; x< mod->mdxa->numBones; x++) { skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); // if name is the same, we found it if (!stricmp(skel->name, boneName)) { break; } } // check to see we did actually make a match with a bone in the model if (x == mod->mdxa->numBones) { #if _DEBUG G2_Bone_Not_Found(boneName,mod->name); #endif return -1; } // look through entire list - see if it's already there first for(i=0; i<blist.size(); i++) { // if this bone entry has info in it, bounce over it if (blist[i].boneNumber != -1) { skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); // if name is the same, we found it if (!stricmp(skel->name, boneName)) { #if DEBUG_G2_BONES { char mess[1000]; sprintf(mess,"ADD BONE1 blistIndex=%3d physicalIndex=%3d %s\n", i, x, boneName); OutputDebugString(mess); } #endif return i; } } else { // if we found an entry that had a -1 for the bonenumber, then we hit a bone slot that was empty blist[i].boneNumber = x; blist[i].flags = 0; #if DEBUG_G2_BONES { char mess[1000]; sprintf(mess,"ADD BONE1 blistIndex=%3d physicalIndex=%3d %s\n", i, x, boneName); OutputDebugString(mess); } #endif return i; } } // ok, we didn't find an existing bone of that name, or an empty slot. Lets add an entry tempBone.boneNumber = x; tempBone.flags = 0; blist.push_back(tempBone); #if DEBUG_G2_BONES { char mess[1000]; sprintf(mess,"ADD BONE1 blistIndex=%3d physicalIndex=%3d %s\n", blist.size()-1, x, boneName); OutputDebugString(mess); } #endif return blist.size()-1; }