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.

193 lines
4.7 KiB

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