1 | #ifndef NX_FLUIDS_NXFLUIDEMITTERDESC
|
---|
2 | #define NX_FLUIDS_NXFLUIDEMITTERDESC
|
---|
3 | /** \addtogroup fluids
|
---|
4 | @{
|
---|
5 | */
|
---|
6 | /*----------------------------------------------------------------------------*\
|
---|
7 | |
|
---|
8 | | Public Interface to NovodeX Technology
|
---|
9 | |
|
---|
10 | | www.novodex.com
|
---|
11 | |
|
---|
12 | \*----------------------------------------------------------------------------*/
|
---|
13 |
|
---|
14 | /**
|
---|
15 | \brief Flags which control the behavior of fluid emitters.
|
---|
16 |
|
---|
17 | \warning <b>Preliminary API, subject to change</b>
|
---|
18 |
|
---|
19 | @see NxFluidEmitter
|
---|
20 | */
|
---|
21 | enum NxFluidEmitterFlag
|
---|
22 | {
|
---|
23 | /**
|
---|
24 | \brief Flags whether the emitter should be visualized for debugging or not.
|
---|
25 | */
|
---|
26 | NX_FEF_VISUALIZATION = (1<<0),
|
---|
27 |
|
---|
28 | /**
|
---|
29 | \brief The emitter may reference an NxActor instance in order to maintain a relative coordinate
|
---|
30 | frame.
|
---|
31 |
|
---|
32 | If this NxActor instance is released, the NX_FEF_BROKEN_ACTOR_REF flag is set.
|
---|
33 | */
|
---|
34 | NX_FEF_BROKEN_ACTOR_REF = (1<<1),
|
---|
35 |
|
---|
36 | /**
|
---|
37 | \brief This flag specifies whether the emission should cause a force on
|
---|
38 | the actor that the emitter is attached to.
|
---|
39 | */
|
---|
40 | NX_FEF_FORCE_ON_ACTOR = (1<<2),
|
---|
41 |
|
---|
42 | /**
|
---|
43 | \brief If set, the velocity of the emitter is added to the emitted particle velocity.
|
---|
44 |
|
---|
45 | This is the default behaviour.
|
---|
46 | */
|
---|
47 | NX_FEF_ADD_ACTOR_VELOCITY = (1<<3),
|
---|
48 |
|
---|
49 | /**
|
---|
50 | \brief Flag to start and stop the emission. On default the emission is enabled.
|
---|
51 | */
|
---|
52 | NX_FEF_ENABLED = (1<<4),
|
---|
53 | };
|
---|
54 |
|
---|
55 | /**
|
---|
56 | \brief Flags to specify the shape of the area of emission.
|
---|
57 |
|
---|
58 | Exactly one flag should be set at any time.
|
---|
59 |
|
---|
60 | \warning <b>Preliminary API, subject to change</b>
|
---|
61 | */
|
---|
62 | enum NxEmitterShape
|
---|
63 | {
|
---|
64 | NX_FE_RECTANGULAR = (1<<0),
|
---|
65 | NX_FE_ELLIPSE = (1<<1)
|
---|
66 | };
|
---|
67 |
|
---|
68 | /**
|
---|
69 | \brief Flags to specify the emitter's type of operation.
|
---|
70 | Exactly one flag should be set at any time.
|
---|
71 |
|
---|
72 | \warning <b>Preliminary API, subject to change</b>
|
---|
73 |
|
---|
74 | @see NxFluidEmitter
|
---|
75 | */
|
---|
76 | enum NxEmitterType
|
---|
77 | {
|
---|
78 | NX_FE_CONSTANT_PRESSURE = (1<<0),
|
---|
79 | NX_FE_CONSTANT_FLOW_RATE = (1<<1)
|
---|
80 | };
|
---|
81 |
|
---|
82 | #include "fluids/NxFluidEmitter.h"
|
---|
83 |
|
---|
84 | /**
|
---|
85 | \brief Descriptor for NxFluidEmitter class. Used for saving and loading the emitter state.
|
---|
86 |
|
---|
87 | \warning <b>Preliminary API, subject to change</b>
|
---|
88 | */
|
---|
89 | class NxFluidEmitterDesc
|
---|
90 | {
|
---|
91 | public:
|
---|
92 |
|
---|
93 | /**
|
---|
94 | \brief The emitter's pose relative to the frame actor's coordinate frame, or the world, if the frame
|
---|
95 | actor is set to NULL.
|
---|
96 |
|
---|
97 | The third axis of the orientation frame sets the flow direction.
|
---|
98 |
|
---|
99 | \warning <b>Preliminary API, subject to change</b>
|
---|
100 | */
|
---|
101 | NxMat34 relPose;
|
---|
102 |
|
---|
103 | /**
|
---|
104 | \brief A pointer to the NxActor to which the emitter is attached to.
|
---|
105 |
|
---|
106 | If this pointer is set to NULL, the emitter is attached to the world frame. The actor
|
---|
107 | must be in the same scene as the emitter.
|
---|
108 |
|
---|
109 | \warning <b>Preliminary API, subject to change</b>
|
---|
110 | */
|
---|
111 | NxActor* frameActor;
|
---|
112 |
|
---|
113 | /**
|
---|
114 | \brief The emitter's mode of operation.
|
---|
115 |
|
---|
116 | Either the simulation enforces constant pressure or constant flow rate at the emission site,
|
---|
117 | given the velocity of emitted particles.
|
---|
118 |
|
---|
119 | \warning <b>Preliminary API, subject to change</b>
|
---|
120 |
|
---|
121 | @see NxEmitterType
|
---|
122 | */
|
---|
123 | NxU32 type;
|
---|
124 |
|
---|
125 | /**
|
---|
126 | \brief The maximum number of particles which are emitted from this emitter.
|
---|
127 |
|
---|
128 | If the total number of particles in the fluid already hit the maxParticles parameter of the fluid,
|
---|
129 | this maximal values can't be reached.
|
---|
130 |
|
---|
131 | If set to 0, the number of emitted particles is unrestricted.
|
---|
132 |
|
---|
133 | \warning <b>Preliminary API, subject to change</b>
|
---|
134 | */
|
---|
135 | NxU32 maxParticles;
|
---|
136 |
|
---|
137 | /**
|
---|
138 | \brief The emitter's shape can either be rectangular or elliptical.
|
---|
139 |
|
---|
140 | \warning <b>Preliminary API, subject to change</b>
|
---|
141 |
|
---|
142 | @see NxEmitterShape
|
---|
143 | */
|
---|
144 | NxU32 shape;
|
---|
145 |
|
---|
146 | /**
|
---|
147 | \brief The sizes of the emitter in the directions of the first and the second axis of its orientation
|
---|
148 | frame (relPose).
|
---|
149 |
|
---|
150 | The dimensions are actually the radii of the size.
|
---|
151 |
|
---|
152 | \warning <b>Preliminary API, subject to change</b>
|
---|
153 |
|
---|
154 | */
|
---|
155 | NxReal dimensionX;
|
---|
156 | NxReal dimensionY;
|
---|
157 |
|
---|
158 | /**
|
---|
159 | \brief Random vector with values for each axis direction of the emitter orientation.
|
---|
160 |
|
---|
161 | The values have to be positive and describe the maximal random particle displacement in each dimension.
|
---|
162 |
|
---|
163 | The z value describes the randomization in emission direction. The emission direction
|
---|
164 | is specified by the third orientation axis of relPose.
|
---|
165 |
|
---|
166 | \warning <b>Preliminary API, subject to change</b>
|
---|
167 | */
|
---|
168 | NxVec3 randomPos;
|
---|
169 |
|
---|
170 | /**
|
---|
171 | \brief Random angle deviation from emission direction.
|
---|
172 |
|
---|
173 | The emission direction is specified by the third orientation axis of relPose.
|
---|
174 |
|
---|
175 | <b>Unit:</b> Radians
|
---|
176 |
|
---|
177 | \warning <b>Preliminary API, subject to change</b>
|
---|
178 | */
|
---|
179 | NxReal randomAngle;
|
---|
180 |
|
---|
181 | /**
|
---|
182 | \brief The velocity magnitude of the emitted fluid particles.
|
---|
183 |
|
---|
184 | \warning <b>Preliminary API, subject to change</b>
|
---|
185 | */
|
---|
186 | NxReal fluidVelocityMagnitude;
|
---|
187 |
|
---|
188 | /**
|
---|
189 | \brief The rate specifies how many particles are emitted per second.
|
---|
190 |
|
---|
191 | The rate is only considered in the simulation if the type is set to NX_FE_CONSTANT_FLOW_RATE.
|
---|
192 |
|
---|
193 | \warning <b>Preliminary API, subject to change</b>
|
---|
194 |
|
---|
195 | @see NxEmitterType
|
---|
196 | */
|
---|
197 | NxReal rate;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | \brief This specifies the time in seconds an emitted particle lives.
|
---|
201 |
|
---|
202 | If set to 0, each particle will live until it collides with a drain.
|
---|
203 |
|
---|
204 | \warning <b>Preliminary API, subject to change</b>
|
---|
205 | */
|
---|
206 | NxReal particleLifetime;
|
---|
207 |
|
---|
208 | /**
|
---|
209 | \brief A combination of NxFluidEmitterFlags.
|
---|
210 |
|
---|
211 | \warning <b>Preliminary API, subject to change</b>
|
---|
212 |
|
---|
213 | @see NxFluidEmitterFlags
|
---|
214 | */
|
---|
215 | NxU32 flags;
|
---|
216 |
|
---|
217 | void* userData; //!< Will be copied to NxShape::userData.
|
---|
218 | const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored.
|
---|
219 |
|
---|
220 | NX_INLINE ~NxFluidEmitterDesc();
|
---|
221 | /**
|
---|
222 | \brief (Re)sets the structure to the default.
|
---|
223 |
|
---|
224 | \warning <b>Preliminary API, subject to change</b>
|
---|
225 | */
|
---|
226 | NX_INLINE void setToDefault();
|
---|
227 | /**
|
---|
228 | \brief Returns true if the current settings are valid
|
---|
229 |
|
---|
230 | \warning <b>Preliminary API, subject to change</b>
|
---|
231 | */
|
---|
232 | NX_INLINE bool isValid() const;
|
---|
233 |
|
---|
234 | /**
|
---|
235 | \brief Constructor sets to default.
|
---|
236 |
|
---|
237 | \warning <b>Preliminary API, subject to change</b>
|
---|
238 | */
|
---|
239 | NX_INLINE NxFluidEmitterDesc();
|
---|
240 | };
|
---|
241 |
|
---|
242 |
|
---|
243 | NX_INLINE NxFluidEmitterDesc::NxFluidEmitterDesc()
|
---|
244 | {
|
---|
245 | setToDefault();
|
---|
246 | }
|
---|
247 |
|
---|
248 | NX_INLINE NxFluidEmitterDesc::~NxFluidEmitterDesc()
|
---|
249 | {
|
---|
250 | }
|
---|
251 |
|
---|
252 | NX_INLINE void NxFluidEmitterDesc::setToDefault()
|
---|
253 | {
|
---|
254 | relPose .id();
|
---|
255 | frameActor = NULL;
|
---|
256 | type = NX_FE_CONSTANT_PRESSURE;
|
---|
257 | maxParticles = 0;
|
---|
258 | shape = NX_FE_RECTANGULAR;
|
---|
259 | dimensionX = 1.0f;
|
---|
260 | dimensionY = 1.0f;
|
---|
261 | randomPos .zero();
|
---|
262 | randomAngle = 0.0f;
|
---|
263 | fluidVelocityMagnitude = 1.0f;
|
---|
264 | rate = 100.0f;
|
---|
265 | particleLifetime = 0.0f;
|
---|
266 | flags = NX_FEF_ENABLED|NX_FEF_VISUALIZATION|NX_FEF_ADD_ACTOR_VELOCITY;
|
---|
267 |
|
---|
268 | userData = NULL;
|
---|
269 | name = NULL;
|
---|
270 | }
|
---|
271 |
|
---|
272 | NX_INLINE bool NxFluidEmitterDesc::isValid() const
|
---|
273 | {
|
---|
274 | if (!relPose.isFinite()) return false;
|
---|
275 |
|
---|
276 | if (dimensionX < 0.0f) return false;
|
---|
277 | if (dimensionY < 0.0f) return false;
|
---|
278 |
|
---|
279 | if (randomPos.x < 0.0f) return false;
|
---|
280 | if (randomPos.y < 0.0f) return false;
|
---|
281 | if (randomPos.z < 0.0f) return false;
|
---|
282 | if (!randomPos.isFinite()) return false;
|
---|
283 |
|
---|
284 | if (randomAngle < 0.0f) return false;
|
---|
285 |
|
---|
286 | if (flags & NX_FEF_BROKEN_ACTOR_REF) return false;
|
---|
287 | if (!((shape & NX_FE_ELLIPSE) ^ (shape & NX_FE_RECTANGULAR))) return false;
|
---|
288 | if (!((type & NX_FE_CONSTANT_FLOW_RATE) ^ (type & NX_FE_CONSTANT_PRESSURE))) return false;
|
---|
289 |
|
---|
290 | if (rate < 0.0f) return false;
|
---|
291 | if (fluidVelocityMagnitude < 0.0f) return false;
|
---|
292 | if (particleLifetime < 0.0f) return false;
|
---|
293 |
|
---|
294 | return true;
|
---|
295 | }
|
---|
296 |
|
---|
297 | /** @} */
|
---|
298 | #endif
|
---|
299 |
|
---|
300 |
|
---|
301 | //AGCOPYRIGHTBEGIN
|
---|
302 | ///////////////////////////////////////////////////////////////////////////
|
---|
303 | // Copyright © 2005 AGEIA Technologies.
|
---|
304 | // All rights reserved. www.ageia.com
|
---|
305 | ///////////////////////////////////////////////////////////////////////////
|
---|
306 | //AGCOPYRIGHTEND
|
---|
307 |
|
---|