diff --git a/src/include/sdk.h b/src/include/sdk.h index 7e773d0..d528689 100644 --- a/src/include/sdk.h +++ b/src/include/sdk.h @@ -21,6 +21,12 @@ /* triangleapi_s */ #include "sdk/common/triangleapi.h" +/* mstudioanim_t, mstudioseqdesc_t, mstudiobone_t, etc. */ +#include "sdk/engine/studio.h" + +/* model_t, vec4_t */ +#include "sdk/common/com_model.h" + /* * Credits: * https://github.com/UnkwUsr/hlhax/blob/26491984996c8389efec977ed940c5a67a0ecca4/src/sdk.h#L45 @@ -101,4 +107,186 @@ typedef struct cl_clientfuncs_s { void (*CLIENTFACTORY)(void); } cl_clientfunc_t; +/* + * Credits: + * https://github.com/UnkwUsr/hlhax/blob/26491984996c8389efec977ed940c5a67a0ecca4/src/sdk.h#L93 + */ +typedef struct StudioModelRenderer_s { + /* Construction/Destruction */ + void (*CStudioModelRenderer)(void* this_ptr); + void (*_CStudioModelRenderer)(void* this_ptr); + + /* Initialization */ + void (*Init)(void* this_ptr); + + /* Public Interfaces */ + int (*StudioDrawModel)(void* this_ptr, int flags); + int (*StudioDrawPlayer)(void* this_ptr, int flags, + struct entity_state_s* pplayer); + + /* ----- Local interfaces ----- */ + + /* Look up animation data for sequence */ + /* P.S. in other bases i know this have wrong return type: mstudioanim_t + * instead mstudioanim_t* :DD */ + mstudioanim_t* (*StudioGetAnim)(void* this_ptr, model_t* m_pSubModel, + mstudioseqdesc_t* pseqdesc); + + /* Interpolate model position and angles and set up matrices */ + void (*StudioSetUpTransform)(void* this_ptr, int trivial_accept); + + /* Set up model bone positions */ + void (*StudioSetupBones)(void* this_ptr); + + /* Find final attachment points */ + void (*StudioCalcAttachments)(void* this_ptr); + + /* Save bone matrices and names */ + void (*StudioSaveBones)(void* this_ptr); + + /* Merge cached bones with current bones for model */ + void (*StudioMergeBones)(void* this_ptr, model_t* m_pSubModel); + + /* Determine interpolation fraction */ + float (*StudioEstimateInterpolant)(void* this_ptr); + + /* Determine current frame for rendering */ + float (*StudioEstimateFrame)(void* this_ptr, mstudioseqdesc_t* pseqdesc); + + /* Apply special effects to transform matrix */ + void (*StudioFxTransform)(void* this_ptr, cl_entity_t* ent, + float transform[3][4]); + + /* Spherical interpolation of bones */ + void (*StudioSlerpBones)(void* this_ptr, vec4_t q1[], float pos1[][3], + vec4_t q2[], float pos2[][3], float s); + + /* Compute bone adjustments ( bone controllers ) */ + void (*StudioCalcBoneAdj)(void* this_ptr, float dadt, float* adj, + const byte* pcontroller1, + const byte* pcontroller2, byte mouthopen); + + /* Get bone quaternions */ + void (*StudioCalcBoneQuaterion)(void* this_ptr, int frame, float s, + mstudiobone_t* pbone, mstudioanim_t* panim, + float* adj, float* q); + + /* Get bone positions */ + void (*StudioCalcBonePosition)(void* this_ptr, int frame, float s, + mstudiobone_t* pbone, mstudioanim_t* panim, + float* adj, float* pos); + + /* Compute rotations */ + void (*StudioCalcRotations)(void* this_ptr, float pos[][3], vec4_t* q, + mstudioseqdesc_t* pseqdesc, + mstudioanim_t* panim, float f); + + /* Send bones and verts to renderer */ + void (*StudioRenderModel)(void* this_ptr); + + /* Finalize rendering */ + void (*StudioRenderFinal)(void* this_ptr); + + /* GL&D3D vs. Software renderer finishing functions */ + void (*StudioRenderFinal_Software)(void* this_ptr); + void (*StudioRenderFinal_Hardware)(void* this_ptr); + + /* Player specific data */ + /* Determine pitch and blending amounts for players */ + void (*StudioPlayerBlend)(void* this_ptr, mstudioseqdesc_t* pseqdesc, + int* pBlend, float* pPitch); + + /* Estimate gait frame for player */ + void (*StudioEstimateGait)(void* this_ptr, entity_state_t* pplayer); + + /* Process movement of player */ + void (*StudioProcessGait)(void* this_ptr, entity_state_t* pplayer); + + /* + // Client clock + double m_clTime; + // Old Client clock + double m_clOldTime; + + // Do interpolation? + int m_fDoInterp; + // Do gait estimation? + int m_fGaitEstimation; + + // Current render frame # + int m_nFrameCount; + + // Cvars that studio model code needs to reference + // Use high quality models? + cvar_t* m_pCvarHiModels; + // Developer debug output desired? + cvar_t* m_pCvarDeveloper; + // Draw entities bone hit boxes, etc? + cvar_t* m_pCvarDrawEntities; + + // The entity which we are currently rendering. + cl_entity_t* m_pCurrentEntity; + + // The model for the entity being rendered + model_t* m_pRenderModel; + + // Player info for current player, if drawing a player + player_info_t* m_pPlayerInfo; + + // The index of the player being drawn + int m_nPlayerIndex; + + // The player's gait movement + float m_flGaitMovement; + + // Pointer to header block for studio model data + studiohdr_t* m_pStudioHeader; + + // Pointers to current body part and submodel + mstudiobodyparts_t* m_pBodyPart; + mstudiomodel_t* m_pSubModel; + + // Palette substition for top and bottom of model + int m_nTopColor; + int m_nBottomColor; + + // + // Sprite model used for drawing studio model chrome + model_t* m_pChromeSprite; + + // Caching + // Number of bones in bone cache + int m_nCachedBones; + // Names of cached bones + char m_nCachedBoneNames[MAXSTUDIOBONES][32]; + // Cached bone & light transformation matrices + float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4]; + float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4]; + + // Software renderer scale factors + float m_fSoftwareXScale, m_fSoftwareYScale; + + // Current view vectors and render origin + float m_vUp[3]; + float m_vRight[3]; + float m_vNormal[3]; + + float m_vRenderOrigin[3]; + + // Model render counters ( from engine ) + int* m_pStudioModelCount; + int* m_pModelsDrawn; + + // Matrices + // Model to world transformation + float (*m_protationmatrix)[3][4]; + // Model to view transformation + float (*m_paliastransform)[3][4]; + + // Concatenated bone and light transforms + float (*m_pbonetransform)[MAXSTUDIOBONES][3][4]; + float (*m_plighttransform)[MAXSTUDIOBONES][3][4]; + */ +} StudioModelRenderer_t; + #endif /* SDK_H_ */