Counter Strike : Global Offensive Source Code
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.

194 lines
4.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef FACEPOSER_MODELS_H
  8. #define FACEPOSER_MODELS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. class StudioModel;
  13. #include "tier0/platform.h"
  14. #include "mxbitmaptools.h"
  15. typedef uint32 CRC32_t;
  16. class IFaceposerModels
  17. {
  18. public:
  19. IFaceposerModels();
  20. virtual ~IFaceposerModels();
  21. virtual int Count( void ) const;
  22. virtual char const *GetModelName( int index );
  23. virtual char const *GetModelFileName( int index );
  24. virtual int GetActiveModelIndex( void ) const;
  25. virtual char const *GetActiveModelName( void );
  26. virtual StudioModel *GetActiveStudioModel( void );
  27. virtual void ForceActiveModelIndex( int index );
  28. virtual void UnForceActiveModelIndex();
  29. virtual int FindModelByFilename( char const *filename );
  30. virtual int LoadModel( char const *filename );
  31. virtual void FreeModel( int index );
  32. virtual void CloseAllModels( void );
  33. virtual StudioModel *GetStudioModel( int index );
  34. virtual CStudioHdr *GetStudioHeader( int index );
  35. virtual int GetIndexForStudioModel( StudioModel *model );
  36. virtual int GetModelIndexForActor( char const *actorname );
  37. virtual StudioModel *GetModelForActor( char const *actorname );
  38. virtual char const *GetActorNameForModel( int modelindex );
  39. virtual void SetActorNameForModel( int modelindex, char const *actorname );
  40. virtual int CountVisibleModels( void );
  41. virtual void ShowModelIn3DView( int modelindex, bool show );
  42. virtual bool IsModelShownIn3DView( int modelindex );
  43. virtual void SaveModelList( void );
  44. virtual void LoadModelList( void );
  45. virtual void ReleaseModels( void );
  46. virtual void RestoreModels( void );
  47. //virtual void RefreshModels( void );
  48. virtual void CheckResetFlexes( void );
  49. virtual void ClearOverlaysSequences( void );
  50. virtual mxbitmapdata_t *GetBitmapForSequence( int modelindex, int sequence );
  51. virtual void RecreateAllAnimationBitmaps( int modelindex );
  52. virtual void RecreateAnimationBitmap( int modelindex, int sequence );
  53. virtual void CreateNewBitmap( int modelindex, char const *pchBitmapFilename, int sequence, int nSnapShotSize, bool bZoomInOnFace, class CExpression *pExpression, mxbitmapdata_t *bitmap );
  54. virtual int CountActiveSources();
  55. virtual void SetSolveHeadTurn( int solve );
  56. virtual void ClearModelTargets( bool force = false );
  57. private:
  58. class CFacePoserModel
  59. {
  60. public:
  61. CFacePoserModel( char const *modelfile, StudioModel *model );
  62. ~CFacePoserModel();
  63. void LoadBitmaps();
  64. void FreeBitmaps();
  65. mxbitmapdata_t *GetBitmapForSequence( int sequence );
  66. const char *GetBitmapChecksum( int sequence );
  67. CRC32_t GetBitmapCRC( int sequence );
  68. const char *GetBitmapFilename( int sequence );
  69. void RecreateAllAnimationBitmaps();
  70. void RecreateAnimationBitmap( int sequence, bool reconcile );
  71. void SetActorName( char const *actorname )
  72. {
  73. strcpy( m_szActorName, actorname );
  74. }
  75. char const *GetActorName( void ) const
  76. {
  77. return m_szActorName;
  78. }
  79. StudioModel *GetModel( void ) const
  80. {
  81. return m_pModel;
  82. }
  83. char const *GetModelFileName( void ) const
  84. {
  85. return m_szModelFileName;
  86. }
  87. char const *GetShortModelName( void ) const
  88. {
  89. return m_szShortName;
  90. }
  91. void SetVisibleIn3DView( bool visible )
  92. {
  93. m_bVisibileIn3DView = visible;
  94. }
  95. bool GetVisibleIn3DView( void ) const
  96. {
  97. return m_bVisibileIn3DView;
  98. }
  99. // For material system purposes
  100. void Release( void );
  101. void Restore( void );
  102. void Refresh( void )
  103. {
  104. // Forces a reload from disk
  105. Release();
  106. Restore();
  107. }
  108. void CreateNewBitmap( char const *pchBitmapFilename, int sequence, int nSnapShotSize, bool bZoomInOnFace, class CExpression *pExpression, mxbitmapdata_t *bitmap );
  109. private:
  110. void LoadBitmapForSequence( mxbitmapdata_t *bitmap, int sequence );
  111. void ReconcileAnimationBitmaps();
  112. void BuildValidChecksums( CUtlRBTree< CRC32_t > &tree );
  113. enum
  114. {
  115. MAX_ACTOR_NAME = 64,
  116. MAX_MODEL_FILE = 128,
  117. MAX_SHORT_NAME = 32,
  118. };
  119. char m_szActorName[ MAX_ACTOR_NAME ];
  120. char m_szModelFileName[ MAX_MODEL_FILE ];
  121. char m_szShortName[ MAX_SHORT_NAME ];
  122. StudioModel *m_pModel;
  123. bool m_bVisibileIn3DView;
  124. struct AnimBitmap
  125. {
  126. AnimBitmap()
  127. {
  128. needsload = false;
  129. bitmap = 0;
  130. }
  131. bool needsload;
  132. mxbitmapdata_t *bitmap;
  133. };
  134. CUtlVector< AnimBitmap * > m_AnimationBitmaps;
  135. bool m_bFirstBitmapLoad;
  136. };
  137. CFacePoserModel *GetEntry( int index );
  138. CUtlVector< CFacePoserModel * > m_Models;
  139. int m_nLastRenderFrame;
  140. int m_nForceModelIndex;
  141. };
  142. extern IFaceposerModels *models;
  143. void EnableStickySnapshotMode( void );
  144. void DisableStickySnapshotMode( void );
  145. #endif // FACEPOSER_MODELS_H