BVB Source Codes

CRYENGINE Show FeatureFluidDynamics.cpp Source code

Return Download CRYENGINE: download FeatureFluidDynamics.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  Created:     21/10/2015 by Benjamin Block
  5. //  Description:
  6. // -------------------------------------------------------------------------
  7. //
  8. ////////////////////////////////////////////////////////////////////////////
  9.  
  10. #include "StdAfx.h"
  11. #include <CrySerialization/Serializer.h>
  12. #include <CrySerialization/Math.h>
  13. #include <CrySerialization/SmartPtr.h>
  14. #include "ParticleSystem/ParticleFeature.h"
  15. #include "ParticleSystem/ParticleEmitter.h"
  16.  
  17. #include <CryRenderer/IGpuParticles.h>
  18.  
  19. CRY_PFX2_DBG
  20.  
  21. namespace pfx2
  22. {
  23.  
  24. class CFeatureMotionFluidDynamics : public CParticleFeature
  25. {
  26. public:
  27.         CRY_PFX2_DECLARE_FEATURE
  28.  
  29.         typedef TValue<int, USoftLimit<100>> TParticleCount;
  30.  
  31.         CFeatureMotionFluidDynamics()
  32.                 : CParticleFeature(gpu_pfx2::eGpuFeatureType_MotionFluidDynamics)
  33.                 , m_initialVelocity(0.0, 0.0, 5.0)
  34.                 , m_stiffness(1000.f)
  35.                 , m_gravityConstant(-5.f)
  36.                 , m_h(0.5f)
  37.                 , m_r0(32.f)
  38.                 , m_mass(1.0f)
  39.                 , m_maxVelocity(5.0f)
  40.                 , m_maxForce(500.f)
  41.                 , m_atmosphericDrag(50.f)
  42.                 , m_cohesion(1.0f)
  43.                 , m_baroclinity(0.25f)
  44.                 , m_spread(1.0f)
  45.                 , m_particleInfluence(0.1f)
  46.                 , m_numberOfIterations(1)
  47.                 , m_gridSizeX(16)
  48.                 , m_gridSizeY(16)
  49.                 , m_gridSizeZ(16)
  50.                 , m_numSpawnParticles(10)
  51.         {}
  52.  
  53.         virtual void AddToComponent(CParticleComponent* pComponent, SComponentParams* pParams) override
  54.         {
  55.                 pComponent->AddToUpdateList(EUL_Update, this);
  56.  
  57.                 if (auto pInt = GetGpuInterface())
  58.                 {
  59.                         gpu_pfx2::SFeatureParametersMotionFluidDynamics params;
  60.                         params.initialVelocity = m_initialVelocity;
  61.                         params.stiffness = m_stiffness;
  62.                         params.gravityConstant = m_gravityConstant;
  63.                         params.h = m_h;
  64.                         params.r0 = m_r0;
  65.                         params.mass = m_mass;
  66.                         params.maxVelocity = m_maxVelocity;
  67.                         params.maxForce = m_maxForce;
  68.                         params.atmosphericDrag = m_atmosphericDrag;
  69.                         params.cohesion = m_cohesion;
  70.                         params.baroclinity = m_baroclinity;
  71.                         params.spread = m_spread;
  72.                         params.numberOfIterations = m_numberOfIterations;
  73.                         params.gridSizeX = m_gridSizeX;
  74.                         params.gridSizeY = m_gridSizeY;
  75.                         params.gridSizeZ = m_gridSizeZ;
  76.                         params.particleInfluence = m_particleInfluence;
  77.                         params.numSpawnParticles = m_numSpawnParticles;
  78.                         pInt->SetParameters(params);
  79.                 }
  80.         }
  81.  
  82.         virtual void Serialize(Serialization::IArchive& ar) override
  83.         {
  84.                 CParticleFeature::Serialize(ar);
  85.                 ar(m_initialVelocity, "initialVelocity", "Initial Velocity");
  86.                 ar(m_stiffness, "stiffness", "Stiffness");
  87.                 ar(m_gravityConstant, "gravityConstant", "Gravity Constant");
  88.                 ar(m_h, "h", "h");
  89.                 ar(m_r0, "r0", "Rest Density");
  90.                 ar(m_mass, "mass", "Particle Mass");
  91.                 ar(m_maxVelocity, "maxVelocity", "Maximum Velocity");
  92.                 ar(m_maxForce, "maxForce", "Maximum Force");
  93.                 ar(m_atmosphericDrag, "atmosphericDrag", "Atmospheric Drag");
  94.                 ar(m_cohesion, "cohesion", "Cohesion");
  95.                 ar(m_baroclinity, "baroclinity", "Baroclinity");
  96.                 ar(m_spread, "spread", "Spread");
  97.                 ar(m_particleInfluence, "particleInfluence", "Particle Influence");
  98.                 ar(m_numberOfIterations, "numberOfIterations", "Number Of Iterations");
  99.                 ar(m_gridSizeX, "gridSizeX", "Grid Size X");
  100.                 ar(m_gridSizeY, "gridSizeY", "Grid Size Y");
  101.                 ar(m_gridSizeZ, "gridSizeZ", "Grid Size Z");
  102.                 ar(m_numSpawnParticles, "numSpawnParticles", "Particles per Frame");
  103.         }
  104.  
  105. private:
  106.         Vec3           m_initialVelocity;
  107.         UFloat         m_stiffness;
  108.         float          m_gravityConstant;
  109.         UFloat         m_h;
  110.         UFloat         m_r0;
  111.         UFloat         m_mass;
  112.         UFloat         m_maxVelocity;
  113.         UFloat         m_maxForce;
  114.         UFloat         m_atmosphericDrag;
  115.         UFloat         m_cohesion;
  116.         UFloat         m_baroclinity;
  117.         UFloat         m_spread;
  118.         UFloat         m_particleInfluence;
  119.         UByte          m_numberOfIterations;
  120.         UByte          m_gridSizeX;
  121.         UByte          m_gridSizeY;
  122.         UByte          m_gridSizeZ;
  123.         TParticleCount m_numSpawnParticles;
  124. };
  125.  
  126. CRY_PFX2_IMPLEMENT_FEATURE(CParticleFeature, CFeatureMotionFluidDynamics, "GPU Particles", "Fluid Dynamics", colorGPU);
  127. CRY_PFX2_LEGACY_FEATURE(CParticleFeature, CFeatureMotionFluidDynamics, "MotionGPU Fluid Dynamics");
  128.  
  129. }
  130.  
downloadFeatureFluidDynamics.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