Loading...
Searching...
No Matches
VolumeParticleEmitter3.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_VOLUME_PARTICLE_EMITTER3_HPP
12#define CUBBYFLOW_VOLUME_PARTICLE_EMITTER3_HPP
13
17
18#include <random>
19
20namespace CubbyFlow
21{
28{
29 public:
30 class Builder;
31
53 double spacing, const Vector3D& initialVel = Vector3D(),
54 const Vector3D& linearVel = Vector3D(),
55 const Vector3D& angularVel = Vector3D(),
56 size_t maxNumberOfParticles = std::numeric_limits<size_t>::max(),
57 double jitter = 0.0, bool isOneShot = true,
58 bool allowOverlapping = false, uint32_t seed = 0);
59
69
72
75
78
81
83 [[nodiscard]] double GetJitter() const;
84
86 void SetJitter(double newJitter);
87
89 [[nodiscard]] bool GetIsOneShot() const;
90
101
104
115
118
121
123 [[nodiscard]] double GetSpacing() const;
124
126 void SetSpacing(double newSpacing);
127
130
133
136
139
142
145
148
149 private:
156 void OnUpdate(double currentTimeInSeconds,
157 double timeIntervalInSeconds) override;
158
159 void Emit(const ParticleSystemData3Ptr& particles,
161
162 [[nodiscard]] double Random();
163
164 [[nodiscard]] Vector3D VelocityAt(const Vector3D& point) const;
165
166 std::mt19937 m_rng;
167
168 ImplicitSurface3Ptr m_implicitSurface;
169 BoundingBox3D m_maxRegion;
170 double m_spacing;
171 Vector3D m_initialVel;
172 Vector3D m_linearVel;
173 Vector3D m_angularVel;
174 PointGenerator3Ptr m_pointsGen;
175
176 size_t m_maxNumberOfParticles = std::numeric_limits<size_t>::max();
177 size_t m_numberOfEmittedParticles = 0;
178
179 double m_jitter = 0.0;
180 bool m_isOneShot = true;
181 bool m_allowOverlapping = false;
182};
183
185using VolumeParticleEmitter3Ptr = std::shared_ptr<VolumeParticleEmitter3>;
186
191{
192 public:
196
199
202
205
208
211
214
217 size_t maxNumberOfParticles);
218
221
224
227
230
233
236
237 private:
238 ImplicitSurface3Ptr m_implicitSurface;
239 BoundingBox3D m_maxRegion;
240 double m_spacing = 0.1;
241 Vector3D m_initialVel;
242 Vector3D m_linearVel;
243 Vector3D m_angularVel;
244 size_t m_maxNumberOfParticles = std::numeric_limits<size_t>::max();
245 double m_jitter = 0.0;
246 uint32_t m_seed = 0;
247 bool m_isBoundSet = false;
248 bool m_isOneShot = true;
249 bool m_allowOverlapping = false;
250};
251} // namespace CubbyFlow
252
253#endif
N-D axis-aligned bounding box class.
Definition BoundingBox.hpp:47
Definition Matrix.hpp:30
Abstract base class for 3-D particle emitter.
Definition ParticleEmitter3.hpp:22
Front-end to create VolumeParticleEmitter3 objects step by step.
Definition VolumeParticleEmitter3.hpp:191
Builder & WithRandomSeed(uint32_t seed)
Returns builder with random seed.
VolumeParticleEmitter3 Build() const
Builds VolumeParticleEmitter3.
Builder & WithJitter(double jitter)
Returns builder with jitter amount.
Builder & WithAngularVelocity(const Vector3D &angularVel)
Returns builder with angular velocity.
Builder & WithImplicitSurface(const ImplicitSurface3Ptr &implicitSurface)
Returns builder with implicit surface defining volume shape.
Builder & WithIsOneShot(bool isOneShot)
Returns builder with one-shot flag.
Builder & WithMaxNumberOfParticles(size_t maxNumberOfParticles)
Returns builder with max number of particles.
Builder & WithSpacing(double spacing)
Returns builder with spacing.
VolumeParticleEmitter3Ptr MakeShared() const
Builds shared pointer of VolumeParticleEmitter3 instance.
Builder & WithInitialVelocity(const Vector3D &initialVel)
Returns builder with initial velocity.
Builder & WithAllowOverlapping(bool allowOverlapping)
Returns builder with overlapping flag.
Builder & WithSurface(const Surface3Ptr &surface)
Returns builder with surface defining volume shape.
Builder & WithLinearVelocity(const Vector3D &linearVel)
Returns builder with linear velocity.
Builder & WithMaxRegion(const BoundingBox3D &maxRegion)
Returns builder with max region.
3-D volumetric particle emitter.
Definition VolumeParticleEmitter3.hpp:28
double GetSpacing() const
Returns the spacing between particles.
Vector3D GetLinearVelocity() const
Returns the linear velocity of the emitter.
void SetPointGenerator(const PointGenerator3Ptr &newPointsGen)
Sets the point generator.
void SetMaxRegion(const BoundingBox3D &newMaxRegion)
Sets the max particle gen region.
static Builder GetBuilder()
Returns builder fox VolumeParticleEmitter3.
void SetAllowOverlapping(bool newValue)
Sets the flag to true if particles can overlap each other.
Vector3D GetInitialVelocity() const
Sets the initial velocity of the particles.
void SetLinearVelocity(const Vector3D &newLinearVel)
Sets the linear velocity of the emitter.
double GetJitter() const
Returns jitter amount.
size_t GetMaxNumberOfParticles() const
Returns max number of particles to be emitted.
Vector3D GetAngularVelocity() const
Returns the angular velocity of the emitter.
void SetMaxNumberOfParticles(size_t newMaxNumberOfParticles)
Sets the max number of particles to be emitted.
const BoundingBox3D & GetMaxRegion() const
Returns max particle gen region.
void SetIsOneShot(bool newValue)
Sets the flag to true if particles are emitted just once.
void SetSpacing(double newSpacing)
Sets the spacing between particles.
void SetInitialVelocity(const Vector3D &newInitialVel)
Returns the initial velocity of the particles.
const ImplicitSurface3Ptr & GetSurface() const
Returns source surface.
void SetSurface(const ImplicitSurface3Ptr &newSurface)
Sets the source surface.
VolumeParticleEmitter3(ImplicitSurface3Ptr implicitSurface, BoundingBox3D maxRegion, double spacing, const Vector3D &initialVel=Vector3D(), const Vector3D &linearVel=Vector3D(), const Vector3D &angularVel=Vector3D(), size_t maxNumberOfParticles=std::numeric_limits< size_t >::max(), double jitter=0.0, bool isOneShot=true, bool allowOverlapping=false, uint32_t seed=0)
void SetAngularVelocity(const Vector3D &newAngularVel)
Sets the linear velocity of the emitter.
bool GetIsOneShot() const
Returns true if particles should be emitted just once.
bool GetAllowOverlapping() const
Returns true if particles can be overlapped.
void SetJitter(double newJitter)
Sets jitter amount between 0 and 1.
Definition pybind11Utils.hpp:21
std::shared_ptr< ParticleSystemData3 > ParticleSystemData3Ptr
Shared pointer type of ParticleSystemData3.
Definition ParticleSystemData.hpp:284
std::shared_ptr< ImplicitSurface3 > ImplicitSurface3Ptr
Shared pointer type for the ImplicitSurface3.
Definition ImplicitSurface.hpp:70
std::shared_ptr< Surface3 > Surface3Ptr
Shared pointer for the Surface3 type.
Definition Surface.hpp:147
Vector3< double > Vector3D
Definition Matrix.hpp:787
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
std::shared_ptr< PointGenerator3 > PointGenerator3Ptr
Shared pointer for the PointGenerator3 type.
Definition PointGenerator3.hpp:71
std::shared_ptr< VolumeParticleEmitter3 > VolumeParticleEmitter3Ptr
Shared pointer for the VolumeParticleEmitter3 type.
Definition VolumeParticleEmitter3.hpp:185