Ignition Rendering

API Reference

4.1.0
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 _minVel,
114  double _maxVel) 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 
141  protected: EmitterType type = EM_POINT;
142 
144  protected: ignition::math::Vector3d emitterSize =
146 
148  protected: double rate = 10;
149 
151  protected: double duration = 0;
152 
154  protected: bool emitting = false;
155 
157  protected: ignition::math::Vector3d particleSize = {1, 1, 1};
158 
160  protected: double lifetime = 5;
161 
163  protected: MaterialPtr material = nullptr;
164 
166  protected: double minVelocity = 1;
167 
169  protected: double maxVelocity = 1;
170 
172  protected: ignition::math::Color colorStart =
174 
176  protected: ignition::math::Color colorEnd =
178 
180  protected: double scaleRate = 1;
181 
183  protected: std::string colorRangeImage = "";
184 
186  private: friend class BaseScene;
187  };
188 
190  template <class T>
192  {
193  }
194 
196  template <class T>
198  {
199  }
200 
202  template <class T>
204  {
205  T::Init();
206  }
207 
209  template <class T>
211  {
212  }
213 
215  template <class T>
217  {
218  }
219 
221  template <class T>
223  {
224  return this->type;
225  }
226 
228  template <class T>
230  {
231  this->type = _type;
232  }
233 
235  template <class T>
237  {
238  return this->emitterSize;
239  }
240 
242  template <class T>
244  const ignition::math::Vector3d &_size)
245  {
246  this->emitterSize = _size;
247  }
248 
250  template <class T>
252  {
253  return this->rate;
254  }
255 
257  template <class T>
259  {
260  this->rate = _rate;
261  }
262 
264  template <class T>
266  {
267  return this->duration;
268  }
269 
271  template <class T>
272  void BaseParticleEmitter<T>::SetDuration(double _duration)
273  {
274  this->duration = _duration;
275  }
276 
278  template <class T>
280  {
281  return this->emitting;
282  }
283 
285  template <class T>
287  {
288  this->emitting = _enable;
289  }
290 
292  template <class T>
294  {
295  return this->particleSize;
296  }
297 
299  template <class T>
301  const ignition::math::Vector3d &_size)
302  {
303  this->particleSize = _size;
304  }
305 
307  template <class T>
309  {
310  return this->lifetime;
311  }
312 
314  template <class T>
315  void BaseParticleEmitter<T>::SetLifetime(double _lifetime)
316  {
317  this->lifetime = _lifetime;
318  }
319 
321  template <class T>
323  {
324  return this->material;
325  }
326 
328  template <class T>
330  {
331  this->material = _material;
332  }
333 
335  template <class T>
337  {
338  return this->minVelocity;
339  }
340 
342  template <class T>
344  {
345  return this->maxVelocity;
346  }
347 
349  template <class T>
351  double _maxVelocity)
352  {
353  this->minVelocity = _minVelocity;
354  this->maxVelocity = _maxVelocity;
355  }
356 
358  template <class T>
360  {
361  return this->colorStart;
362  }
363 
365  template <class T>
367  {
368  return this->colorEnd;
369  }
370 
372  template <class T>
374  const ignition::math::Color &_colorStart,
375  const ignition::math::Color &_colorEnd)
376  {
377  this->colorStart = _colorStart;
378  this->colorEnd = _colorEnd;
379  }
380 
382  template <class T>
384  {
385  return this->scaleRate;
386  }
387 
389  template <class T>
390  void BaseParticleEmitter<T>::SetScaleRate(double _scaleRate)
391  {
392  this->scaleRate = _scaleRate;
393  }
394 
396  template <class T>
398  {
399  return this->colorRangeImage;
400  }
401 
403  template <class T>
405  {
406  this->colorRangeImage = _image;
407  }
408  }
409  }
410 }
411 #endif
virtual double Rate() const override
Get how many particles per second should be emitted.
Definition: BaseParticleEmitter.hh:251
virtual ignition::math::Vector3d ParticleSize() const override
Get the particle dimensions (width, height, depth).
Definition: BaseParticleEmitter.hh:293
virtual void Reset()
Reset the particle emitter visual state.
Definition: BaseParticleEmitter.hh:210
EmitterType
Enum for emitter types.
Definition: ParticleEmitter.hh:36
virtual MaterialPtr Material() const override
Get the material which all particles in the emitter will use.
Definition: BaseParticleEmitter.hh:322
virtual double MaxVelocity() const override
Get the maximum velocity each particle is emitted (m/s).
Definition: BaseParticleEmitter.hh:343
virtual void SetEmitting(bool _enable) override
This is used to turn on or off particle emission. Default value is false.
Definition: BaseParticleEmitter.hh:286
virtual void SetDuration(double _duration) override
Set the number of seconds the emitter is active. A value of 0 means infinite duration. Default value is 0.
Definition: BaseParticleEmitter.hh:272
virtual void SetType(const EmitterType _type) override
Set the emitter type. Default value is EM_POINT.
Definition: BaseParticleEmitter.hh:229
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: BaseParticleEmitter.hh:243
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: BaseParticleEmitter.hh:373
STL class.
virtual double MinVelocity() const override
Get the minimum velocity each particle is emitted (m/s).
Definition: BaseParticleEmitter.hh:336
virtual ignition::math::Color ColorEnd() const override
Get the end color of the particles.
Definition: BaseParticleEmitter.hh:366
virtual void SetScaleRate(double _scaleRate) override
Set the amount by which to scale the particles in both x and y direction per second.
Definition: BaseParticleEmitter.hh:390
virtual std::string ColorRangeImage() const override
Get the path to the color image used as an affector.
Definition: BaseParticleEmitter.hh:397
virtual void SetRate(double _rate) override
Set how many particles per second should be emitted. Default value is 10.
Definition: BaseParticleEmitter.hh:258
virtual bool Emitting() const override
Is the particle emitter enabled?
Definition: BaseParticleEmitter.hh:279
virtual ignition::math::Vector3d EmitterSize() const override
Get the size of the emitter where the particles are sampled.
Definition: BaseParticleEmitter.hh:236
virtual void SetMaterial(const MaterialPtr &_material) override
Sets the material which all particles in the emitter will use.
Definition: BaseParticleEmitter.hh:329
virtual ~BaseParticleEmitter()
Destructor.
Definition: BaseParticleEmitter.hh:197
virtual ignition::math::Color ColorStart() const override
Get the starting color of the particles.
Definition: BaseParticleEmitter.hh:359
virtual void Init() override
Definition: BaseParticleEmitter.hh:203
BaseParticleEmitter()
Constructor.
Definition: BaseParticleEmitter.hh:191
Class to manage a particle emitter.
Definition: ParticleEmitter.hh:58
virtual void SetParticleSize(const ignition::math::Vector3d &_size) override
Set the particle dimensions (width, height, depth). Default value is {1, 1, 1}.
Definition: BaseParticleEmitter.hh:300
Definition: BaseScene.hh:36
static const Color White
virtual void SetLifetime(double _lifetime) override
Set the number of seconds each particle will ’live’ for before being destroyed. Default value is 5...
Definition: BaseParticleEmitter.hh:315
static const Vector3 One
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: BaseParticleEmitter.hh:404
virtual void SetVelocityRange(double _minVel, double _maxVel) override
Set a velocity range and each particle is emitted with a random velocity within this range (m/s)...
Definition: BaseParticleEmitter.hh:350
virtual double Duration() const override
Get the number of seconds the emitter is active. A value of 0 means infinite duration.
Definition: BaseParticleEmitter.hh:265
virtual double ScaleRate() const override
Get the amount by which to scale the particles in both x and y direction per second. Default value is 1.
Definition: BaseParticleEmitter.hh:383
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
Definition: BaseParticleEmitter.hh:216
Represents a surface material of a Geometry.
Definition: Material.hh:47
virtual double Lifetime() const override
Get the number of seconds each particle will ’live’ for before being destroyed. ...
Definition: BaseParticleEmitter.hh:308
virtual EmitterType Type() const override
Get the emitter type.
Definition: BaseParticleEmitter.hh:222
Point emitter.
Definition: ParticleEmitter.hh:39
A base implementation of the ParticleEmitter class.
Definition: BaseParticleEmitter.hh:37