BVB Source Codes

CRYENGINE Show ParticleFeature.h Source code

Return Download CRYENGINE: download ParticleFeature.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  Created:     24/09/2014 by Filipe amim
  5. //  Description:
  6. // -------------------------------------------------------------------------
  7. //
  8. ////////////////////////////////////////////////////////////////////////////
  9.  
  10. #ifndef PARTICLEFEATURE_H
  11. #define PARTICLEFEATURE_H
  12.  
  13. #pragma once
  14.  
  15. #include <CrySerialization/IArchive.h>
  16. #include <CrySerialization/Color.h>
  17. #include <CrySerialization/ClassFactory.h>
  18.  
  19. #include "ParticleSystem.h"
  20. #include "ParticleEffect.h"
  21. #include "ParticleComponent.h"
  22. #include "ParticleComponentRuntime.h"
  23.  
  24. #include <CryRenderer/IGpuParticles.h>
  25.  
  26. namespace pfx2
  27. {
  28.  
  29. struct SGpuInterfaceRef
  30. {
  31.         SGpuInterfaceRef(gpu_pfx2::EGpuFeatureType feature) : feature(feature) {}
  32.         gpu_pfx2::EGpuFeatureType                          feature;
  33.         _smart_ptr<gpu_pfx2::IParticleFeatureGpuInterface> gpuInterface;
  34. };
  35.  
  36. class CParticleFeature : public IParticleFeature, public _i_reference_target_t
  37. {
  38. public:
  39.         CParticleFeature() : m_gpuInterfaceRef(gpu_pfx2::eGpuFeatureType_None) {}
  40.         CParticleFeature(gpu_pfx2::EGpuFeatureType feature) : m_gpuInterfaceRef(feature) {}
  41.  
  42.         // IParticleFeature
  43.         void                                    SetEnabled(bool enabled) override                 { m_enabled.Set(enabled); }
  44.         bool                                    IsEnabled() const override                        { return m_enabled; }
  45.         void                                    Serialize(Serialization::IArchive& ar) override;
  46.         uint                                    GetNumConnectors() const override                 { return 0; }
  47.         const char*                             GetConnectorName(uint connectorId) const override { return nullptr; }
  48.         void                                    ConnectTo(const char* pOtherName) override        {}
  49.         void                                    DisconnectFrom(const char* pOtherName) override   {}
  50.         void                                    SetGpuInterfaceNeeded(bool gpuInterface)          { m_gpuInterfaceNeeded = gpuInterface; }
  51.         gpu_pfx2::IParticleFeatureGpuInterface* GetGpuInterface() override;
  52.         // ~IParticleFeature
  53.  
  54.         // Initialization
  55.         virtual void              ResolveDependency(CParticleComponent* pComponent)                         {}
  56.         virtual void              AddToComponent(CParticleComponent* pComponent, SComponentParams* pParams) {}
  57.         virtual EFeatureType      GetFeatureType()                                                          { return EFT_Generic; }
  58.         virtual bool              CanMakeRuntime(CParticleEmitter* pEmitter) const                          { return true; }
  59.  
  60.         // EUL_MainPreUpdate
  61.         virtual void MainPreUpdate(CParticleComponentRuntime* pComponentRuntime) {}
  62.  
  63.         // EUL_InitSubInstance
  64.         virtual void InitSubInstance(CParticleComponentRuntime* pComponentRuntime, size_t firstInstance, size_t lastInstance) {}
  65.  
  66.         // EUL_Spawn
  67.         virtual void SpawnParticles(const SUpdateContext& context) {}
  68.  
  69.         // EUL_InitUpdate
  70.         virtual void InitParticles(const SUpdateContext& context) {}
  71.  
  72.         // EUL_PostInitUpdate
  73.         virtual void PostInitParticles(const SUpdateContext& context) {}
  74.  
  75.         // EUL_KillUpdate
  76.         virtual void KillParticles(const SUpdateContext& context, TParticleId* pParticles, size_t count) {}
  77.  
  78.         // EUL_PreUpdate
  79.         virtual void PreUpdate(const SUpdateContext& context) {}
  80.  
  81.         // EUL_Update
  82.         virtual void Update(const SUpdateContext& context) {}
  83.  
  84.         // EUL_Render
  85.         virtual void PrepareRenderObjects(CParticleEmitter* pEmitter, CParticleComponent* pComponent)                                                                            {}
  86.         virtual void ResetRenderObjects(CParticleEmitter* pEmitter, CParticleComponent* pComponent)                                                                              {}
  87.         virtual void Render(CParticleEmitter* pEmitter, ICommonParticleComponentRuntime* pComponentRuntime, CParticleComponent* pComponent, const SRenderContext& renderContext) {}
  88.         virtual void ComputeVertices(CParticleComponentRuntime* pComponentRuntime, const SCameraInfo& camInfo, CREParticle* pRE, uint64 uRenderFlags, float fMaxPixels)          {}
  89.  
  90.         // EUL_GetExtents
  91.         virtual void GetSpatialExtents(const SUpdateContext& context, Array<const float, uint> scales, Array<float, uint> extents) {}
  92.  
  93. protected:
  94.         void AddNoPropertiesLabel(Serialization::IArchive& ar);
  95.  
  96. private:
  97.         SGpuInterfaceRef m_gpuInterfaceRef;
  98.         SEnable          m_enabled;
  99.         bool             m_gpuInterfaceNeeded;
  100. };
  101.  
  102. ILINE ColorB HexToColor(uint hex)
  103. {
  104.         return ColorB((hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff);
  105. }
  106.  
  107. static const ColorB colorAppearance = HexToColor(0x00ffba);
  108. static const ColorB colorField      = HexToColor(0x02ba25);
  109. static const ColorB colorRender     = HexToColor(0xc2fbbe);
  110. static const ColorB colorLocation   = HexToColor(0x30a8fd);
  111. static const ColorB colorAngles     = HexToColor(0x84d7fa);
  112. static const ColorB colorSpawn      = HexToColor(0xfc7070);
  113. static const ColorB colorLife       = HexToColor(0xd0c0ac);
  114. static const ColorB colorKill       = HexToColor(0xd0c0ac);
  115. static const ColorB colorVelocity   = HexToColor(0xcea639);
  116. static const ColorB colorMotion     = HexToColor(0xfb9563);
  117. static const ColorB colorLight      = HexToColor(0xfffdd0);
  118. static const ColorB colorAudio      = HexToColor(0xd671f7);
  119. static const ColorB colorGeneral    = HexToColor(0xececec);
  120. static const ColorB colorSecondGen  = HexToColor(0xc0c0c0);
  121. static const ColorB colorProject    = HexToColor(0xc0c0c0);
  122. static const ColorB colorGPU        = HexToColor(0x00e87e);
  123. static const ColorB colorComponent  = HexToColor(0x000000);
  124.  
  125. #define CRY_PFX2_DECLARE_FEATURE                                 \
  126.   static const SParticleFeatureParams &GetStaticFeatureParams(); \
  127.   virtual const SParticleFeatureParams& GetFeatureParams() const override;
  128.  
  129. #define CRY_PFX2_IMPLEMENT_FEATURE_INTERNAL(BaseType, Type, GroupName, FeatureName, Color, UseConnector)                \
  130.   static struct SInit ## Type {SInit ## Type() { GetFeatureParams().push_back(Type::GetStaticFeatureParams()); } } gInit ## Type; \
  131.   static IParticleFeature* Create ## Type() { return new Type(); }                                                                \
  132.   const SParticleFeatureParams& Type::GetStaticFeatureParams() {                                                                  \
  133.     static SParticleFeatureParams params;                                                                                         \
  134.     params.m_groupName = GroupName;                                                                                               \
  135.     params.m_featureName = FeatureName;                                                                                           \
  136.     params.m_color = Color;                                                                                                       \
  137.     params.m_pFactory = Create ## Type;                                                                                           \
  138.     params.m_hasComponentConnector = UseConnector;                                                                                \
  139.     return params; }                                                                                                              \
  140.   const SParticleFeatureParams& Type::GetFeatureParams() const { return GetStaticFeatureParams(); }                               \
  141.   SERIALIZATION_CLASS_NAME(BaseType, Type, GroupName FeatureName, GroupName FeatureName);
  142.  
  143. #define CRY_PFX2_IMPLEMENT_FEATURE(BaseType, Type, GroupName, FeatureName, Color) \
  144.   CRY_PFX2_IMPLEMENT_FEATURE_INTERNAL(BaseType, Type, GroupName, FeatureName, Color, false)
  145.  
  146. #define CRY_PFX2_IMPLEMENT_FEATURE_WITH_CONNECTOR(BaseType, Type, GroupName, FeatureName, Color) \
  147.   CRY_PFX2_IMPLEMENT_FEATURE_INTERNAL(BaseType, Type, GroupName, FeatureName, Color, true)
  148.  
  149. #define CRY_PFX2_LEGACY_FEATURE(BaseType, NewType, LegacyName)           \
  150.         SERIALIZATION_CLASS_NAME(BaseType, NewType, LegacyName, LegacyName);
  151.  
  152. }
  153.  
  154. #endif // PARTICLEFUNCTION_H
  155.  
downloadParticleFeature.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