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.

149 lines
5.3 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // A class used to build flex animation controls for an animation set
  4. //
  5. //=============================================================================
  6. #ifndef FLEXCONTROLBUILDER_H
  7. #define FLEXCONTROLBUILDER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlvector.h"
  12. #include "movieobjects/dmelog.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class CDmeAnimationSet;
  17. class CDmeGameModel;
  18. class CDmeFilmClip;
  19. class CDmeChannelsClip;
  20. class CDmElement;
  21. class CDmeChannel;
  22. class CDmeGlobalFlexControllerOperator;
  23. //-----------------------------------------------------------------------------
  24. //
  25. // Utility class for dealing with the complex task of building flex controls
  26. //
  27. //-----------------------------------------------------------------------------
  28. class CFlexControlBuilder
  29. {
  30. public:
  31. // Main entry point for creating flex animation set controls
  32. void CreateAnimationSetControls( CDmeFilmClip *pMovie, CDmeAnimationSet *pAnimationSet,
  33. CDmeGameModel *pGameModel, CDmeFilmClip *pSourceClip, CDmeChannelsClip *pDestClip, bool bUseExistingLogs );
  34. private:
  35. enum ControlField_t
  36. {
  37. CONTROL_MONO = 0,
  38. CONTROL_RIGHT,
  39. CONTROL_LEFT,
  40. CONTROL_FIELD_COUNT,
  41. };
  42. struct FlexControllerInfo_t
  43. {
  44. char m_pFlexControlName[256];
  45. float m_flDefaultValue;
  46. int m_nGlobalIndex;
  47. };
  48. struct ExistingLogInfo_t
  49. {
  50. CDmeFloatLog *m_pLog;
  51. DmeTime_t m_GlobalOffset;
  52. double m_flGlobalScale;
  53. };
  54. struct ControlInfo_t
  55. {
  56. char m_pControlName[256];
  57. bool m_bIsStereo : 1;
  58. CDmElement *m_pControl;
  59. float m_flDefaultValue;
  60. int m_pControllerIndex[CONTROL_FIELD_COUNT];
  61. CDmeChannel *m_ppControlChannel[CONTROL_FIELD_COUNT];
  62. ExistingLogInfo_t m_pExistingLog[CONTROL_FIELD_COUNT];
  63. };
  64. // Removes a channel from the channels clip referring to it.
  65. void RemoveChannelFromClips( CDmeChannel *pChannel );
  66. // Builds the list of flex controls (outputs) in the current game model
  67. void BuildDesiredFlexControlList( CDmeGameModel *pGameModel );
  68. // This builds a list of the desired input controls we need to have controls for
  69. // by the time we're all done with this enormous process.
  70. void BuildDesiredControlList( CDmeGameModel *pGameModel );
  71. // finds controls whose channels don't point to anything anymore, and deletes both the channels and the control
  72. void RemoveUnusedControlsAndChannels( CDmeAnimationSet *pAnimationSet, CDmeChannelsClip *pChannelsClip );
  73. // I'll bet you can guess what this does
  74. void RemoveUnusedExistingFlexControllers( CDmeGameModel *pGameModel );
  75. // Fixup list of existing flex controller logs
  76. // - reattach flex controls that were removed from the gamemodel's list
  77. void FixupExistingFlexControlLogList( CDmeFilmClip *pCurrentClip, CDmeGameModel *pGameModel );
  78. // Build list of existing flex controller logs
  79. void BuildExistingFlexControlLogList( CDmeFilmClip *pCurrentClip, CDmeGameModel *pGameModel );
  80. // Finds a desired flex controller index in the m_FlexControllerInfo array
  81. int FindDesiredFlexController( const char *pFlexControllerName ) const;
  82. // Blows away the various elements trying to control a flex controller op
  83. void CleanupExistingFlexController( CDmeGameModel *pGameModel, CDmeGlobalFlexControllerOperator *pOp );
  84. // Finds a channels clip containing a particular channel
  85. CDmeChannelsClip* FindChannelsClipContainingChannel( CDmeFilmClip *pClip, CDmeChannel *pSearch );
  86. // Returns an existing mono log
  87. void GetExistingMonoLog( ExistingLogInfo_t *pLog, CDmeFilmClip *pClip, CDmeGlobalFlexControllerOperator *pMonoOp );
  88. // Computes a global offset and scale to convert from log time to global time
  89. void ComputeChannelTimeTransform( DmeTime_t *pOffset, double *pScale, CDmeChannelsClip *pChannelsClip );
  90. bool ComputeChannelTimeTransform( DmeTime_t *pOffset, double *pScale, CDmeFilmClip* pClip, CDmeChannel* pChannel );
  91. // Initializes the fields of a flex control
  92. void InitializeFlexControl( ControlInfo_t &info );
  93. // Creates all controls for flexes
  94. void CreateFlexControls( CDmeAnimationSet *pAnimationSet );
  95. // Build the infrastructure of the ops that connect that control to the dmegamemodel
  96. void AttachControlsToGameModel( CDmeAnimationSet *pAnimationSet, CDmeGameModel *pGameModel, CDmeChannelsClip *pChannelsClip );
  97. // Connects a mono control to a single flex controller op
  98. void BuildFlexControllerOps( CDmeGameModel *pGameModel, CDmeChannelsClip *pChannelsClip, ControlInfo_t &info, ControlField_t field );
  99. // Attaches existing logs and sets default values for logs
  100. void SetupLogs( CDmeChannelsClip *pChannelsClip, bool bUseExistingLogs );
  101. // Destination flex controllers
  102. CUtlVector< FlexControllerInfo_t > m_FlexControllerInfo;
  103. // Destination controls
  104. CUtlVector< ControlInfo_t > m_ControlInfo;
  105. CDmeFilmClip *m_pMovie;
  106. };
  107. //-----------------------------------------------------------------------------
  108. // Initialize default global flex controller
  109. //-----------------------------------------------------------------------------
  110. void SetupDefaultFlexController();
  111. #endif // FLEXCONTROLBUILDER_H