BVB Source Codes

CRYENGINE Show ParticleSubEmitter.h Source code

Return Download CRYENGINE: download ParticleSubEmitter.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   ParticleSubEmitter.h
  5. //  Version:     v1.00
  6. //  Created:     20/04/2010 by Corey.
  7. //  Description: Split out from ParticleEmitter.h
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12.  
  13. #ifndef __particlesubemitter_h__
  14. #define __particlesubemitter_h__
  15. #pragma once
  16.  
  17. #include "ParticleEffect.h"
  18. #include "ParticleContainer.h"
  19. #include "ParticleEnviron.h"
  20. #include "ParticleUtils.h"
  21. #include <CryCore/BitFiddling.h>
  22.  
  23. class CParticleEmitter;
  24. struct SParticleUpdateContext;
  25. struct IAudioProxy;
  26.  
  27. //////////////////////////////////////////////////////////////////////////
  28. class CRY_ALIGN(16) CParticleSubEmitter: public Cry3DEngineBase, public _plain_reference_target<int>
  29.         // Maintains an emitter source state, emits particles to a container
  30.         // Ref count increased only by emitted particles
  31. {
  32. public:
  33.  
  34.         CParticleSubEmitter(CParticleSource * pSource, CParticleContainer * pCont);
  35.         ~CParticleSubEmitter();
  36.  
  37.         ResourceParticleParams const& GetParams() const
  38.         { return m_pContainer->GetParams(); }
  39.         CParticleContainer&           GetContainer() const
  40.         { return *m_pContainer; }
  41.         CParticleSource&              GetSource() const
  42.         { assert(m_pSource && m_pSource->NumRefs()); return *m_pSource; }
  43.         CParticleEmitter&             GetMain() const
  44.         { return GetContainer().GetMain(); }
  45.  
  46.         // State.
  47.         bool IsActive() const
  48.         { return GetAge() >= m_fActivateAge; }
  49.         void Deactivate();
  50.  
  51.         // Timing.
  52.         float GetAge() const
  53.         { return GetSource().GetAge(); }
  54.         float GetStartAge() const
  55.         { return m_fStartAge; }
  56.         float GetRepeatAge() const
  57.         { return m_fRepeatAge; }
  58.         float GetStopAge() const
  59.         { return m_fStopAge; }
  60.         float GetParticleStopAge() const
  61.         { return GetStopAge() + GetParams().GetMaxParticleLife(); }
  62.         float GetRelativeAge(float fAgeAdjust = 0.f) const
  63.         { return GetAgeRelativeTo(m_fStopAge, fAgeAdjust); }
  64.  
  65.         float GetStopAge(ParticleParams::ESoundControlTime eControl) const;
  66.         float GetRelativeAge(ParticleParams::ESoundControlTime eControl, float fAgeAdjust = 0.f) const
  67.         { return GetAgeRelativeTo(min(GetStopAge(eControl), m_fRepeatAge), fAgeAdjust); }
  68.  
  69.         float GetStrength(float fAgeAdjust = 0.f, ParticleParams::ESoundControlTime eControl = ParticleParams::ESoundControlTime::EmitterLifeTime) const;
  70.  
  71.         Vec3 GetEmitFocusDir(const QuatTS &loc, float fStrength, Quat * pRot = 0) const;
  72.  
  73.         // Actions.
  74.         void UpdateState(float fAgeAdjust = 0.f);
  75.         void UpdateAudio();
  76.         void ResetLoc()
  77.         { m_LastLoc.s = -1.f; }
  78.         void SetLastLoc()
  79.         { m_LastLoc = GetSource().GetLocation(); }
  80.         float GetParticleScale() const;
  81.         bool GetMoveRelative(Vec3 & vPreTrans, QuatTS & qtMove) const;
  82.         void UpdateForce();
  83.  
  84.         bool HasForce() const
  85.         { return (m_pForce != 0); }
  86.  
  87.         int EmitParticle(SParticleUpdateContext & context, const EmitParticleData &data, float fAge = 0.f, QuatTS * plocPreTransform = NULL);
  88.         void EmitParticles(SParticleUpdateContext & context);
  89.  
  90.         uint32    GetEmitIndex() const
  91.         { return m_nEmitIndex; }
  92.         uint16    GetSequence() const
  93.         { return m_nSequenceIndex; }
  94.         CChaosKey GetChaosKey() const
  95.         { return m_ChaosKey; }
  96.  
  97.         void OffsetPosition(const Vec3& delta)
  98.         {
  99.                 m_LastLoc.t += delta;
  100.         }
  101.  
  102.         void GetMemoryUsage(ICrySizer* pSizer) const
  103.         {
  104.         }
  105.  
  106. private:
  107.         // Associated structures.
  108.         CParticleContainer* m_pContainer;         // Direct or shared container to emit particles into.
  109.         _smart_ptr<CParticleSource> m_pSource;
  110.  
  111.         AudioControlId m_startAudioTriggerId;
  112.         AudioControlId m_stopAudioTriggerId;
  113.         AudioControlId m_audioRtpcId;
  114.         IAudioProxy* m_pIAudioProxy;
  115.         EAudioOcclusionType m_currentAudioOcclusionType;
  116.         bool m_bExecuteAudioTrigger;
  117.  
  118.         // State.
  119.         float m_fStartAge;              // Relative age when scheduled to start (default 0).
  120.         float m_fStopAge;               // Relative age when scheduled to end (fHUGE if never).
  121.         float m_fRepeatAge;             // Relative age when scheduled to repeat (fHUGE if never).
  122.         float m_fLastEmitAge;           // Age of emission of last particle.
  123.         float m_fActivateAge;           // Cached age for last activation mode.
  124.  
  125.         CChaosKey m_ChaosKey;           // Seed for randomising; inited every pulse.
  126.         QuatTS m_LastLoc;               // Location at time of last update.
  127.  
  128.         uint32 m_nEmitIndex;
  129.         uint16 m_nSequenceIndex;
  130.  
  131.         // External objects.
  132.         IPhysicalEntity* m_pForce;
  133.  
  134.         // Methods.
  135.         void Initialize(float fAge);
  136.         float GetAgeRelativeTo(float fStopAge, float fAgeAdjust = 0.f) const;
  137.         void DeactivateAudio();
  138.         float ComputeDensityIncrease(float fStrength, float fParticleLife, const QuatTS &locA, const QuatTS * plocB) const;
  139.         Matrix34 GetEmitTM() const;
  140.  
  141. };
  142.  
  143. #endif // __particlesubemitter_h__
  144.  
downloadParticleSubEmitter.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