1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
#ifndef EMITTER_GEOMS_H
#define EMITTER_GEOMS_H
#include "Apex.h"
namespace nvidia
{
namespace apex
{
PX_PUSH_PACK_DEFAULT
///Emitter type
struct EmitterType
{
///Enum of emitter types
enum Enum
{
ET_RATE = 0, ///< use emittion rate to calculate the number of particles
ET_DENSITY_ONCE, ///< emit density particles at once
ET_DENSITY_BRUSH, ///< brush behavior: particles are emitted proportionally to the newly occupied vlume
ET_FILL, ///< fill the volume of the emitter with particles
ET_UNDEFINED,
};
};
class EmitterGeomBox;
class EmitterGeomSphere;
class EmitterGeomSphereShell;
class EmitterGeomCylinder;
class EmitterGeomExplicit;
///Base class for all emitter shapes
class EmitterGeom
{
public:
///Sets the type of the emitter
virtual void setEmitterType(EmitterType::Enum) = 0;
///Gets the type of the emitter
virtual EmitterType::Enum getEmitterType() const = 0;
///If it is a box, cast to box class, return NULL otherwise
virtual const EmitterGeomBox* isBoxGeom() const
{
return NULL;
}
///If it is a sphere, cast to sphere class, return NULL otherwise
virtual const EmitterGeomSphere* isSphereGeom() const
{
return NULL;
}
///If it is a sphere shell, cast to sphere shell class, return NULL otherwise
virtual const EmitterGeomSphereShell* isSphereShellGeom() const
{
return NULL;
}
///If it is a cylinder shell, cast to cylinder class, return NULL otherwise
virtual const EmitterGeomCylinder* isCylinderGeom() const
{
return NULL;
}
///If it is an explicit geom, cast to explicit geom class, return NULL otherwise
virtual const EmitterGeomExplicit* isExplicitGeom() const
{
return NULL;
}
};
///Sphere shell shape for an emitter. It's a shape formed by the difference of two cocentered spheres.
class EmitterGeomSphereShell : public EmitterGeom
{
public:
///Set sphere shell radius
virtual void setRadius(float radius) = 0;
///Get sphere shell radius
virtual float getRadius() const = 0;
///Set sphere shell thickness
virtual void setShellThickness(float thickness) = 0;
///Get sphere shell thickness
virtual float getShellThickness() const = 0;
};
///Spherical shape for an emitter.
class EmitterGeomSphere : public EmitterGeom
{
public:
///Set sphere radius
virtual void setRadius(float radius) = 0;
///Get sphere radius
virtual float getRadius() const = 0;
};
///Cylindrical shape for an emitter.
class EmitterGeomCylinder : public EmitterGeom
{
public:
///Set cylinder radius
virtual void setRadius(float radius) = 0;
///Get cylinder radius
virtual float getRadius() const = 0;
///Set cylinder height
virtual void setHeight(float height) = 0;
///Get cylinder height
virtual float getHeight() const = 0;
};
///Box shape for an emitter.
class EmitterGeomBox : public EmitterGeom
{
public:
///Set box extents
virtual void setExtents(const PxVec3& extents) = 0;
///Get box extents
virtual PxVec3 getExtents() const = 0;
};
///Explicit geometry. Coordinates of each particle are given explicitly.
class EmitterGeomExplicit : public EmitterGeom
{
public:
///Point parameters
struct PointParams
{
PxVec3 position; ///< Point position
bool doDetectOverlaps; ///< Should detect overlap
};
///Sphere prameters
struct SphereParams
{
PxVec3 center; ///< Sphere center
float radius; ///< Sphere radius
bool doDetectOverlaps; ///< Should detect overlap
};
///Ellipsoid parameters
struct EllipsoidParams
{
PxVec3 center; ///< Ellipsoid center
float radius; ///< Ellipsoid radius
PxVec3 normal; ///< Ellipsoid normal
float polarRadius; ///< Ellipsoid polar radius
bool doDetectOverlaps; ///< Should detect overlap
};
///Remove all shapes
virtual void resetParticleList() = 0;
/**
\brief Add particles to geometry to be emitted
\param [in] count - number of particles being added by this call
\param [in] params must be specified. When emitted, these relative positions are added to emitter actor position
\param [in] velocities if NULL, the geometry's velocity list will be padded with zero velocities and the asset's velocityRange will be used for velocity
*/
virtual void addParticleList(uint32_t count,
const PointParams* params,
const PxVec3* velocities = 0) = 0;
/**
\brief Add particles to geometry to be emitted
\param [in] count - number of particles being added by this call
\param [in] positions must be specified. When emitted, these relative positions are added to emitter actor position
\param [in] velocities if NULL, the geometry's velocity list will be padded with zero velocities and the asset's velocityRange will be used for velocity
*/
virtual void addParticleList(uint32_t count,
const PxVec3* positions,
const PxVec3* velocities = 0) = 0;
///Structure contains positions, velocities and user data for particles
struct PointListData
{
const void* positionStart; ///< Pointer to first position
uint32_t positionStrideBytes; ///< The stride between position vectors
const void* velocityStart; ///< Pointer to first velocity
uint32_t velocityStrideBytes; ///< The stride between velocity vectors
const void* userDataStart; ///< Pointer to first instance of user data
uint32_t userDataStrideBytes; ///< The stride between instances of user data
};
/**
\brief Add particles to geometry to be emitted
\param [in] count - number of particles being added by this call
\param [in] data - particles data
\see EmitterGeomExplicit::PointListData
*/
virtual void addParticleList(uint32_t count, const PointListData& data) = 0;
/**
\brief Add spheres to geometry to be emitted
\param [in] count - number of spheres being added by this call
\param [in] params - spheres parameters
\param [in] velocities if NULL, the geometry's velocity list will be padded with zero velocities and the asset's velocityRange will be used for velocity
\see EmitterGeomExplicit::SphereParams
*/
virtual void addSphereList(uint32_t count,
const SphereParams* params,
const PxVec3* velocities = 0) = 0;
/**
\brief Add ellipsoids to geometry to be emitted
\param [in] count - number of ellipsoids being added by this call
\param [in] params - ellipsoids parameters
\param [in] velocities if NULL, the geometry's velocity list will be padded with zero velocities and the asset's velocityRange will be used for velocity
\see EmitterGeomExplicit::EellipsoidParams
*/
virtual void addEllipsoidList(uint32_t count,
const EllipsoidParams* params,
const PxVec3* velocities = 0) = 0;
/**
\brief Access particles list
\param [out] params - particles coordinates
\param [out] numPoints - number of particles in list
\param [out] velocities - particles velocities
\param [out] numVelocities - number of particles velocities in list
\see EmitterGeomExplicit::PointParams
*/
virtual void getParticleList(const PointParams* ¶ms,
uint32_t& numPoints,
const PxVec3* &velocities,
uint32_t& numVelocities) const = 0;
/**
\brief Access spheres list
\param [out] params - spheres parameters
\param [out] numSpheres - number of spheres in list
\param [out] velocities - spheres velocities
\param [out] numVelocities - number of spheres velocities in list
\see EmitterGeomExplicit::SphereParams
*/
virtual void getSphereList(const SphereParams* ¶ms,
uint32_t& numSpheres,
const PxVec3* &velocities,
uint32_t& numVelocities) const = 0;
/**
\brief Access ellipsoids list
\param [out] params - ellipsoids parameters
\param [out] numEllipsoids - number of ellipsoids in list
\param [out] velocities - ellipsoids velocities
\param [out] numVelocities - number of ellipsoids velocities in list
\see EmitterGeomExplicit::EllipsoidParams
*/
virtual void getEllipsoidList(const EllipsoidParams* ¶ms,
uint32_t& numEllipsoids,
const PxVec3* &velocities,
uint32_t& numVelocities) const = 0;
///Get the number of points
virtual uint32_t getParticleCount() const = 0;
///Get the position of point
virtual PxVec3 getParticlePos(uint32_t index) const = 0;
///Get the number of spheres
virtual uint32_t getSphereCount() const = 0;
///Get the center of the sphere
virtual PxVec3 getSphereCenter(uint32_t index) const = 0;
///Get the radius of the sphere
virtual float getSphereRadius(uint32_t index) const = 0;
///Get the number of ellipsoids
virtual uint32_t getEllipsoidCount() const = 0;
///Get the center of the ellipsoid
virtual PxVec3 getEllipsoidCenter(uint32_t index) const = 0;
///Get the radius of the ellipsoid
virtual float getEllipsoidRadius(uint32_t index) const = 0;
///Get the normal of the ellipsoid
virtual PxVec3 getEllipsoidNormal(uint32_t index) const = 0;
///Get the polar radius of the ellipsoid
virtual float getEllipsoidPolarRadius(uint32_t index) const = 0;
///Get average distance between particles
virtual float getDistance() const = 0;
};
PX_POP_PACK
}
} // end namespace nvidia
#endif // EMITTER_GEOMS_H
|