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.

122 lines
4.3 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef SFMRIGBUILDCONTEXT_H
  7. #define SFMRIGBUILDCONTEXT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "movieobjects/dmerigconstraintoperators.h"
  12. #include "movieobjects/dmelog.h"
  13. #include "studio.h"
  14. #include "tier1/utldict.h"
  15. class CDmeAnimationSet;
  16. class CDmeFilmClip;
  17. class CDmeClip;
  18. class CDmeRigHandle;
  19. class CDmeChannelsClip;
  20. class CDmeGameModel;
  21. class CRigBuildContext
  22. {
  23. public:
  24. enum
  25. {
  26. DESC_SKELETON = (1<<0),
  27. DESC_RIG = (1<<1),
  28. DESC_CONSTRAINTS = (1<<2),
  29. DESC_ALL = DESC_SKELETON | DESC_RIG | DESC_CONSTRAINTS,
  30. };
  31. enum eRigBuildContextType
  32. {
  33. RBC_ATTACH = 0,
  34. RBC_DETACH,
  35. };
  36. explicit CRigBuildContext( eRigBuildContextType type, CDmeAnimationSet *pAnimSet, CDmeFilmClip *pShot, CDmeClip *pMovie );
  37. ~CRigBuildContext();
  38. bool IsValid();
  39. CDmeRigHandle *FindRigHandle( char const *pchHandleName );
  40. CDmeRigHandle *CreateRigHandle( char const *pchHandleName, char const *pchRigSubGroup, const Vector &p, const Quaternion &q );
  41. CDmeRigBaseConstraintOperator *FindOrAddConstraintTypeForObject( bool *pbUpdatingHandles, EConstraintType eType, char const *pchObjectName, char const *pchConstraintName, const DmFileId_t &fileId );
  42. void CreateWeightChannels( CDmeRigBaseConstraintOperator *pConstraint, int nCount, CDmeDag *const pRigHandles[] );
  43. Vector GetBonePosition( char const *pchBoneName ) const;
  44. CDmeDag *FindBone( const char *pchBoneName ) const;
  45. void SetRigName( char const *pchRigName );
  46. void Describe( int flags );
  47. void DisconnectBoneChannel( CUtlVector< CDmeChannel * > &list, int boneIndex, CDmeDag *pBone, EConstraintType eType );
  48. void AttachHandleToBone( CDmeRigHandle *pRigHandle, CDmeDag *pBone ) const;
  49. // Creates a new set of bone channels for the "detached" bone
  50. void PerformDetach();
  51. void FinishAttach();
  52. protected:
  53. CDmeRigBaseConstraintOperator *InstanceConstraint( EConstraintType eType, char const *pchName, const DmFileId_t &fileId );
  54. void CreateRigHandleChannels( CDmeChannel *list[ 2 ], CDmeChannelsClip *pChannelsClip, CDmeRigHandle *pHandle );
  55. CDmElement *CreateRigAnimationSetControl( CDmeAnimationSet *pAnimSet, CDmeDag *pDag, CDmeChannel *pDagChannel, int controlType );
  56. void AddControlToAnimationSetRig( CDmeAnimationSet *pAnimSet, char const *pchGroupName, char const *pchControlGroupName, char const *pchControlName );
  57. CDmeChannelsClip* CreateChannelsClip();
  58. void CreateTransformChannels( CDmeDag *pDag, const char* baseName, CDmeChannelsClip *pChannelsClip );
  59. void DescribeSkeleton();
  60. void DescribeRig();
  61. void DescribeConstraints();
  62. void DescribeSkeleton_R( int depth, CDmeDag *bone );
  63. void DescribeOperatorsForDag( int depth, CDmeDag *pDag );
  64. CDmeChannel *DisconnectBoneChannel( CDmeDag *pBone, char const *pchTargetAttribute );
  65. void DetachAddBoneChannelsToChannelsClip( CUtlVector< CDmeChannel * > &boneChannels );
  66. void DetachCreateBoneChannels( CStudioHdr &hdr, CUtlVector< CDmeChannel * > &boneChannels );
  67. void DetachGatherAllOperators( CUtlRBTree< CDmeOperator * > &operators );
  68. void AttachInit();
  69. void DetachInit();
  70. CDmeDag *FindSceneRoot();
  71. void InsertSubHandles_R( CDmeRigHandle *pRoot );
  72. void FindChannelsForDag( CDmeDag* pDagNode, CUtlRBTree< CDmeOperator * > &operators );
  73. void FindBoneChannels_R( CDmeDag *bone, CUtlRBTree< CDmeOperator * > &operators );
  74. void FindBoneChannels( CUtlRBTree< CDmeOperator * > &operators );
  75. void FindRigHandleChannels( CUtlRBTree< CDmeOperator * > &operators );
  76. public:
  77. bool m_bValid;
  78. int m_nRigNumber;
  79. DmeLog_TimeSelection_t m_timeSelection;
  80. CDmeHandle< CDmeAnimationSet > m_hAnimationSet;
  81. CDmeHandle< CDmeFilmClip > m_hShot;
  82. CDmeHandle< CDmeClip > m_hMovie;
  83. CDmeHandle< CDmeGameModel > m_hGameModel;
  84. CDmeHandle< CDmeDag > m_hRigSceneRoot;
  85. CDmeHandle< CDmeChannelsClip > m_hDstChannelsClip;
  86. const CStudioHdr *m_pStudioHdr;
  87. matrix3x4_t m_ReferencePoseBoneToWorld[ MAXSTUDIOBONES ];
  88. CUtlVector< CDmeChannel * > m_DetachChannels;
  89. CUtlDict< CDmeHandle< CDmeRigHandle >, short > m_RigHandles;
  90. CUtlVector< CDmeHandle< CDmeRigBaseConstraintOperator > > m_Constraints;
  91. };
  92. #endif // SFMRIGBUILDCONTEXT_H