AGXDynamics
2.35.0.3
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
#include <
agx/ObserverFrame.h
>
26
27
namespace
agxSDK
28
{
29
class
Simulation;
30
}
31
32
33
namespace
agx
34
{
35
AGX_DECLARE_POINTER_TYPES
(
RigidBodyEmitter
);
36
AGX_DECLARE_VECTOR_TYPES
(
RigidBodyEmitter
);
37
43
class
AGXPHYSICS_EXPORT
RigidBodyEmitter
:
public
agx::Emitter
44
{
45
private
:
50
struct
RigidBodyEmitterInternalData :
public
agx::ICloneable
51
{
52
enum
EState
53
{
54
CREATED_BY_RIGIDBODYEMITTER = 1 << 0,
55
CREATED_BY_SNAPSHOT_LOADING = 1 << 1,
56
IS_BODYMODEL_TEMPLATE = 1 << 2
57
};
58
typedef
agx::BitState< EState, agx::Int32 >
State
;
59
60
RigidBodyEmitterInternalData() : state() {}
61
62
State
state;
63
protected
:
64
virtual
~RigidBodyEmitterInternalData() {}
65
66
private
:
67
virtual
agx::ICloneableRef
clone(
agx::ICloneable
* child)
override
68
{
69
if
(child ==
nullptr
)
70
child =
new
RigidBodyEmitterInternalData();
71
72
child->
as
<RigidBodyEmitterInternalData>()->state = this->state;
73
74
return
agx::ICloneableRef
(child);
75
}
76
};
77
public
:
78
79
typedef
Event2<RigidBodyEmitter *, agx::RigidBody *>
Event
;
80
Event
emitEvent
;
81
82
AGX_DECLARE_POINTER_TYPES
(DistributionModel);
83
84
public
:
85
90
RigidBodyEmitter
(
Quantity
quantity = QUANTITY_COUNT);
91
99
static
agx::RigidBodyRefVector
spawnBodiesInBound(
const
agx::Bound3
& bound,
100
agx::Emitter::DistributionTable
* sourceTable,
101
const
agx::Vec3
& spacing,
102
agx::Real
jitterfactor =
agx::Real
(0));
103
107
static
bool
rigidBodyIsEmitted(
const
agx::RigidBody
* body );
108
112
static
bool
rigidBodyIsLoaded(
const
agx::RigidBody
* body );
113
119
static
bool
rigidBodyIsTemplate(
const
agx::RigidBody
* body);
120
127
static
void
setRigidBodyIsEmitted(
agx::RigidBody
* body,
bool
isEmitted );
128
135
static
void
setRigidBodyIsLoaded(
agx::RigidBody
* body,
bool
isLoaded );
136
147
static
void
setRigidBodyIsTemplate(
agx::RigidBody
* body,
bool
isTemplate);
148
153
static
agx::RigidBodyPtrVector
getEmittedBodiesInSimulation(
agxSDK::Simulation
* simulation);
154
155
DOXYGEN_START_INTERNAL_BLOCK
()
156
157
static
void
storePersistentData(const
agx
::
RigidBody
* rb,
agxStream
::OutputArchive&
out
);
158
159
static
void
restorePersistentData(
agx
::
RigidBody
* rb,
agxStream
::InputArchive&
in
);
160
161
AGXSTREAM_DECLARE_SERIALIZABLE
(
agx
::
RigidBodyEmitter
);
162
163
private:
164
static RigidBodyEmitterInternalData* getRigidBodyEmitterData(const
agx
::
RigidBody
* obj);
165
166
static RigidBodyEmitterInternalData* getOrCreateRigidBodyEmitterData(
agx
::
RigidBody
* obj);
167
168
DOXYGEN_END_INTERNAL_BLOCK
()
169
170
protected:
171
173
virtual ~
RigidBodyEmitter
();
174
175
virtual
void
emitBody(const
Vec3
& position,
176
const
Quat
& rotation,
177
const
Vec3
& velocity,
178
Emitter
::DistributionModel *model) override;
179
virtual
bool
preEmit() override;
180
virtual
void
postEmit() override;
181
182
virtual
void
transfer(
agxSDK
::Simulation *simulation) override;
183
184
private:
185
// Creates and initializes the parameters.
186
void
init
();
187
188
189
190
private:
191
agxSDK
::Simulation *m_simulation;
192
};
193
197
class
AGXPHYSICS_EXPORT
RigidBodyEmitter
::DistributionModel : public
Emitter
::DistributionModel
198
{
199
public
:
203
DistributionModel();
204
216
DistributionModel(
agx::RigidBody
*bodyTemplate,
217
agx::Real
probabilityWeight,
218
agx::ObserverFrame
* placementObserver=
nullptr
);
219
223
agx::RigidBody
*getBodyTemplate();
224
229
agx::ObserverFrame
* getPlacementObserver()
const
;
230
231
DOXYGEN_START_INTERNAL_BLOCK
()
232
233
AGXSTREAM_DECLARE_SERIALIZABLE
(
agx
::
RigidBodyEmitter
::DistributionModel);
234
235
DOXYGEN_END_INTERNAL_BLOCK
()
236
237
protected:
238
virtual ~DistributionModel();
239
virtual
agx
::
Real
calculateVolume() override;
240
virtual
agx
::
Real
calculateMass() override;
241
242
private:
243
agx
::
RigidBodyRef
m_bodyTemplate;
244
agx
::
ObserverFrameRef
m_placementObserver;
245
};
246
}
247
248
#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:80
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::ObserverFrame
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition:
ObserverFrame.h:43
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:79
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:43
agx::GraphNode::State
State
Definition:
GraphNode.h:39
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition:
Referenced.h:248
Emitter.h
ObserverFrame.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 Fri Feb 10 2023 14:06:17 for AGXDynamics by
1.8.17