BVB Source Codes

CRYENGINE Show AnimationManager.h Source code

Return Download CRYENGINE: download AnimationManager.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #pragma once
  4. #ifndef RESOURCE_COMPILER
  5. #include "GlobalAnimationHeaderLMG.h"
  6. #include "GlobalAnimationHeaderCAF.h"
  7. #include "GlobalAnimationHeaderAIM.h"
  8. #include "LoaderDBA.h"
  9.  
  10. class CAnimationSet;
  11. class CryCGALoader;
  12. class CAnimationManager;
  13. class CAnimationSet;
  14. struct CInternalSkinningInfo;
  15.  
  16. struct AnimSearchHelper
  17. {
  18.  
  19.         typedef std::vector<int>                                                     TIndexVector;
  20.         typedef std::map<uint32 /*crc*/, TIndexVector* /*vector of indexes*/>        TFoldersVector;
  21.  
  22.         typedef std::vector<uint32>                                                  TSubFolderCrCVector;
  23.         typedef std::map<uint32 /*crc*/, TSubFolderCrCVector* /*vector of indexes*/> TSubFoldersMap;
  24.  
  25.         TFoldersVector       m_AnimationsMap;
  26.         TSubFoldersMap       m_SubFoldersMap;
  27.  
  28.         bool                 AddAnimation(uint32 crc, uint32 gahIndex);
  29.         void                 AddAnimation(const string& path, uint32 gahIndex);
  30.  
  31.         TSubFolderCrCVector* GetSubFoldersVector(uint32 crc);
  32.  
  33.         TIndexVector*        GetAnimationsVector(uint32 crc);
  34.         TIndexVector*        GetAnimationsVector(const string& path);
  35.         void                 Clear();
  36.  
  37.         AnimSearchHelper() {}
  38.         ~AnimSearchHelper() { Clear(); };
  39.  
  40. private:
  41.         // Ensure non copyable
  42.         AnimSearchHelper(const AnimSearchHelper&);
  43.         AnimSearchHelper& operator=(const AnimSearchHelper&);
  44. };
  45.  
  46. /////////////////////////////////////////////////////////////////////////////////////////////////////
  47. // class CAnimationManager
  48. // Responsible for creation of multiple animations, subsequently bind to the character bones
  49. // There is one instance of this class per a game.
  50. /////////////////////////////////////////////////////////////////////////////////////////////////////
  51. class CAnimationManager : public IAnimEvents
  52. {
  53. public:
  54.  
  55.         virtual IAnimEventList*       GetAnimEventList(const char* animationFilePath);
  56.         virtual const IAnimEventList* GetAnimEventList(const char* animationFilePath) const;
  57.  
  58.         virtual bool                  SaveAnimEventToXml(const CAnimEventData& dataIn, XmlNodeRef& dataOut);
  59.         virtual bool                  LoadAnimEventFromXml(const XmlNodeRef& dataIn, CAnimEventData& dataOut);
  60.         virtual void                  InitializeSegmentationDataFromAnimEvents(const char* animationFilePath);
  61.  
  62.         void                          InitialiseRunTimePools();
  63.         void                          DestroyRunTimePools();
  64.  
  65.         /////////////////////////////////////////////////////////////////////
  66.         // finds the animation-asset by path-name.
  67.         // Returns -1 if no animation was found.
  68.         // Returns the animation ID if it was found.
  69.         /////////////////////////////////////////////////////////////////////
  70.  
  71.         //! Searches for a CAF animation asset by its name.
  72.         //! \param szFilePath Name of the animation to search for.
  73.         //! \return Global ID of the animation or -1 if no animation was found.
  74.         int GetGlobalIDbyFilePath_CAF(const char* szFilePath) const;
  75.  
  76.         //! Searches for an AIM animation asset by its name.
  77.         //! \param szFilePath Name of the animation to search for.
  78.         //! \return Global ID of the animation or -1 if no animation was found.
  79.         int GetGlobalIDbyFilePath_AIM(const char* szFilePath) const;
  80.  
  81.         //! Searches for a blend-space (locomotion group) asset by its name.
  82.         //! \param szFilePath Name of the blend-space to search for.
  83.         //! \return Global ID of the blend-space or -1 if no blend-space was found.
  84.         int GetGlobalIDbyFilePath_LMG(const char* szFilePath) const;
  85.  
  86.         //! Searches for a blend-space (locomotion group) asset by a crc32 hash of its name.
  87.         //! \param szFilePath Lowercase crc32 hash of the blend-space name to search for.
  88.         //! \return Global ID of the blend-space or -1 if no blend-space was found.
  89.         int GetGlobalIDbyFilePathCRC_LMG(uint32 crc32) const;
  90.  
  91.         // create header with the specified name. If the header already exists, it return the index
  92.         int               CreateGAH_CAF(const string& strFileName);
  93.         int               CreateGAH_AIM(const string& strFileName);
  94.         int               CreateGAH_LMG(const string& strFileName);
  95.  
  96.         CGlobalHeaderDBA* FindGlobalHeaderByCRC_DBA(uint32 crc);
  97.  
  98.         // loads existing animation record, returns false on error
  99.         bool LoadAnimationTCB(int nGlobalAnimId, DynArray<CControllerTCB>& m_LoadCurrAnimation, CryCGALoader* pCGA, const IDefaultSkeleton* pIDefaultSkeleton);
  100.  
  101.         void UnloadAnimationCAF(GlobalAnimationHeaderCAF& rCAF);
  102.         void UnloadAnimationAIM(int nGLobalAnimID);
  103.  
  104.         // returns the total number of animations hold in memory (for statistics)
  105.         size_t GetGlobalAnimCount() { return m_arrGlobalCAF.size();  }
  106.  
  107.         // notifies the controller manager that this client doesn't use the given animation any more.
  108.         // these calls must be balanced with AnimationAddRef() calls
  109.         void AnimationReleaseCAF(GlobalAnimationHeaderCAF& rCAF);
  110.         void AnimationReleaseAIM(GlobalAnimationHeaderAIM& rAIM);
  111.         void AnimationReleaseLMG(GlobalAnimationHeaderLMG& rLMG);
  112.  
  113.         // puts the size of the whole subsystem into this sizer object, classified, according to the flags set in the sizer
  114.         void GetMemoryUsage(class ICrySizer* pSizer) const;
  115.         void             DebugAnimUsage(uint32 printtxt);
  116.  
  117.         size_t           GetSizeOfDBA();
  118.         bool             CreateGlobalHeaderDBA(DynArray<string>& name);
  119.         bool             DBA_PreLoad(const char* pFilePathDBA, bool highPriority);
  120.         bool             DBA_LockStatus(const char* pFilePathDBA, uint32 status, bool highPriority);
  121.         bool             DBA_Unload(const char* pFilePathDBA);
  122.         bool             DBA_Unload_All();
  123.         bool             Unload_All_Animation();
  124.  
  125.         EReloadCAFResult ReloadCAF(const char* szFilePathCAF);
  126.         int              ReloadLMG(const char* szFilePathLMG);
  127.  
  128.         uint32           GetDBACRC32fromFilePath(const char* szFilePathCAF);
  129.         bool             IsDatabaseInMemory(uint32 nDBACRC32);
  130.  
  131.         DynArray<CGlobalHeaderDBA>         m_arrGlobalHeaderDBA;
  132.         CNameCRCMap                        m_AnimationMapCAF;
  133.         DynArray<GlobalAnimationHeaderCAF> m_arrGlobalCAF;
  134.         //      CNameCRCMap             m_AnimationMapAIM;
  135.         DynArray<GlobalAnimationHeaderAIM> m_arrGlobalAIM;
  136.         //      CNameCRCMap             m_AnimationMapLMG;
  137.         DynArray<GlobalAnimationHeaderLMG> m_arrGlobalLMG;
  138.  
  139. #ifdef EDITOR_PCDEBUGCODE
  140.         typedef std::map<string, DynArray<char>> CachedBSPACES;
  141.         CachedBSPACES m_cachedBSPACES;
  142. #endif
  143.  
  144.         AnimSearchHelper   m_animSearchHelper;
  145.         SAnimMemoryTracker m_AnimMemoryTracker;
  146.  
  147.         bool               m_shuttingDown;
  148.  
  149.         CAnimationManager(const CAnimationManager&);
  150.         void operator=(const CAnimationManager&);
  151.  
  152.         CAnimationManager() : m_shuttingDown(false)
  153.         {
  154.                 //We reserve the place for future animations.
  155.                 //The best performance will be archived when this number is >= actual number of animations that can be used, and not much greater
  156.                 m_arrGlobalHeaderDBA.reserve(128);
  157.                 m_arrGlobalCAF.reserve(0);
  158.                 m_arrGlobalAIM.reserve(0);
  159.                 m_arrGlobalLMG.reserve(128);
  160.  
  161. #if BLENDSPACE_VISUALIZATION
  162.                 //the first LMG must be an Internal Type (it is a pre-initalized 1D blend-space). We use it just for debugging on PC
  163.                 int nGlobalAnimID = CreateGAH_LMG("InternalPara1D.LMG");
  164.                 m_arrGlobalLMG[nGlobalAnimID].CreateInternalType_Para1D();
  165. #endif
  166.  
  167.                 InitialiseRunTimePools();
  168.         }
  169.  
  170.         ~CAnimationManager()
  171.         {
  172.                 m_shuttingDown = true;
  173.                 DestroyRunTimePools();
  174.         }
  175.  
  176. private:
  177. };
  178. #endif
downloadAnimationManager.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top