/* =============== R_RecursiveBoneListAdd =============== */ void R_RecursiveBoneListAdd(int bi, int *boneList, int *numBones, mdsBoneInfo_t *boneInfoList) { if (boneInfoList[bi].parent >= 0) { R_RecursiveBoneListAdd(boneInfoList[bi].parent, boneList, numBones, boneInfoList); } boneList[(*numBones)++] = bi; }
/* =============== R_GetBoneTag =============== */ int R_GetBoneTag( orientation_t *outTag, mdsHeader_t *mds, int startTagIndex, const refEntity_t *refent, const char *tagName ) { int i; mdsTag_t *pTag; mdsBoneInfo_t *boneInfoList; int boneList[ MDS_MAX_BONES ]; int numBones; if ( startTagIndex > mds->numTags ) { memset( outTag, 0, sizeof( *outTag ) ); return -1; } // find the correct tag pTag = ( mdsTag_t * )( (byte *)mds + mds->ofsTags ); pTag += startTagIndex; for ( i = startTagIndex; i < mds->numTags; i++, pTag++ ) { if ( !strcmp( pTag->name, tagName ) ) { break; } } if ( i >= mds->numTags ) { memset( outTag, 0, sizeof( *outTag ) ); return -1; } // now build the list of bones we need to calc to get this tag's bone information boneInfoList = ( mdsBoneInfo_t * )( (byte *)mds + mds->ofsBones ); numBones = 0; //LockBones R_RecursiveBoneListAdd( pTag->boneIndex, boneList, &numBones, boneInfoList ); R_CalcBones( (mdsHeader_t *)mds, refent, boneList, numBones, 0 ); //UnlockBones // now extract the orientation for the bone that represents our tag memcpy( outTag->axis, smpbones[0][ pTag->boneIndex ].matrix, sizeof( outTag->axis ) ); VectorCopy( smpbones[0][ pTag->boneIndex ].translation, outTag->origin ); return i; }
/* =============== R_GetBoneTag =============== */ int R_GetBoneTag(orientation_t *outTag, mdsHeader_t *mds, int startTagIndex, const refEntity_t *refent, const char *tagName) { int i; mdsTag_t *pTag; mdsBoneInfo_t *boneInfoList; int boneList[MDS_MAX_BONES]; int numBones; if (startTagIndex > mds->numTags) { memset(outTag, 0, sizeof(*outTag)); return -1; } // find the correct tag pTag = ( mdsTag_t * )((byte *)mds + mds->ofsTags); pTag += startTagIndex; for (i = startTagIndex; i < mds->numTags; i++, pTag++) { if (!strcmp(pTag->name, tagName)) { break; } } if (i >= mds->numTags) { memset(outTag, 0, sizeof(*outTag)); return -1; } // now build the list of bones we need to calc to get this tag's bone information boneInfoList = ( mdsBoneInfo_t * )((byte *)mds + mds->ofsBones); numBones = 0; R_RecursiveBoneListAdd(pTag->boneIndex, boneList, &numBones, boneInfoList); // calc the bones R_CalcBones((mdsHeader_t *)mds, refent, boneList, numBones); // now extract the orientation for the bone that represents our tag memcpy(outTag->axis, bones[pTag->boneIndex].matrix, sizeof(outTag->axis)); VectorCopy(bones[pTag->boneIndex].translation, outTag->origin); /* code not functional, not in backend if (r_bonesDebug->integer == 4) { int j; // DEBUG: show the tag position/axis GL_Bind( tr.whiteImage ); qglLineWidth( 2 ); qglBegin( GL_LINES ); for (j=0; j<3; j++) { VectorClear(vec); vec[j] = 1; qglColor3fv( vec ); qglVertex3fv( outTag->origin ); VectorMA( outTag->origin, 8, outTag->axis[j], vec ); qglVertex3fv( vec ); } qglEnd(); qglLineWidth( 1 ); } */ return i; }