Gazebo Rendering

API Reference

6.6.3
gz/rendering/base/BaseParticleEmitter.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef IGNITION_RENDERING_BASE_BASEPARTICLEEMITTER_HH_
19 #define IGNITION_RENDERING_BASE_BASEPARTICLEEMITTER_HH_
20 
21 #include <string>
25 
26 namespace ignition
27 {
28  namespace rendering
29  {
30  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
31  //
32  /* \class BaseParticleEmitter BaseParticleEmitter.hh \
33  * ignition/rendering/base/BaseParticleEmitter.hh
34  */
36  template <class T>
38  public virtual ParticleEmitter,
39  public virtual T
40  {
42  protected: BaseParticleEmitter();
43 
45  public: virtual ~BaseParticleEmitter();
46 
47  // Documentation inherited
48  public: virtual void Init() override;
49 
50  // Documentation inherited
51  public: virtual void PreRender() override;
52 
54  public: virtual void Reset();
55 
56  // Documentation inherited.
57  public: virtual EmitterType Type() const override;
58 
59  // Documentation inherited.
60  public: virtual void SetType(const EmitterType _type) override;
61 
62  // Documentation inherited.
63  public: virtual ignition::math::Vector3d EmitterSize() const override;
64 
65  // Documentation inherited.
66  public: virtual void SetEmitterSize(
67  const ignition::math::Vector3d &_size) override;
68 
69  // Documentation inherited.
70  public: virtual double Rate() const override;
71 
72  // Documentation inherited.
73  public: virtual void SetRate(double _rate) override;
74 
75  // Documentation inherited.
76  public: virtual double Duration() const override;
77 
78  // Documentation inherited.
79  public: virtual void SetDuration(double _duration) override;
80 
81  // Documentation inherited.
82  public: virtual bool Emitting() const override;
83 
84  // Documentation inherited.
85  public: virtual void SetEmitting(bool _enable) override;
86 
87  // Documentation inherited.
88  public: virtual ignition::math::Vector3d ParticleSize() const override;
89 
90  // Documentation inherited.
91  public: virtual void SetParticleSize(
92  const ignition::math::Vector3d &_size) override;
93 
94  // Documentation inherited.
95  public: virtual double Lifetime() const override;
96 
97  // Documentation inherited.
98  public: virtual void SetLifetime(double _lifetime) override;
99 
100  // Documentation inherited.
101  public: virtual MaterialPtr Material() const override;
102 
103  // Documentation inherited.
104  public: virtual void SetMaterial(const MaterialPtr &_material) override;
105 
106  // Documentation inherited.
107  public: virtual double MinVelocity() const override;
108 
109  // Documentation inherited.
110  public: virtual double MaxVelocity() const override;
111 
112  // Documentation inherited.
113  public: virtual void SetVelocityRange(double _minVelocity,
114  double _maxVelocity) override;
115 
116  // Documentation inherited.
117  public: virtual ignition::math::Color ColorStart() const override;
118 
119  // Documentation inherited.
120  public: virtual ignition::math::Color ColorEnd() const override;
121 
122  // Documentation inherited.
123  public: virtual void SetColorRange(
124  const ignition::math::Color &_colorStart,
125  const ignition::math::Color &_colorEnd) override;
126 
127  // Documentation inherited.
128  public: virtual double ScaleRate() const override;
129 
130  // Documentation inherited.
131  public: virtual void SetScaleRate(double _scaleRate) override;
132 
133  // Documentation inherited.
134  public: virtual std::string ColorRangeImage() const override;
135 
136  // Documentation inherited.
137  public: virtual void SetColorRangeImage(
138  const std::string &_image) override;
139 
140  // Documentation inherited.
141  public: virtual float ParticleScatterRatio() const override;
142 
143  // Documentation inherited.
144  public: virtual void SetParticleScatterRatio(float _ratio) override;
145 
147  protected: EmitterType type = EM_POINT;
148 
150  protected: ignition::math::Vector3d emitterSize =
152 
154  protected: double rate = 10;
155 
157  protected: double duration = 0;
158 
160  protected: bool emitting = false;
161 
163  protected: ignition::math::Vector3d particleSize = {1, 1, 1};
164 
166  protected: double lifetime = 5;
167 
169  protected: MaterialPtr material = nullptr;
170 
172  protected: double minVelocity = 1;
173 
175  protected: double maxVelocity = 1;
176 
178  protected: ignition::math::Color colorStart =
180 
182  protected: ignition::math::Color colorEnd =
184 
186  protected: double scaleRate = 1;
187 
189  protected: std::string colorRangeImage = "";
190 
198  protected: float particleScatterRatio = 0.65f;
199 
201  private: friend class BaseScene;
202  };
203 
205  template <class T>
207  {
208  }
209 
211  template <class T>
213  {
214  }
215 
217  template <class T>
219  {
220  T::Init();
221  }
222 
224  template <class T>
226  {
227  }
228 
230  template <class T>
232  {
233  }
234 
236  template <class T>
238  {
239  return this->type;
240  }
241 
243  template <class T>
245  {
246  this->type = _type;
247  }
248 
250  template <class T>
252  {
253  return this->emitterSize;
254  }
255 
257  template <class T>
259  const ignition::math::Vector3d &_size)
260  {
261  this->emitterSize = _size;
262  }
263 
265  template <class T>
267  {
268  return this->rate;
269  }
270 
272  template <class T>
274  {
275  this->rate = _rate;
276  }
277 
279  template <class T>
281  {
282  return this->duration;
283  }
284 
286  template <class T>
287  void BaseParticleEmitter<T>::SetDuration(double _duration)
288  {
289  this->duration = _duration;
290  }
291 
293  template <class T>
295  {
296  return this->emitting;
297  }
298 
300  template <class T>
302  {
303  this->emitting = _enable;
304  }
305 
307  template <class T>
309  {
310  return this->particleSize;
311  }
312 
314  template <class T>
316  const ignition::math::Vector3d &_size)
317  {
318  this->particleSize = _size;
319  }
320 
322  template <class T>
324  {
325  return this->lifetime;
326  }
327 
329  template <class T>
330  void BaseParticleEmitter<T>::SetLifetime(double _lifetime)
331  {
332  this->lifetime = _lifetime;
333  }
334 
336  template <class T>
338  {
339  return this->material;
340  }
341 
343  template <class T>
345  {
346  this->material = _material;
347  }
348 
350  template <class T>
352  {
353  return this->minVelocity;
354  }
355 
357  template <class T>
359  {
360  return this->maxVelocity;
361  }
362 
364  template <class T>
366  double _maxVelocity)
367  {
368  this->minVelocity = _minVelocity;
369  this->maxVelocity = _maxVelocity;
370  }
371 
373  template <class T>
375  {
376  return this->colorStart;
377  }
378 
380  template <class T>
382  {
383  return this->colorEnd;
384  }
385 
387  template <class T>
389  const ignition::math::Color &_colorStart,
390  const ignition::math::Color &_colorEnd)
391  {
392  this->colorStart = _colorStart;
393  this->colorEnd = _colorEnd;
394  }
395 
397  template <class T>
399  {
400  return this->scaleRate;
401  }
402 
404  template <class T>
405  void BaseParticleEmitter<T>::SetScaleRate(double _scaleRate)
406  {
407  this->scaleRate = _scaleRate;
408  }
409 
411  template <class T>
413  {
414  return this->colorRangeImage;
415  }
416 
418  template <class T>
420  {
421  this->colorRangeImage = _image;
422  }
423 
425  template <class T>
427  {
428  return this->particleScatterRatio;
429  }
430 
432  template <class T>
434  {
435  if (_ratio > 0.0f)
436  this->particleScatterRatio = _ratio;
437  }
438  }
439  }
440 }
441 #endif
BaseParticleEmitter()
Constructor.
Definition: gz/rendering/base/BaseParticleEmitter.hh:206
virtual void SetVelocityRange(double _minVelocity, double _maxVelocity) override
Set a velocity range and each particle is emitted with a random velocity within this range (m/s)....
Definition: gz/rendering/base/BaseParticleEmitter.hh:365
virtual void Reset()
Reset the particle emitter visual state.
Definition: gz/rendering/base/BaseParticleEmitter.hh:225
virtual void SetType(const EmitterType _type) override
Set the emitter type. Default value is EM_POINT.
Definition: gz/rendering/base/BaseParticleEmitter.hh:244
virtual EmitterType Type() const override
Get the emitter type.
Definition: gz/rendering/base/BaseParticleEmitter.hh:237
virtual void SetLifetime(double _lifetime) override
Set the number of seconds each particle will ’live’ for before being destroyed. Default value is 5.
Definition: gz/rendering/base/BaseParticleEmitter.hh:330
ignition::math::Color colorEnd
The end color of a particle to choose from.
Definition: gz/rendering/base/BaseParticleEmitter.hh:182
STL class.
virtual void SetRate(double _rate) override
Set how many particles per second should be emitted. Default value is 10.
Definition: gz/rendering/base/BaseParticleEmitter.hh:273
STL class.
double lifetime
Particle lifetime.
Definition: gz/rendering/base/BaseParticleEmitter.hh:166
double scaleRate
The scale rate.
Definition: gz/rendering/base/BaseParticleEmitter.hh:186
virtual float ParticleScatterRatio() const override
Get the particle scatter ratio.
Definition: gz/rendering/base/BaseParticleEmitter.hh:426
virtual MaterialPtr Material() const override
Get the material which all particles in the emitter will use.
Definition: gz/rendering/base/BaseParticleEmitter.hh:337
double minVelocity
The minimum velocity of each particle.
Definition: gz/rendering/base/BaseParticleEmitter.hh:172
virtual void SetColorRange(const ignition::math::Color &_colorStart, const ignition::math::Color &_colorEnd) override
Sets a color for all particle emitted. The actual color will be interpolated between these two colors...
Definition: gz/rendering/base/BaseParticleEmitter.hh:388
ignition::math::Vector3d emitterSize
Emitter size.
Definition: gz/rendering/base/BaseParticleEmitter.hh:150
virtual ~BaseParticleEmitter()
Destructor.
Definition: gz/rendering/base/BaseParticleEmitter.hh:212
virtual void SetDuration(double _duration) override
Set the number of seconds the emitter is active. A value of 0 means infinite duration....
Definition: gz/rendering/base/BaseParticleEmitter.hh:287
static const Vector3 One
virtual void SetScaleRate(double _scaleRate) override
Set the amount by which to scale the particles in both x and y direction per second.
Definition: gz/rendering/base/BaseParticleEmitter.hh:405
@ EM_POINT
Point emitter.
Definition: gz/rendering/ParticleEmitter.hh:39
ignition::math::Vector3d particleSize
Particle size.
Definition: gz/rendering/base/BaseParticleEmitter.hh:163
virtual void SetMaterial(const MaterialPtr &_material) override
Sets the material which all particles in the emitter will use.
Definition: gz/rendering/base/BaseParticleEmitter.hh:344
float particleScatterRatio
The particle scatter ratio. This is used to determine the ratio of particles that will be detected by...
Definition: gz/rendering/base/BaseParticleEmitter.hh:198
virtual void SetParticleScatterRatio(float _ratio) override
Set the particle scatter ratio.
Definition: gz/rendering/base/BaseParticleEmitter.hh:433
virtual ignition::math::Color ColorStart() const override
Get the starting color of the particles.
Definition: gz/rendering/base/BaseParticleEmitter.hh:374
virtual void SetParticleSize(const ignition::math::Vector3d &_size) override
Set the particle dimensions (width, height, depth). Default value is {1, 1, 1}.
Definition: gz/rendering/base/BaseParticleEmitter.hh:315
virtual double ScaleRate() const override
Get the amount by which to scale the particles in both x and y direction per second....
Definition: gz/rendering/base/BaseParticleEmitter.hh:398
virtual void SetColorRangeImage(const std::string &_image) override
Set the path to the color image used as an affector. This affector modifies the color of particles in...
Definition: gz/rendering/base/BaseParticleEmitter.hh:419
virtual ignition::math::Vector3d EmitterSize() const override
Get the size of the emitter where the particles are sampled.
Definition: gz/rendering/base/BaseParticleEmitter.hh:251
virtual bool Emitting() const override
Is the particle emitter enabled?
Definition: gz/rendering/base/BaseParticleEmitter.hh:294
A base implementation of the ParticleEmitter class.
Definition: gz/rendering/base/BaseParticleEmitter.hh:37
virtual double Duration() const override
Get the number of seconds the emitter is active. A value of 0 means infinite duration.
Definition: gz/rendering/base/BaseParticleEmitter.hh:280
virtual void SetEmitterSize(const ignition::math::Vector3d &_size) override
Set the size of the emitter where the particles are sampled. Default value is (1, 1,...
Definition: gz/rendering/base/BaseParticleEmitter.hh:258
double maxVelocity
The maximum velocity of each particle.
Definition: gz/rendering/base/BaseParticleEmitter.hh:175
virtual double Lifetime() const override
Get the number of seconds each particle will ’live’ for before being destroyed.
Definition: gz/rendering/base/BaseParticleEmitter.hh:323
virtual std::string ColorRangeImage() const override
Get the path to the color image used as an affector.
Definition: gz/rendering/base/BaseParticleEmitter.hh:412
EmitterType type
Emitter type.
Definition: gz/rendering/base/BaseParticleEmitter.hh:147
virtual double MinVelocity() const override
Get the minimum velocity each particle is emitted (m/s).
Definition: gz/rendering/base/BaseParticleEmitter.hh:351
virtual ignition::math::Color ColorEnd() const override
Get the end color of the particles.
Definition: gz/rendering/base/BaseParticleEmitter.hh:381
double duration
Duration of the emitter.
Definition: gz/rendering/base/BaseParticleEmitter.hh:157
virtual ignition::math::Vector3d ParticleSize() const override
Get the particle dimensions (width, height, depth).
Definition: gz/rendering/base/BaseParticleEmitter.hh:308
Definition: gz/rendering/base/BaseScene.hh:37
virtual void Init() override
Definition: gz/rendering/base/BaseParticleEmitter.hh:218
std::string colorRangeImage
The color image.
Definition: gz/rendering/base/BaseParticleEmitter.hh:189
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
Definition: gz/rendering/base/BaseParticleEmitter.hh:231
Class to manage a particle emitter.
Definition: gz/rendering/ParticleEmitter.hh:58
virtual double Rate() const override
Get how many particles per second should be emitted.
Definition: gz/rendering/base/BaseParticleEmitter.hh:266
ignition::math::Color colorStart
The start color of a particle to choose from.
Definition: gz/rendering/base/BaseParticleEmitter.hh:178
Represents a surface material of a Geometry.
Definition: gz/rendering/Material.hh:47
bool emitting
Whether particle emitter is enabled or not.
Definition: gz/rendering/base/BaseParticleEmitter.hh:160
virtual void SetEmitting(bool _enable) override
This is used to turn on or off particle emission. Default value is false.
Definition: gz/rendering/base/BaseParticleEmitter.hh:301
EmitterType
Enum for emitter types.
Definition: gz/rendering/ParticleEmitter.hh:36
double rate
Rate of emission.
Definition: gz/rendering/base/BaseParticleEmitter.hh:154
MaterialPtr material
Particle material.
Definition: gz/rendering/base/BaseParticleEmitter.hh:169
static const Color White
virtual double MaxVelocity() const override
Get the maximum velocity each particle is emitted (m/s).
Definition: gz/rendering/base/BaseParticleEmitter.hh:358