AGX Dynamics  2.35.0.1
ParticleEmitter.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 
18 #ifndef AGX_PARTICLE_EMITTER_H
19 #define AGX_PARTICLE_EMITTER_H
20 
21 #include <agx/Emitter.h>
22 #include <agx/ParticleSystem.h>
23 
24 namespace agx
25 {
28 
33  {
34  public:
37 
38  AGX_DECLARE_POINTER_TYPES(DistributionModel);
39 
40  public:
41 
45  ParticleEmitter( ParticleSystem *target, Quantity quantity = QUANTITY_COUNT );
46 
51  void setLife( Real life );
52 
56  Real getLife() const;
57 
62  void setColor( const Vec4& color );
63 
67  const Vec4& getColor( ) const;
68 
72  void setEnableMoisture(bool enable);
73 
74  /*
75  Get if the emitter should set a moisture property for the created particles
76  */
77  bool getEnableMoisture() const;
78 
82  void setDefaultMoisture(agx::Real defaultMoisture);
83 
88 
89 
91 
93 
95 
96  protected:
99 
101  virtual ~ParticleEmitter();
102 
103  virtual void emitBody(const Vec3& position, const Vec3& velocity, Emitter::DistributionModel *model) override;
104  virtual bool preEmit() override;
105  virtual void postEmit() override;
106  virtual Real getDefaultElementQuantity(Quantity quantity) override;
107 
108  private:
109  // Creates and initializes the parameters.
110  void init(ParticleSystem *target);
111 
112  private:
113  ParticleSystemRef m_particleSystem;
114  bool m_isGranularSystem;
115  ScalarParameterRef m_life;
116 
117  ScalarParameterRef m_particleColor;
118  size_t m_startSize;
119 
120  bool m_enableMoistureProperty = false;
121  agx::Real m_defaultMoisture = 0;
122  };
123 
124 
125  class AGXPHYSICS_EXPORT ParticleEmitter::DistributionModel : public Emitter::DistributionModel
126  {
127  public:
129  DistributionModel(agx::Real particleRadius, agx::Material *particleMaterial, agx::Real probabilityWeight);
130 
134  // void setParticleRadius(agx::Real radius);
135 
140 
144  // void setParticleMaterial(agx::Material *material);
145 
151 
153 
154  AGXSTREAM_DECLARE_SERIALIZABLE( agx::ParticleEmitter::DistributionModel );
155 
157 
158  protected:
159  virtual ~DistributionModel();
160  virtual agx::Real calculateVolume() override;
161  virtual agx::Real calculateMass() override;
162 
163  private:
164  agx::Real m_particleRadius;
165  agx::MaterialRef m_particleMaterial;
166  };
167 }
168 
169 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Spawns new bodys inside a given volume.
Definition: Emitter.h:45
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:388
Spawns new particles inside a given volume given to the Emitter.
void setDefaultMoisture(agx::Real defaultMoisture)
Set the default value for the moisture property of created particles.
void setEnableMoisture(bool enable)
Set if the emitter should set a moisture property for the created particles.
Real getLife() const
Event2< ParticleEmitter *, agxData::EntityRange > Event
agx::Real getDefaultMoisture() const
Return the default value of the moisture property for created particles.
void setLife(Real life)
Set the initial life-length of the particles.
agx::Material * getParticleMaterial()
Set the particle material.
agx::Real getParticleRadius() const
Set the particle radius.
bool getEnableMoisture() const
const agx::Material * getParticleMaterial() const
void setColor(const Vec4 &color)
Set the initial color for the spawned particles.
ParticleEmitter(ParticleSystem *target, Quantity quantity=QUANTITY_COUNT)
Create a particle emitter coupled with a particle system.
const Vec4 & getColor() const
DistributionModel(agx::Real particleRadius, agx::Material *particleMaterial, agx::Real probabilityWeight)
A basic particle system that contains all the storages and buffers required for basic operation and a...
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42
void AGXPHYSICS_EXPORT init()
Initialize agx.