BVB Source Codes

CRYENGINE Show MFXRandomEffect.cpp Source code

Return Download CRYENGINE: download MFXRandomEffect.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 "MFXRandomEffect.h"
  5.  
  6. void CMFXRandomizerContainer::ExecuteRandomizedEffects(const SMFXRunTimeEffectParams& params)
  7. {
  8.         TMFXEffectBasePtr pEffect = ChooseCandidate(params);
  9.         if (pEffect)
  10.         {
  11.                 pEffect->Execute(params);
  12.         }
  13. }
  14.  
  15. TMFXEffectBasePtr CMFXRandomizerContainer::ChooseCandidate(const SMFXRunTimeEffectParams& params) const
  16. {
  17.         const size_t nEffects = m_effects.size();
  18.         if (nEffects == 0)
  19.                 return TMFXEffectBasePtr(NULL);
  20.  
  21.         CryFixedArray<TMFXEffectBasePtr, 16> candidatesArray;
  22.  
  23.         TMFXEffects::const_iterator it = m_effects.begin();
  24.         TMFXEffects::const_iterator itEnd = m_effects.end();
  25.         while ((it != itEnd) && !candidatesArray.isfull())
  26.         {
  27.                 const TMFXEffectBasePtr& pEffect = *it;
  28.                 if (pEffect->CanExecute(params))
  29.                 {
  30.                         candidatesArray.push_back(pEffect);
  31.                 }
  32.                 ++it;
  33.         }
  34.  
  35.         TMFXEffectBasePtr pChosenEffect = NULL;
  36.         if (!candidatesArray.empty())
  37.         {
  38.                 const uint32 randChoice = cry_random(0U, candidatesArray.size() - 1);
  39.                 pChosenEffect = candidatesArray[randChoice];
  40.         }
  41.  
  42.         return pChosenEffect;
  43. }
  44.  
  45. //////////////////////////////////////////////////////////////////////////
  46. //////////////////////////////////////////////////////////////////////////
  47.  
  48. CMFXRandomEffect::CMFXRandomEffect()
  49.         : CMFXEffectBase(eMFXPF_All)
  50. {
  51. }
  52.  
  53. CMFXRandomEffect::~CMFXRandomEffect()
  54. {
  55. }
  56.  
  57. void CMFXRandomEffect::GetMemoryUsage(ICrySizer* pSizer) const
  58. {
  59.         pSizer->AddObject(this, sizeof(*this));
  60. }
  61.  
  62. void CMFXRandomEffect::Execute(const SMFXRunTimeEffectParams& params)
  63. {
  64.         FUNCTION_PROFILER(gEnv->pSystem, PROFILE_ACTION);
  65.  
  66.         m_container.ExecuteRandomizedEffects(params);
  67. }
  68.  
  69. void CMFXRandomEffect::LoadParamsFromXml(const XmlNodeRef& paramsNode)
  70. {
  71.         // Xml data format
  72.         /*
  73.            <RandEffect>
  74.            <Particle />
  75.            <Audio />
  76.            <ForceFeedback />
  77.            ...
  78.            </Particle>
  79.          */
  80.  
  81.         m_container.BuildFromXML(paramsNode);
  82. }
  83.  
  84. void CMFXRandomEffect::GetResources(SMFXResourceList& resourceList) const
  85. {
  86.         m_container.GetResources(resourceList);
  87. }
  88.  
  89. void CMFXRandomEffect::PreLoadAssets()
  90. {
  91.         m_container.PreLoadAssets();
  92. }
  93.  
  94. void CMFXRandomEffect::ReleasePreLoadAssets()
  95. {
  96.         m_container.ReleasePreLoadAssets();
  97. }
  98.  
  99. void CMFXRandomEffect::SetCustomParameter(const char* customParameter, const SMFXCustomParamValue& customParameterValue)
  100. {
  101.         m_container.SetCustomParameter(customParameter, customParameterValue);
  102. }
  103.  
downloadMFXRandomEffect.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