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.

82 lines
2.8 KiB

  1. //===== Copyright (c) 1996-2009, Valve Corporation, All rights reserved. =====
  2. //
  3. // Purpose:
  4. //
  5. //============================================================================
  6. #ifndef MDLOBJECTS_UTILS_H
  7. #define MDLOBJECTS_UTILS_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. // Valve includes
  12. #include "movieobjects/dmechannel.h"
  13. #include "movieobjects/dmemodel.h"
  14. #include "mdlobjects/dmeasset.h"
  15. #include "mdlobjects/dmesequence.h"
  16. #include "tier1/utlvector.h"
  17. #include "tier1/utlstring.h"
  18. //-----------------------------------------------------------------------------
  19. // Ok to pass NULL
  20. //-----------------------------------------------------------------------------
  21. void ReorientMppFile( CDmElement *pDmElementRoot, bool bMakeZUp );
  22. void MppReorient( CDmElement *pDmElementRoot, bool bMakeZUp );
  23. void GetAbsMotion( CDmeChannel **ppDmePChannel, CDmeChannel **ppDmeOChannel, CDmeDag *pDmeDag );
  24. bool SetAbsMotion( CDmeDag *pDmeDag, CDmeChannel *pDmePositionChannel, CDmeChannel *pDmeOrientationChannel );
  25. // Creates a guaranteed unique DmFileId_t
  26. DmFileId_t CreateUniqueDmFileId();
  27. //-----------------------------------------------------------------------------
  28. // Iterates over all CDmeSequence's in the MPP File (Not CDmeMultiSequence)
  29. // Get() only returns NULL if IsDone() also returns true so this usage is safe
  30. //
  31. // for ( MppSequenceIt sIt( pDmeAssetRoot ); !sIt.IsDone(); sIt.Next() )
  32. // {
  33. // sIt.Get()->SomeFunctionOnCDmeSequence()
  34. // }
  35. //-----------------------------------------------------------------------------
  36. class MppSequenceIt
  37. {
  38. public:
  39. MppSequenceIt( CDmeAssetRoot *pDmeAssetRoot );
  40. CDmeSequence *Get() const;
  41. bool IsDone() const;
  42. void Next();
  43. void Reset();
  44. protected:
  45. CUtlVector< DmElementHandle_t > m_hDmeSequenceList;
  46. int m_nSequenceIndex;
  47. };
  48. // Masks for MppGetSkeletonLIst
  49. enum MppSkeletonMask_t
  50. {
  51. MPP_ANIM_SKELETON_MASK = 1 << 0,
  52. MPP_PHYSICS_SKELETON_MASK = 1 << 1,
  53. MPP_MODEL_SKELETON_MASK = 1 << 2,
  54. MPP_ALL_SKELETON_MASK = MPP_ANIM_SKELETON_MASK | MPP_PHYSICS_SKELETON_MASK | MPP_MODEL_SKELETON_MASK
  55. };
  56. // Returns a list of all unique skeletons under the specified MPP DmeAssetRoot
  57. void MppGetSkeletonList( CUtlVector< CDmeModel * > &skeletonList, CDmeAssetRoot *pDmeAssetRoot, int nMppSkeletonMask = MPP_ALL_SKELETON_MASK );
  58. // Connects all of the non-animation skeletons to each animation skeleton via DmeConnectionOperators
  59. DmFileId_t MppConnectSkeletonsForAnimation( CDmeAssetRoot *pDmeAssetRoot );
  60. // Disconnects all of the non-animation skeletons from each animation skeleton
  61. // and destroys the elements created by MppConnectSkeletonsForAnimation
  62. void MppDisconnectSkeletonsFromAnimation( CDmeAssetRoot *pDmeAssetRoot );
  63. // Utility to return DmElement id as name:string
  64. CUtlString ComputeDmElementIdStr( const CDmElement *pDmElement );
  65. #endif // MDLOBJECTS_UTILS_H