BVB Source Codes

CRYENGINE Show AnimEventLoader.cpp Source code

Return Download CRYENGINE: download AnimEventLoader.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "stdafx.h"
  4. #include "AnimEventLoader.h"
  5.  
  6. #include "Model.h"
  7. #include "CharacterManager.h"
  8.  
  9. namespace AnimEventLoader
  10. {
  11. void DoAdditionalAnimEventInitialization(const char* animationFilePath, CAnimEventData& animEvent);
  12. }
  13.  
  14. static bool s_bPreLoadParticleEffects = true;
  15.  
  16. void AnimEventLoader::SetPreLoadParticleEffects(bool bPreLoadParticleEffects)
  17. {
  18.         s_bPreLoadParticleEffects = bPreLoadParticleEffects;
  19. }
  20.  
  21. bool AnimEventLoader::LoadAnimationEventDatabase(CDefaultSkeleton* pDefaultSkeleton, const char* pFileName)
  22. {
  23.         if (pFileName == 0 || pFileName[0] == 0)
  24.                 return false;
  25.  
  26.         CRY_DEFINE_ASSET_SCOPE("AnimEvents", pFileName);
  27.  
  28.         // Parse the xml.
  29.         XmlNodeRef root = g_pISystem->LoadXmlFromFile(pFileName);
  30.         if (!root)
  31.         {
  32.                 //AnimWarning("Animation Event Database (.animevent) file \"%s\" could not be read (associated with model \"%s\")", pFileName, pDefaultSkeleton->GetFile() );
  33.                 return false;
  34.         }
  35.  
  36.         // Load the events from the xml.
  37.         uint32 numAnimations = root->getChildCount();
  38.         for (uint32 nAnimationNode = 0; nAnimationNode < numAnimations; ++nAnimationNode)
  39.         {
  40.                 XmlNodeRef animationRoot = root->getChild(nAnimationNode);
  41.  
  42.                 // Check whether this is an animation.
  43.                 if (stack_string("animation") != animationRoot->getTag())
  44.                         continue;
  45.  
  46.                 const uint32 numEvents = animationRoot->getChildCount();
  47.                 if (numEvents == 0)
  48.                         continue;
  49.  
  50.                 XmlString animationFilePath = animationRoot->getAttr("name");
  51.  
  52.                 IAnimEventList* pAnimEventList = g_AnimationManager.GetAnimEventList(animationFilePath.c_str());
  53.                 if (!pAnimEventList)
  54.                         continue;
  55.  
  56.                 const uint32 currentAnimationEventCount = pAnimEventList->GetCount();
  57.                 if (currentAnimationEventCount != 0)
  58.                         continue;
  59.  
  60.                 for (uint32 nEventNode = 0; nEventNode < numEvents; ++nEventNode)
  61.                 {
  62.                         XmlNodeRef eventNode = animationRoot->getChild(nEventNode);
  63.  
  64.                         CAnimEventData animEvent;
  65.                         const bool couldLoadXmlData = g_AnimationManager.LoadAnimEventFromXml(eventNode, animEvent);
  66.                         if (!couldLoadXmlData)
  67.                                 continue;
  68.  
  69.                         pAnimEventList->Append(animEvent);
  70.  
  71.                         DoAdditionalAnimEventInitialization(animationFilePath, animEvent);
  72.                 }
  73.  
  74.                 g_AnimationManager.InitializeSegmentationDataFromAnimEvents(animationFilePath.c_str());
  75.         }
  76.  
  77.         return true;
  78. }
  79.  
  80. void AnimEventLoader::DoAdditionalAnimEventInitialization(const char* animationFilePath, CAnimEventData& animEvent)
  81. {
  82.         // NB. Currently, this is only executed when the events are created from an xml file, so for example the editor will
  83.         // not be executing logic contained here while editing animation events.
  84.         assert(animationFilePath);
  85.  
  86.         static const uint32 s_crc32_effect = CCrc32::ComputeLowercase("effect");
  87.         const uint32 eventNameCRC32 = animEvent.GetNameLowercaseCRC32();
  88.  
  89.         if (s_bPreLoadParticleEffects)
  90.         {
  91.                 if (eventNameCRC32 == s_crc32_effect)
  92.                 {
  93.                         const char* effectName = animEvent.GetCustomParameter();
  94.                         gEnv->pParticleManager->FindEffect(effectName);
  95.                 }
  96.         }
  97. }
  98.  
downloadAnimEventLoader.cpp 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