Now what this code does is get our local bones and adds bone names and indexes for map and outputs them to a text-file. After it's done it will close our stream that outputs data into text-file and clears the map. Obviously we dont want to clear the map if we're going to use these for something later but this was just a quick test :p
credits:
- Gaben
- Tetsuo
- whoever wrote this: map (C++) - Wikipedia, the free encyclopedia
VOID WINAPI mapBones() { std::fstream fstrOut; typedef std::map<PCHAR, INT> boneMap; boneMap bones; while( TRUE ) { if( g_pEngineClient->IsInGame() ) { C_BasePlayer* LocalEntity = reinterpret_cast<C_BasePlayer*>( g_pClientEntList->GetClientEntity( g_pEngineClient->GetLocalPlayer() )); if( !LocalEntity ){ return; } if( !fstrOut.is_open() || fstrOut.bad() ) { fstrOut.open( "C:\\css_bones.txt", std::ios_base::out | std::ios_base::app ); } matrix3x4_t pMatrix[MAX_BONES]; const model_t *p_model = reinterpret_cast<const model_t*>( LocalEntity->GetModel() ); if( !p_model ){ return; } studiohdr_t *p_studiomodel = reinterpret_cast<studiohdr_t*>( g_pModelInfoClient->GetStudiomodel( p_model )); if( !p_studiomodel ){ return; } if( !LocalEntity->SetupBones( pMatrix, MAX_BONES, BONE_USED_BY_HITBOX, GetTickCount() )) return; mstudiobone_t *p_bone = NULL; for( size_t bone_index = 0; bone_index < p_studiomodel->numbones; ++bone_index ) { p_bone = (mstudiobone_t *)((PBYTE)p_studiomodel + p_studiomodel->boneindex); if( !p_bone ){ continue; } bones.insert( std::pair<PCHAR,INT>( p_bone[bone_index].pszName(), bone_index )); } boneMap::const_iterator iter; boneMap::const_iterator end = bones.end(); for ( iter = bones.begin(); iter != end; ++iter ) { fstrOut << "bone name: " << iter->first << std::endl; fstrOut << "bone index: " << iter->second << std::endl; } fstrOut.close(); bones.clear(); return; } } }
Output:
bone name: ValveBiped.Bip01_Pelvis bone index: 0 bone name: ValveBiped.Bip01_L_Thigh bone index: 1 bone name: ValveBiped.Bip01_L_Calf bone index: 2 bone name: ValveBiped.Bip01_L_Foot bone index: 3 bone name: ValveBiped.Bip01_L_Toe0 bone index: 4 bone name: ValveBiped.Bip01_R_Thigh bone index: 5 bone name: ValveBiped.Bip01_R_Calf bone index: 6 bone name: ValveBiped.Bip01_R_Foot bone index: 7 bone name: ValveBiped.Bip01_R_Toe0 bone index: 8 bone name: ValveBiped.Bip01_Spine bone index: 9 bone name: ValveBiped.Bip01_Spine1 bone index: 10 bone name: ValveBiped.Bip01_Spine2 bone index: 11 bone name: ValveBiped.Bip01_Spine4 bone index: 12 bone name: ValveBiped.Bip01_Neck1 bone index: 13 bone name: ValveBiped.Bip01_Head1 bone index: 14 bone name: ValveBiped.Bip01_L_Clavicle bone index: 15 bone name: ValveBiped.Bip01_L_UpperArm bone index: 16 bone name: ValveBiped.Bip01_L_Forearm bone index: 17 bone name: ValveBiped.Bip01_L_Hand bone index: 18 bone name: ValveBiped.Bip01_L_Finger2 bone index: 19 bone name: ValveBiped.Bip01_L_Finger21 bone index: 20 bone name: ValveBiped.Bip01_L_Finger22 bone index: 21 bone name: ValveBiped.Bip01_L_Finger1 bone index: 22 bone name: ValveBiped.Bip01_L_Finger11 bone index: 23 bone name: ValveBiped.Bip01_L_Finger12 bone index: 24 bone name: ValveBiped.Bip01_L_Finger0 bone index: 25 bone name: ValveBiped.Bip01_L_Finger01 bone index: 26 bone name: ValveBiped.Bip01_L_Finger02 bone index: 27 bone name: ValveBiped.Bip01_R_Clavicle bone index: 28 bone name: ValveBiped.Bip01_R_UpperArm bone index: 29 bone name: ValveBiped.Bip01_R_Forearm bone index: 30 bone name: ValveBiped.Bip01_R_Hand bone index: 31 bone name: ValveBiped.Bip01_R_Finger2 bone index: 32 bone name: ValveBiped.Bip01_R_Finger21 bone index: 33 bone name: ValveBiped.Bip01_R_Finger22 bone index: 34 bone name: ValveBiped.Bip01_R_Finger1 bone index: 35 bone name: ValveBiped.Bip01_R_Finger11 bone index: 36 bone name: ValveBiped.Bip01_R_Finger12 bone index: 37 bone name: ValveBiped.Bip01_R_Finger0 bone index: 38 bone name: ValveBiped.Bip01_R_Finger01 bone index: 39 bone name: ValveBiped.Bip01_R_Finger02 bone index: 40 bone name: ValveBiped.Bip01_R_Wrist bone index: 41 bone name: ValveBiped.Bip01_L_Wrist bone index: 42 bone name: ValveBiped.Bip01_L_Ulna bone index: 43 bone name: ValveBiped.Bip01_R_Ulna bone index: 44 bone name: ValveBiped.weapon_bone bone index: 45 bone name: ValveBiped.weapon_bone_RHand bone index: 46 bone name: ValveBiped.weapon_bone_LHand bone index: 47 bone name: ValveBiped.weapon_bone_Clip bone index: 48 bone name: ValveBiped.forward bone index: 49
Comment