AGXDynamics
2.35.0.2
RigidBodyEmitter.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_RIGIDBODY_EMITTER_H
19
#define AGX_RIGIDBODY_EMITTER_H
20
21
#include <
agx/Emitter.h
>
22
#include <
agx/InternalData.h
>
23
#include <
agx/BitState.h
>
24
#include <
agx/ICloneable.h
>
25
26
namespace
agxSDK
27
{
28
class
Simulation;
29
}
30
31
32
namespace
agx
33
{
34
AGX_DECLARE_POINTER_TYPES
(
RigidBodyEmitter
);
35
AGX_DECLARE_VECTOR_TYPES
(
RigidBodyEmitter
);
36
42
class
AGXPHYSICS_EXPORT
RigidBodyEmitter
:
public
agx::Emitter
43
{
44
private
:
49
struct
RigidBodyEmitterInternalData :
public
agx::ICloneable
50
{
51
enum
EState
52
{
53
CREATED_BY_RIGIDBODYEMITTER = 1 << 0,
54
CREATED_BY_SNAPSHOT_LOADING = 1 << 1,
55
IS_BODYMODEL_TEMPLATE = 1 << 2
56
};
57
typedef
agx::BitState< EState, agx::Int32 >
State
;
58
59
RigidBodyEmitterInternalData() : state() {}
60
61
State
state;
62
protected
:
63
virtual
~RigidBodyEmitterInternalData() {}
64
65
private
:
66
virtual
agx::ICloneableRef
clone(
agx::ICloneable
* child)
override
67
{
68
if
(child ==
nullptr
)
69
child =
new
RigidBodyEmitterInternalData();
70
71
child->
as
<RigidBodyEmitterInternalData>()->state = this->state;
72
73
return
agx::ICloneableRef
(child);
74
}
75
};
76
public
:
77
78
typedef
Event2<RigidBodyEmitter *, agx::RigidBody *>
Event
;
79
Event
emitEvent
;
80
81
AGX_DECLARE_POINTER_TYPES
(DistributionModel);
82
83
public
:
84
89
RigidBodyEmitter
(
Quantity
quantity = QUANTITY_COUNT);
90
98
static
agx::RigidBodyRefVector
spawnBodiesInBound(
const
agx::Bound3
& bound,
99
agx::Emitter::DistributionTable
* sourceTable,
100
const
agx::Vec3
& spacing,
101
agx::Real
jitterfactor =
agx::Real
(0));
102
106
static
bool
rigidBodyIsEmitted(
const
agx::RigidBody
* body );
107
111
static
bool
rigidBodyIsLoaded(
const
agx::RigidBody
* body );
112
118
static
bool
rigidBodyIsTemplate(
const
agx::RigidBody
* body);
119
126
static
void
setRigidBodyIsEmitted(
agx::RigidBody
* body,
bool
isEmitted );
127
134
static
void
setRigidBodyIsLoaded(
agx::RigidBody
* body,
bool
isLoaded );
135
146
static
void
setRigidBodyIsTemplate(
agx::RigidBody
* body,
bool
isTemplate);
147
152
static
agx::RigidBodyPtrVector
getEmittedBodiesInSimulation(
agxSDK::Simulation
* simulation);
153
154
DOXYGEN_START_INTERNAL_BLOCK
()
155
156
static
void
storePersistentData(const
agx
::
RigidBody
* rb,
agxStream
::OutputArchive&
out
);
157
158
static
void
restorePersistentData(
agx
::
RigidBody
* rb,
agxStream
::InputArchive&
in
);
159
160
AGXSTREAM_DECLARE_SERIALIZABLE
(
agx
::
RigidBodyEmitter
);
161
162
private:
163
static RigidBodyEmitterInternalData* getRigidBodyEmitterData(const
agx
::
RigidBody
* obj);
164
165
static RigidBodyEmitterInternalData* getOrCreateRigidBodyEmitterData(
agx
::
RigidBody
* obj);
166
167
DOXYGEN_END_INTERNAL_BLOCK
()
168
169
protected:
170
172
virtual ~
RigidBodyEmitter
();
173
174
virtual
void
emitBody(const
Vec3
& position,
175
const
Quat
& rotation,
176
const
Vec3
& velocity,
177
Emitter
::DistributionModel *model) override;
178
virtual
bool
preEmit() override;
179
virtual
void
postEmit() override;
180
181
virtual
void
transfer(
agxSDK
::Simulation *simulation) override;
182
183
private:
184
// Creates and initializes the parameters.
185
void
init
();
186
187
188
189
private:
190
agxSDK
::Simulation *m_simulation;
191
};
192
196
class
AGXPHYSICS_EXPORT
RigidBodyEmitter
::DistributionModel : public
Emitter
::DistributionModel
197
{
198
public
:
202
DistributionModel();
203
213
DistributionModel(
agx::RigidBody
*bodyTemplate,
agx::Real
probabilityWeight);
214
218
agx::RigidBody
*getBodyTemplate();
219
220
DOXYGEN_START_INTERNAL_BLOCK
()
221
222
AGXSTREAM_DECLARE_SERIALIZABLE
(
agx
::
RigidBodyEmitter
::DistributionModel);
223
224
DOXYGEN_END_INTERNAL_BLOCK
()
225
226
protected:
227
virtual ~DistributionModel();
228
virtual
agx
::
Real
calculateVolume() override;
229
virtual
agx
::
Real
calculateMass() override;
230
231
private:
232
agx
::
RigidBodyRef
m_bodyTemplate;
233
};
234
}
235
236
#endif
InternalData.h
agx::Real
double Real
Definition:
Real.h:42
agx::ICloneableRef
agx::ref_ptr< ICloneable > ICloneableRef
Definition:
ICloneable.h:24
agx::Vector< RigidBodyRef >
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition:
OutputArchive.h:412
BitState.h
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:54
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition:
macros.h:97
agx::Emitter::DistributionTable
friend class DistributionTable
Definition:
Emitter.h:388
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition:
macros.h:96
agx::RigidBodyEmitter::emitEvent
Event emitEvent
Definition:
RigidBodyEmitter.h:79
agx::ICloneable
Interface class for a cloneable reference counted object.
Definition:
ICloneable.h:29
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agx::Referenced::as
T * as()
Subclass casting.
agx::VectorPOD< RigidBody * >
agx::Emitter::Quantity
Quantity
Definition:
Emitter.h:47
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition:
AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::BoundT< Vec3 >
agxStream::in
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition:
InputArchive.h:400
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition:
Vector.h:34
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition:
ref_ptr.h:29
agx::RigidBodyEmitter::Event
Event2< RigidBodyEmitter *, agx::RigidBody * > Event
Definition:
RigidBodyEmitter.h:78
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition:
Simulation.h:126
ICloneable.h
agx::QuatT< Real >
agx::RigidBodyEmitter
Spawns new Rigid Bodies inside a volume given to the Emitter.
Definition:
RigidBodyEmitter.h:42
agx::GraphNode::State
State
Definition:
GraphNode.h:39
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition:
Referenced.h:248
Emitter.h
agxStream
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
Definition:
ElementaryConstraint.h:31
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition:
Constraint.h:30
agx::init
void AGXPHYSICS_EXPORT init()
Initialize agx.
agx::Vec3T< Real >
agx::Event2< RigidBodyEmitter *, agx::RigidBody * >
agx::Emitter
Spawns new bodys inside a given volume.
Definition:
Emitter.h:44
include
agx
RigidBodyEmitter.h
Generated on Mon Jan 30 2023 15:44:19 for AGXDynamics by
1.8.17