Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
8.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_PLAYERMODELPANEL_H
  8. #define TF_PLAYERMODELPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "basemodel_panel.h"
  13. #include "ichoreoeventcallback.h"
  14. class CChoreoScene;
  15. extern CMouthInfo g_ClientUIMouth;
  16. // A model panel that knows how to imitate a TF2 player, including wielding/wearing unlockable items.
  17. class CTFPlayerModelPanel : public CBaseModelPanel, public IChoreoEventCallback, public IHasLocalToGlobalFlexSettings, public IModelLoadCallback
  18. {
  19. DECLARE_CLASS_SIMPLE( CTFPlayerModelPanel, CBaseModelPanel );
  20. public:
  21. CTFPlayerModelPanel( vgui::Panel *pParent, const char *pName );
  22. ~CTFPlayerModelPanel( void );
  23. void ApplySettings( KeyValues *inResourceData );
  24. void SetToPlayerClass( int iClass, bool bIsRobot, bool bForceRefresh = false );
  25. bool HoldItemInSlot( int iSlot );
  26. bool HoldItem( int iItemNumber );
  27. void SwitchHeldItemTo( CEconItemView *pItem );
  28. void EquipRequiredLoadoutSlot( int iRequiredLoadoutSlot );
  29. CEconItemView *GetHeldItem() { return m_pHeldItem; }
  30. int AddCarriedItem( CEconItemView *pItem );
  31. void ClearCarriedItems( void );
  32. void PlayVCD( const char *pszVCD, const char *pszWeaponEntityRequired = NULL, bool bLoopVCD = true, bool bFileNameOnly = true );
  33. // Handle animation events
  34. virtual void FireEvent( const char *pszEventName, const char *pszEventOptions );
  35. const CUtlVector<CEconItemView*> &GetCarriedItems() { return m_ItemsToCarry; }
  36. int GetNumCarriedItems() const { return m_ItemsToCarry.Count(); }
  37. int GetPlayerClass() const { return m_iCurrentClassIndex; }
  38. Vector GetZoomOffset();
  39. void ToggleZoom();
  40. bool IsZoomed() { return m_bZoomedToHead; }
  41. void SetTeam( int iTeam );
  42. int GetTeam( void ) { return m_iTeam; }
  43. void UpdatePreviewVisuals( void );
  44. // From IChoreoEventCallback
  45. virtual void StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  46. virtual void EndEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  47. virtual void ProcessEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  48. virtual bool CheckEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  49. virtual void SetupFlexWeights( void );
  50. // IHasLocalToGlobalFlexSettings
  51. virtual void EnsureTranslations( const flexsettinghdr_t *pSettinghdr );
  52. int FlexControllerLocalToGlobal( const flexsettinghdr_t *pSettinghdr, int key );
  53. // IModelLoadCallback
  54. virtual void OnModelLoadComplete( const model_t *pModel );
  55. void SetEyeGlowEffect ( const char *pEffectName, Vector vColor1, Vector vColor2, bool bForceUpdate, bool bPlaySparks );
  56. void InvalidateParticleEffects();
  57. protected:
  58. // From CBaseModelPanel
  59. virtual void PrePaint3D( IMatRenderContext *pRenderContext ) OVERRIDE;
  60. virtual void PostPaint3D( IMatRenderContext *pRenderContext ) OVERRIDE;
  61. virtual void RenderingRootModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix );
  62. virtual void RenderingMergedModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix );
  63. virtual IMaterial* GetOverrideMaterial( MDLHandle_t mdlHandle ) OVERRIDE;
  64. private:
  65. enum modelpanel_particle_system_t
  66. {
  67. SYSTEM_HEAD = 0,
  68. SYSTEM_MISC1,
  69. SYSTEM_MISC2,
  70. SYSTEM_WEAPON, // there can only be one weapon equipped
  71. SYSTEM_ACTIONSLOT,
  72. SYSTEM_EYEGLOW_LEFT,
  73. SYSTEM_EYEGLOW_RIGHT,
  74. SYSTEM_EYESPARK_LEFT,
  75. SYSTEM_EYESPARK_RIGHT,
  76. SYSTEM_TAUNT,
  77. SYSTEM_COUNT,
  78. };
  79. // Choreo Scene handling
  80. void ClearScene( void );
  81. void ProcessSequence( CChoreoScene *scene, CChoreoEvent *event );
  82. void ProcessExpression( CChoreoScene *scene, CChoreoEvent *event );
  83. void ProcessFlexSettingSceneEvent( CChoreoScene *scene, CChoreoEvent *event );
  84. void ProcessLoop( CChoreoScene *scene, CChoreoEvent *event );
  85. void AddFlexSetting( const char *expr, float scale, const flexsettinghdr_t *pSettinghdr );
  86. void ProcessFlexAnimation( CChoreoScene *scene, CChoreoEvent *event );
  87. void SetFlexWeight( LocalFlexController_t index, float value );
  88. float GetFlexWeight( LocalFlexController_t index );
  89. LocalFlexController_t GetNumFlexControllers( void );
  90. const char *GetFlexDescFacs( int iFlexDesc );
  91. const char *GetFlexControllerName( LocalFlexController_t iFlexController );
  92. const char *GetFlexControllerType( LocalFlexController_t iFlexController );
  93. LocalFlexController_t FindFlexController( const char *szName );
  94. // Mouth processing
  95. CMouthInfo& MouthInfo() { return g_ClientUIMouth; }
  96. void ProcessVisemes( Emphasized_Phoneme *classes );
  97. void AddVisemesForSentence( Emphasized_Phoneme *classes, float emphasis_intensity, CSentence *sentence, float t, float dt, bool juststarted );
  98. void AddViseme( Emphasized_Phoneme *classes, float emphasis_intensity, int phoneme, float scale, bool newexpression );
  99. bool SetupEmphasisBlend( Emphasized_Phoneme *classes, int phoneme );
  100. void ComputeBlendedSetting( Emphasized_Phoneme *classes, float emphasis_intensity );
  101. void InitPhonemeMappings( void );
  102. void SetupMappings( char const *pchFileRoot );
  103. void HoldFirstValidItem( void );
  104. void EquipAllWearables( CEconItemView *pHeldItem );
  105. void EquipItem( CEconItemView *pItem );
  106. bool UpdateHeldItem( int iDesiredSlot );
  107. void UpdateWeaponBodygroups( bool bModifyDeployedOnlyBodygroups );
  108. void UpdateHiddenBodyGroups( CEconItemView* pItem );
  109. CEconItemView *GetItemInSlot( int iSlot );
  110. CEconItemView *GetPreviewItem( CEconItemView *pMatchItem );
  111. // Use this instead of SetMergeModel() - handles dynamic asset allocation
  112. void LoadAndAttachAdditionalModel( const char *pMDLName, CEconItemView *pItem );
  113. bool FinishAttachAdditionalModel( const model_t *pModel );
  114. void RemoveAdditionalModels( void );
  115. bool UpdateCosmeticParticles(
  116. IMatRenderContext *pRenderContext,
  117. CStudioHdr *pStudioHdr,
  118. MDLHandle_t mdlHandle,
  119. matrix3x4_t *pWorldMatrix,
  120. modelpanel_particle_system_t iSystem,
  121. CEconItemView *pEconItem
  122. );
  123. void UpdateEyeGlows( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix, bool bIsRightEye );
  124. void UpdateActionSlotEffects( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix );
  125. void UpdateTauntEffects( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix );
  126. int m_iCurrentClassIndex;
  127. int m_iCurrentSlotIndex;
  128. CUtlVector<CEconItemView*> m_ItemsToCarry; // Items that our player should be seen carrying
  129. QAngle m_angPlayerOrg;
  130. int m_nBody;
  131. int m_iTeam;
  132. bool m_bZoomedToHead;
  133. MDLHandle_t m_MergeMDL;
  134. CEconItemView *m_pHeldItem;
  135. const char *m_pszVCD;
  136. const char *m_pszWeaponEntityRequired;
  137. bool m_bLoopVCD;
  138. bool m_bVCDFileNameOnly;
  139. CChoreoScene *m_pScene;
  140. float m_flSceneTime;
  141. float m_flSceneEndTime;
  142. float m_flLastTickTime;
  143. bool m_bLoopScene;
  144. CUtlVector< CRefCountedModelIndex > m_vecDynamicAssetsLoaded;
  145. CUtlVector< CEconItemView* > m_vecItemsLoaded;
  146. struct CustomClassData_t
  147. {
  148. float m_flFOV;
  149. Vector m_vPosition;
  150. QAngle m_vAngles;
  151. };
  152. CUtlVector< CustomClassData_t > m_customClassData;
  153. // Choreo scenes
  154. bool m_bShouldRunFlexEvents;
  155. float m_flexWeight[ MAXSTUDIOFLEXCTRL ];
  156. Emphasized_Phoneme m_PhonemeClasses[ NUM_PHONEME_CLASSES ];
  157. CUtlRBTree< FS_LocalToGlobal_t, unsigned short > m_LocalToGlobal;
  158. // The particle system to draw
  159. particle_data_t *m_aParticleSystems[ SYSTEM_COUNT ];
  160. bool m_bUpdateEyeGlows;
  161. bool m_bPlaySparks;
  162. char m_pszEyeGlowParticleName[MAX_PATH];
  163. Vector m_vEyeGlowColor1;
  164. Vector m_vEyeGlowColor2;
  165. bool m_bDrawActionSlotEffects;
  166. bool m_bDrawTauntParticles;
  167. float m_flTauntParticleRefireTime;
  168. float m_flTauntParticleRefireRate;
  169. bool m_bIsRobot;
  170. CPanelAnimationVar( bool, m_bDisableSpeakEvent, "disable_speak_event", "0" );
  171. CEconItemView *GetLoadoutItemFromMDLHandle( loadout_positions_t iPosition, MDLHandle_t mdlHandle );
  172. bool RenderStatTrack( CStudioHdr *pStudioHdr, matrix3x4_t *pWorldMatrix );
  173. MDLData_t m_StatTrackModel;
  174. float m_flStatTrackScale;
  175. };
  176. #endif // TF_PLAYERMODELPANEL_H