Raised This Month: $51 Target: $400
 12% 

About SV_StudioSetupBones


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bos93
Veteran Member
Join Date: Jul 2010
Old 10-30-2013 , 08:07   About SV_StudioSetupBones
Reply With Quote #1

Can you give me more information about SV_StudioSetupBones?
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-30-2013 , 14:01   Re: About SV_StudioSetupBones
Reply With Quote #2

Code:
/* DESCRIPTION: SV_StudioSetupBones
// Location: SDK, as SetupBones
// PATH: An annoying API.
//
// This 'sets up' bones.  I'm starting to get the picture, but I don't know
// enough to describe what's actualy going on.
*/
void SV_StudioSetupBones(model_t * arg_0, float arg_4, int arg_8_sequence,
                         vec3_t arg_C, vec3_t arg_10, byte * arg_14,
                         byte * arg_18, int arg_1C, edict_t * unused) {

   int               i, j, var_270, var_26C[0x80];
   float             var_c, var_10, var_30[8];

   vec_t              bonematrix[3][4];
   mstudiobone_t      *pbones;
   mstudioseqdesc_t   *pseqdesc;
   mstudioanim_t      *panim;

   #define MAXSTUDIOBONES 128
   static vec3_t      pos[MAXSTUDIOBONES];
   static vec4_t      q[MAXSTUDIOBONES];
   static vec3_t      pos2[MAXSTUDIOBONES];
   static vec4_t      q2[MAXSTUDIOBONES];


   var_270 = 0;
   if(arg_8_sequence < 0 || arg_8_sequence >= pstudiohdr->numseq) {
      Con_Printf("%s: Sequence %i/%i out of range for model %s.\n", __FUNCTION__, arg_8_sequence, pstudiohdr->numseq, pstudiohdr->name);
      arg_8_sequence = 0;
   }

   pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + arg_8_sequence;
   pbones = (mstudiobone_t *)((byte *)pstudiohdr + pstudiohdr->boneindex);

   panim = R_GetAnim(arg_0, pseqdesc);

   if(arg_1C < -1 || arg_1C >= pstudiohdr->numbones) { arg_1C = 0; }
   if(arg_1C == -1) {
      var_270 = pstudiohdr->numbones;
      for(i = 0; i < pstudiohdr->numbones; i++) {

         var_26C[(var_270 - i) - 1] = i;
      }
   }
   else {
      for(i = arg_1C; i != -1; i = pbones[i].parent) {

         var_26C[var_270] = i;
         var_270++;
      }
   }

   if(pseqdesc->numframes > 1) {
      var_c = (pseqdesc->numframes - 1) * arg_4 / 256.0;
   }
   else {
      var_c = 0;
   }

   var_10 = var_c - (int)var_c; //so, the decimal part.
   R_StudioCalcBoneAdj(0, var_30, arg_14, arg_14, 0);

   for(j = var_270 - 1; j >= 0; j--) {

      i = var_26C[j];
      R_StudioCalcBoneQuaterion((int)var_c, var_10, &(pbones[i]), &(panim[i]), var_30, q[i]);
      R_StudioCalcBonePosition((int)var_c, var_10, &(pbones[i]), &(panim[i]), var_30, pos[i]);
   }

   if(pseqdesc->numblends > 1) {

      //Waitaminute, why are we doing this over again?
      pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + arg_8_sequence;
      panim = R_GetAnim(arg_0, pseqdesc);

      panim += pstudiohdr->numbones;

      for(j = var_270 - 1; j >= 0; j--) {

         i = var_26C[j];
         R_StudioCalcBoneQuaterion((int)var_c, var_10, &(pbones[i]), &(panim[i]), var_30, q2[i]);
         R_StudioCalcBonePosition((int)var_c, var_10, &(pbones[i]), &(panim[i]), var_30, pos2[i]);
      }

      R_StudioSlerpBones(q, pos, q2, pos2, ((float)(arg_18[0])) / 255.0);
   }

   AngleMatrix(arg_C, rotationmatrix);
   rotationmatrix[0][3] = arg_10[0];
   rotationmatrix[1][3] = arg_10[1];
   rotationmatrix[2][3] = arg_10[2];

   for(j = var_270 - 1; j >= 0; j--) {

      i = var_26C[j];
      QuaternionMatrix(q[i], bonematrix);
      bonematrix[0][3] = pos[i][0];
      bonematrix[1][3] = pos[i][0];
      bonematrix[2][3] = pos[i][0];

      //These two both pop up annoying errors about incompatible pointer types.  I don't see the flaw, and the right address is definitely being passed.
      if(pbones[i].parent == -1) {
         R_ConcatTransforms(rotationmatrix, bonematrix, bonetransform[i]);
      }
      else {
         R_ConcatTransforms(bonetransform[pbones[i].parent], bonematrix, bonetransform[i]);
      }
   }
}
Seems to be called from [FM_/EngFunc_]GetBonePosition and from [FM_/EngFunc_]GetAttachment
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-30-2013 at 14:05.
ConnorMcLeod is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 10-30-2013 , 14:48   Re: About SV_StudioSetupBones
Reply With Quote #3

Ok,thanks. Look this thread http://forums.alliedmods.net/showthread.php?t=196602

Problem with hitboxes.

SV_StudioSetupBones called with mp.dll,but doesn't called with swds.dll

Need hook it with mp.dll and called it with arguments from swds.dll, but i get problem with arguments.


I'm create npc (info_target), function is called, but not all arguments is correct

Debug: frame 30.000000 Animation 2, angles 0.000000 0.000000 0.000000, origin 0.
000000 -1.#QNAN0 0.000000


problem with angles,origin ...

PHP Code:
#include <extdll.h>
#include <meta_api.h>
#include "СHooker.h"

#if _MSC_VER
    #if _MSC_VER >= 1400
        #define stricmp _stricmp
    #endif
#endif

#ifdef __linux__
    #define stricmp    strcasecmp
#endif

plugin_info_t Plugin_info =
{
    
META_INTERFACE_VERSION,            // ifvers
    
"x",                  // name
    
"0.0.0.1",                        // version
    
"30/10/2013",                  // date
    
"Andrei",                     // author
    
"x",            // url
    
"x",                  // logtag, all caps please
    
PT_ANYTIME,                     // (when) loadable
    
PT_ANYPAUSE                     // (when) unloadable
};

meta_globals_t *gpMetaGlobals;
mutil_funcs_t *gpMetaUtilFuncs;
enginefuncs_t g_engfuncs;
globalvars_t  *gpGlobals;
gamedll_funcs_t *gpGamedllFuncs;

CHooker  HookerClass;
CHookerHooker = &HookerClass;

typedef void ( *FuncSV_StudioSetupBones ) ( struct model_s *, floatint, const vec3_t, const vec3_t, const byte *, const byte *, edict_t *, signed int );
void FuncSV_StudioSetupBones_Hookstruct model_s *pModelfloat frameint sequence, const vec3_t angles, const vec3_t origin, const byte *pcontroller, const byte *pblending
 
edict_t pEdictsigned int iBone );

CFuncFuncSV_StudioSetupBonesHook NULL;
FuncSV_StudioSetupBones  FuncSV_StudioSetupBonesOrig NULL;

void FuncSV_StudioSetupBones_Hookstruct model_s *pModelfloat frameint sequence, const vec3_t angles, const vec3_t origin, const byte *pcontroller, const byte *pblending
edict_t pEdictsigned int iBone )
{
    
printf"Debug: frame %f Animation %d, angles %f %f %f, origin %f %f %f\n"framesequenceangles.x,angles.y,angles.zorigin.xorigin.yorigin.);

    
/*if( FuncSV_StudioSetupBonesHook->Restore() )
    {
        FuncSV_StudioSetupBones_Hook( pModel, frame, sequence, angles, origin, pcontroller, pblending, pEdict, iBone );

        FuncSV_StudioSetupBonesHook->Patch();
    }*/
}

C_DLLEXPORT    int    Meta_Query(char    *ifversplugin_info_t **pPlugInfo,    mutil_funcs_t *pMetaUtilFuncs)
{
    
gpMetaUtilFuncs pMetaUtilFuncs;

    *
pPlugInfo = &Plugin_info;

    return(
TRUE);
}

static 
META_FUNCTIONS gMetaFunctionTable;
C_DLLEXPORT    int    Meta_Attach(PLUG_LOADTIME nowMETA_FUNCTIONS *pFunctionTablemeta_globals_t *pMGlobalsgamedll_funcs_t *pGamedllFuncs)
{
    
gpMetaGlobals pMGlobals;
    
gpGamedllFuncs=pGamedllFuncs;

    
memcpy(pFunctionTable, &gMetaFunctionTablesizeof(META_FUNCTIONS));
    
  
    
FuncSV_StudioSetupBonesOrig Hooker->MemorySearchFuncSV_StudioSetupBones >( "0x81,0xEC,*,*,*,*,0x53,0x55,0x8B,0xAC,0x24,0x68,0x02,0x00,0x00,0x56,0x57,0x55,0x33,0xFF,0xFF,0x15,*,*,*,*,0x8B,0x8C,0x24,0x7C,0x02,0x00,0x00,0x83,0xC4,0x04,0x85,0xC9,0xA3,*,*,*,*,0x7C,*,0x3B,0x88,0xA4,0x00,0x00,0x00,0x7C,*", ( void* )MDLL_SpawnFALSE );
    
//FuncSV_StudioSetupBonesOrig_Engine = Hooker->MemorySearch< FuncSV_StudioSetupBones_Engine >( "0x55,0x8B,0xEC,0x83,0xEC,0x48,0xA1,*,*,*,*,0x8B,0x0D,*,*,*,*,0x53,0x56,0x8B,0x90,0xDC,0x02,0x00,0x00,0x8B,0xB1,0xA4,0x00,0x00,0x00,0x3B,0xD6,0x57,0x7C,*,0xC7,0x80,0xDC,0x02,0x00,0x00,0x00,0x00,0x00,0x00", "engine", FALSE );

    
FuncSV_StudioSetupBonesHook Hooker->CreateHook( ( void* )FuncSV_StudioSetupBonesOrig, ( void* )FuncSV_StudioSetupBones_HookTRUE );
    return(
TRUE);
}

#ifdef __linux__
// linux prototype
C_DLLEXPORT void GiveFnptrsToDll(enginefuncs_tpengfuncsFromEngineglobalvars_t *pGlobals)
{
#else
#ifdef _MSC_VER
// MSVC: Simulate __stdcall calling convention
C_DLLEXPORT __declspec(nakedvoid GiveFnptrsToDll(enginefuncs_tpengfuncsFromEngineglobalvars_t *pGlobals)
{
    
__asm            // Prolog
    
{
        
// Save ebp
        
push        ebp
        
// Set stack frame pointer
        
mov            ebpesp
        
// Allocate space for local variables
        // The MSVC compiler gives us the needed size in __LOCAL_SIZE.
        
sub            esp__LOCAL_SIZE
        
// Push registers
        
push        ebx
        push        esi
        push        edi
    
}
#else    // _MSC_VER
#ifdef __GNUC__
// GCC can also work with this
C_DLLEXPORT void __stdcall GiveFnptrsToDllenginefuncs_tpengfuncsFromEngineglobalvars_t *pGlobals )
{
#else    // __GNUC__
// compiler not known
#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers or contact the AMX Mod X dev team.
#endif    // __GNUC__
#endif // _MSC_VER
#endif // __linux__

    // ** Function core <--
    
memcpy(&g_engfuncspengfuncsFromEnginesizeof(enginefuncs_t));
    
gpGlobals pGlobals;
    
// --> ** Function core

#ifdef _MSC_VER
    // Epilog
    
if (sizeof(int*) == 8)
    {    
// 64 bit
        
__asm
        
{
            
// Pop registers
            
pop    edi
            pop    esi
            pop    ebx
            
// Restore stack frame pointer
            
mov    espebp
            
// Restore ebp
            
pop    ebp
            
// 2 * sizeof(int*) = 16 on 64 bit
            
ret 16
        
}
    }
    else
    {    
// 32 bit
        
__asm
        
{
            
// Pop registers
            
pop    edi
            pop    esi
            pop    ebx
            
// Restore stack frame pointer
            
mov    espebp
            
// Restore ebp
            
pop    ebp
            
// 2 * sizeof(int*) = 8 on 32 bit
            
ret 8
        
}
    }
#endif // #ifdef _MSC_VER

PHP Code:
#include < amxmodx >
#include < fakemeta >

#define g_szModel "models/alien.mdl"

new Float:vecOrigin];

public 
plugin_precache( )
    
precache_modelg_szModel );

public 
plugin_init( )
{
    
register_clcmd"say /Origin""ClientCommand_Origin" );
    
register_clcmd"say /Create""ClientCommand__CreateEntity" );
}

public 
ClientCommand_OriginpPlayer )
    
pevpPlayerpev_originvecOrigin );

public 
ClientCommand__CreateEntitypPlayer )
{
    new 
pEntity engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );
    
    if( !
pev_validpEntity ) )
        return;
    
    
set_pevpEntitypev_classname"Alien" );
    
set_pevpEntitypev_modelg_szModel );
    
    
set_pevpEntitypev_solidSOLID_BBOX);
    
set_pevpEntitypev_movetypeMOVETYPE_PUSHSTEP);
    
    
vecOrigin] += 50.0;
    
    
engfuncEngFunc_SetModelpEntityg_szModel);
    
engfuncEngFunc_SetSizepEntityFloat:{ -32.0, -32.0, -36.0}, Float:{  32.0,  32.0,  32.0 });
    
engfuncEngFunc_SetOriginpEntityvecOrigin );
    
    
set_pevpEntitypev_sequence);
    
set_pevpEntitypev_frame30);
    
set_pevpEntitypev_animtimeget_gametime());
    
set_pevpEntitypev_framerate1.0 );


Why arguments are passed is not true? Sorry for my bad English

Last edited by Bos93; 10-31-2013 at 01:41.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode