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.

209 lines
6.7 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Dme version of a game model (MDL)
  4. //
  5. //=============================================================================
  6. #ifndef DMEGAMEMODEL_H
  7. #define DMEGAMEMODEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "movieobjects/dmedag.h"
  12. #include "movieobjects/dmeoperator.h"
  13. #include "datacache/imdlcache.h"
  14. #include "tier1/UtlDict.h"
  15. #include "toolframework/itoolframework.h"
  16. struct studiohdr_t;
  17. // Fixme, this might not be the best spot for this
  18. class IGlobalFlexController
  19. {
  20. public:
  21. virtual int FindGlobalFlexController( char const *name ) = 0;
  22. virtual char const *GetGlobalFlexControllerName( int idx ) = 0;
  23. };
  24. class CDmeGameModel;
  25. // Mapping from name to dest index
  26. class CDmeGlobalFlexControllerOperator : public CDmeOperator
  27. {
  28. DEFINE_ELEMENT( CDmeGlobalFlexControllerOperator, CDmeOperator );
  29. public:
  30. void SetGameModel( CDmeGameModel *gameModel );
  31. virtual void Resolve();
  32. virtual void Operate();
  33. virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
  34. virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
  35. void SetWeight( float flWeight );
  36. void SetMapping( int globalIndex );
  37. void SetupToAttribute();
  38. int GetGlobalIndex() const;
  39. virtual void OnAttributeChanged( CDmAttribute *pAttribute );
  40. CDmaVar< float > m_flexWeight;
  41. CDmaElement< CDmeGameModel > m_gameModel;
  42. DmAttributeHandle_t m_ToAttributeHandle;
  43. private:
  44. int FindGlobalFlexControllerIndex() const;
  45. int m_nFlexControllerIndex;
  46. };
  47. //-----------------------------------------------------------------------------
  48. // A class representing a game model
  49. //-----------------------------------------------------------------------------
  50. class CDmeGameModel : public CDmeDag
  51. {
  52. DEFINE_ELEMENT( CDmeGameModel, CDmeDag );
  53. public:
  54. virtual void OnAttributeChanged( CDmAttribute *pAttribute );
  55. void AddBone( CDmeTransform* pTransform );
  56. void AddBones( studiohdr_t *pStudioHdr, int nFirstBone, int nCount );
  57. void SetBone( uint index, const Vector& pos, const Quaternion& rot );
  58. uint NumBones() const;
  59. CDmeTransform *GetBone( uint index ) const;
  60. int FindBone( CDmeTransform *pTransform ) const;
  61. void RemoveAllBones();
  62. // A src bone transform transforms pre-compiled data (.dmx or .smd files, for example)
  63. // into post-compiled data (.mdl or .ani files)
  64. // Returns false if there is no transform (or if the transforms are identity)
  65. bool GetSrcBoneTransforms( matrix3x4_t *pPreTransform, matrix3x4_t *pPostTransform, int nBoneIndex ) const;
  66. bool GetBoneDefaultPosition( int nBoneIndex, Vector &position ) const;
  67. bool GetBoneDefaultOrientation( int nBoneIndex, Quaternion &orientation ) const;
  68. bool IsRootTransform( int nBoneIndex ) const;
  69. uint NumFlexWeights() const;
  70. const CUtlVector< float >& GetFlexWeights() const;
  71. // We drive these through the operators instead
  72. // void SetFlexWeights( uint nFlexWeights, const float* flexWeights );
  73. void SetNumFlexWeights( uint nFlexWeights );
  74. void SetFlexWeights( uint nFlexWeights, const float* flexWeights );
  75. void SetSkin( int nSkin );
  76. void SetBody( int nBody );
  77. void SetSequence( int nSequence );
  78. void SetFlags( int nFlags );
  79. int GetSkin() const;
  80. int GetBody() const;
  81. int GetSequence() const;
  82. int GetFlags() const;
  83. const char *GetModelName() const;
  84. MDLHandle_t GetModelHandle();
  85. CDmeGlobalFlexControllerOperator *AddGlobalFlexController( char const *controllerName, int globalIndex );
  86. CDmeGlobalFlexControllerOperator *FindGlobalFlexController( int nGlobalIndex );
  87. void RemoveGlobalFlexController( CDmeGlobalFlexControllerOperator *controller );
  88. int NumGlobalFlexControllers() const;
  89. CDmeGlobalFlexControllerOperator *GetGlobalFlexController( int localIndex ); // localIndex is in order of calls to AddGlobalFlexController
  90. void AppendGlobalFlexControllerOperators( CUtlVector< IDmeOperator * >& list );
  91. studiohdr_t* GetStudioHdr() const;
  92. void FindFlexControllerDependencies( CUtlVector< CUtlVector< int > > &dependencyList ) const;
  93. int FindAttachment( const char *pchAttachmentName ) const;
  94. Vector ComputeAttachmentPosition( const char *pchAttachmentName ) const;
  95. CDmeDag *CreateDagForAttachment( const char *pchAttachmentName ) const;
  96. void SetComputeBounds( bool bEnable ) { m_bComputeBounds = bEnable; }
  97. void SetEvaluateProceduralBones( bool bEnable ) { m_bEvaluateProceduralBones = bEnable; }
  98. bool ShouldComputeBounds() const { return m_bComputeBounds; }
  99. bool ShouldEvaluateProceduralBones() const { return m_bEvaluateProceduralBones; }
  100. public:
  101. protected:
  102. void PopulateExistingDagList( CDmeDag** pDags, int nCount );
  103. void UpdateHMDL();
  104. // This holds the operators which map to the m_flexWeights below
  105. CDmaElementArray< CDmeGlobalFlexControllerOperator > m_globalFlexControllers;
  106. CDmaArray< float > m_flexWeights; // These are global flex weights (so there can be gaps, unused indices)
  107. CDmaString m_modelName;
  108. CDmaVar< int > m_skin;
  109. CDmaVar< int > m_body;
  110. CDmaVar< int > m_sequence;
  111. CDmaVar< int > m_flags;
  112. CDmaVar< bool > m_bComputeBounds;
  113. CDmaVar< bool > m_bEvaluateProceduralBones;
  114. // this is different than m_Children - this is ALL transforms in the tree that are used by the model
  115. // m_Children holds the roots of that tree
  116. CDmaElementArray< CDmeTransform > m_bones;
  117. MDLHandle_t m_hMDL;
  118. bool m_bHMDLDirty;
  119. };
  120. //-----------------------------------------------------------------------------
  121. // A class representing a game sprite
  122. //-----------------------------------------------------------------------------
  123. class CDmeGameSprite : public CDmeDag
  124. {
  125. DEFINE_ELEMENT( CDmeGameSprite, CDmeDag );
  126. public:
  127. const char *GetModelName() const;
  128. float GetScale() const;
  129. float GetFrame() const;
  130. int GetRenderMode() const;
  131. int GetRenderFX() const;
  132. const Color &GetColor() const;
  133. float GetProxyRadius() const;
  134. void SetState( bool bVisible, float nFrame, int nRenderMode, int nRenderFX, float flRenderScale, float flProxyRadius, const Vector &pos, const Quaternion &rot, const Color &color );
  135. protected:
  136. CDmaString m_modelName;
  137. CDmaVar< float > m_frame;
  138. CDmaVar< int > m_rendermode;
  139. CDmaVar< int > m_renderfx;
  140. CDmaVar< float > m_renderscale;
  141. CDmaVar< Color > m_color;
  142. CDmaVar< float > m_proxyRadius;
  143. };
  144. //-----------------------------------------------------------------------------
  145. // A class representing a game portal
  146. //-----------------------------------------------------------------------------
  147. class CDmeGamePortal : public CDmeDag
  148. {
  149. DEFINE_ELEMENT( CDmeGamePortal, CDmeDag );
  150. public:
  151. CDmaVar< int > m_nPortalId;
  152. CDmaVar< int > m_nLinkedPortalId;
  153. CDmaVar< float > m_flStaticAmount;
  154. CDmaVar< float > m_flSecondaryStaticAmount;
  155. CDmaVar< float > m_flOpenAmount;
  156. CDmaVar< float > m_flHalfWidth;
  157. CDmaVar< float > m_flHalfHeight;
  158. CDmaVar< bool > m_bIsPortal2;
  159. CDmaString m_PortalType;
  160. };
  161. #endif // DMEGAMEMODEL_H