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.

184 lines
5.7 KiB

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