IParticleSystemSceneNode.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED
  5. #define IRR_I_PARTICLE_SYSTEM_SCENE_NODE_H_INCLUDED
  6. #include "ISceneNode.h"
  7. #include "IParticleAnimatedMeshSceneNodeEmitter.h"
  8. #include "IParticleBoxEmitter.h"
  9. #include "IParticleCylinderEmitter.h"
  10. #include "IParticleMeshEmitter.h"
  11. #include "IParticleRingEmitter.h"
  12. #include "IParticleSphereEmitter.h"
  13. #include "IParticleAttractionAffector.h"
  14. #include "IParticleFadeOutAffector.h"
  15. #include "IParticleGravityAffector.h"
  16. #include "IParticleRotationAffector.h"
  17. #include "dimension2d.h"
  18. namespace irr
  19. {
  20. namespace scene
  21. {
  22. //! A particle system scene node for creating snow, fire, explosions, smoke...
  23. /** A scene node controlling a particle System. The behavior of the particles
  24. can be controlled by setting the right particle emitters and affectors.
  25. You can for example easily create a campfire by doing this:
  26. \code
  27. scene::IParticleSystemSceneNode* p = scenemgr->addParticleSystemSceneNode();
  28. p->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f));
  29. scene::IParticleEmitter* em = p->createBoxEmitter(
  30. core::aabbox3d<f32>(-5,0,-5,5,1,5),
  31. core::vector3df(0.0f,0.03f,0.0f),
  32. 40,80, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 1100,2000);
  33. p->setEmitter(em);
  34. em->drop();
  35. scene::IParticleAffector* paf = p->createFadeOutParticleAffector();
  36. p->addAffector(paf);
  37. paf->drop();
  38. \endcode
  39. */
  40. //! Bitflags to control particle behavior
  41. enum EParticleBehavior
  42. {
  43. //! Continue emitting new particles even when the node is invisible
  44. EPB_INVISIBLE_EMITTING = 1,
  45. //! Continue affecting particles even when the node is invisible
  46. EPB_INVISIBLE_AFFECTING = 2,
  47. //! Continue updating particle positions or deleting them even when the node is invisible
  48. EPB_INVISIBLE_ANIMATING = 4,
  49. //! Clear all particles when node gets invisible
  50. EPB_CLEAR_ON_INVISIBLE = 8,
  51. //! Particle movement direction on emitting ignores the node rotation
  52. //! This is mainly to allow backward compatible behavior to Irrlicht 1.8
  53. EPB_EMITTER_VECTOR_IGNORE_ROTATION = 16,
  54. //! On emitting global particles interpolate the positions randomly between the last and current node transformations.
  55. //! This can be set to avoid gaps caused by fast node movement or low framerates, but will be somewhat
  56. //! slower to calculate.
  57. EPB_EMITTER_FRAME_INTERPOLATION = 32
  58. };
  59. class IParticleSystemSceneNode : public ISceneNode
  60. {
  61. public:
  62. //! Constructor
  63. IParticleSystemSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
  64. const core::vector3df& position = core::vector3df(0,0,0),
  65. const core::vector3df& rotation = core::vector3df(0,0,0),
  66. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
  67. : ISceneNode(parent, mgr, id, position, rotation, scale)
  68. , ParticleBehavior(0)
  69. {
  70. }
  71. //! Sets the size of all particles.
  72. virtual void setParticleSize(
  73. const core::dimension2d<f32> &size = core::dimension2d<f32>(5.0f, 5.0f)) = 0;
  74. //! Sets if the particles should be global.
  75. /** If they are, the particles are affected by the movement of the
  76. particle system scene node too, otherwise they completely ignore it.
  77. Default is true. */
  78. virtual void setParticlesAreGlobal(bool global=true) = 0;
  79. //! Bitflags to change the particle behavior
  80. /**
  81. \param flags A combination of ::EParticleBehavior bit-flags. Default is 0. */
  82. virtual void setParticleBehavior(irr::u32 flags)
  83. {
  84. ParticleBehavior = flags;
  85. }
  86. //! Gets how particles behave in different situations
  87. /**
  88. \return A combination of ::EParticleBehavior flags */
  89. virtual irr::u32 getParticleBehavior() const
  90. {
  91. return ParticleBehavior;
  92. }
  93. //! Remove all currently visible particles
  94. virtual void clearParticles() = 0;
  95. //! Do manually update the particles.
  96. /** This should only be called when you want to render the node outside
  97. the scenegraph, as the node will care about this otherwise
  98. automatically. */
  99. virtual void doParticleSystem(u32 time) = 0;
  100. //! Gets the particle emitter, which creates the particles.
  101. /** \return The particle emitter. Can be 0 if none is set. */
  102. virtual IParticleEmitter* getEmitter() =0;
  103. //! Sets the particle emitter, which creates the particles.
  104. /** A particle emitter can be created using one of the createEmitter
  105. methods. For example to create and use a simple PointEmitter, call
  106. IParticleEmitter* p = createPointEmitter(); setEmitter(p); p->drop();
  107. \param emitter: Sets the particle emitter. You can set this to 0 for
  108. removing the current emitter and stopping the particle system emitting
  109. new particles. */
  110. virtual void setEmitter(IParticleEmitter* emitter) = 0;
  111. //! Adds new particle effector to the particle system.
  112. /** A particle affector modifies the particles. For example, the FadeOut
  113. affector lets all particles fade out after some time. It is created and
  114. used in this way:
  115. \code
  116. IParticleAffector* p = createFadeOutParticleAffector();
  117. addAffector(p);
  118. p->drop();
  119. \endcode
  120. Please note that an affector is not necessary for the particle system to
  121. work.
  122. \param affector: New affector. */
  123. virtual void addAffector(IParticleAffector* affector) = 0;
  124. //! Get a list of all particle affectors.
  125. /** \return The list of particle affectors attached to this node. */
  126. virtual const core::list<IParticleAffector*>& getAffectors() const = 0;
  127. //! Removes all particle affectors in the particle system.
  128. virtual void removeAllAffectors() = 0;
  129. //! Creates a particle emitter for an animated mesh scene node
  130. /** \param node: Pointer to the animated mesh scene node to emit
  131. particles from
  132. \param useNormalDirection: If true, the direction of each particle
  133. created will be the normal of the vertex that it's emitting from. The
  134. normal is divided by the normalDirectionModifier parameter, which
  135. defaults to 100.0f.
  136. \param direction: Direction and speed of particle emission.
  137. \param normalDirectionModifier: If the emitter is using the normal
  138. direction then the normal of the vertex that is being emitted from is
  139. divided by this number.
  140. \param mbNumber: This allows you to specify a specific meshBuffer for
  141. the IMesh* to emit particles from. The default value is -1, which
  142. means a random meshBuffer picked from all of the meshes meshBuffers
  143. will be selected to pick a random vertex from. If the value is 0 or
  144. greater, it will only pick random vertices from the meshBuffer
  145. specified by this value.
  146. \param everyMeshVertex: If true, the emitter will emit between min/max
  147. particles every second, for every vertex in the mesh, if false, it will
  148. emit between min/max particles from random vertices in the mesh.
  149. \param minParticlesPerSecond: Minimal amount of particles emitted per
  150. second.
  151. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  152. second.
  153. \param minStartColor: Minimal initial start color of a particle. The
  154. real color of every particle is calculated as random interpolation
  155. between minStartColor and maxStartColor.
  156. \param maxStartColor: Maximal initial start color of a particle. The
  157. real color of every particle is calculated as random interpolation
  158. between minStartColor and maxStartColor.
  159. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  160. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  161. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  162. direction of the particle will differ from the original direction.
  163. \param minStartSize: Minimal initial start size of a particle. The
  164. real size of every particle is calculated as random interpolation
  165. between minStartSize and maxStartSize.
  166. \param maxStartSize: Maximal initial start size of a particle. The
  167. real size of every particle is calculated as random interpolation
  168. between minStartSize and maxStartSize.
  169. \return Pointer to the created particle emitter. To set this emitter
  170. as new emitter of this particle system, just call setEmitter(). Note
  171. that you'll have to drop() the returned pointer, after you don't need
  172. it any more, see IReferenceCounted::drop() for more information. */
  173. virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(
  174. scene::IAnimatedMeshSceneNode* node, bool useNormalDirection = true,
  175. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  176. f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
  177. bool everyMeshVertex = false,
  178. u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
  179. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  180. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  181. u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
  182. s32 maxAngleDegrees = 0,
  183. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  184. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  185. //! Creates a box particle emitter.
  186. /** \param box: The box for the emitter.
  187. \param direction: Direction and speed of particle emission.
  188. \param minParticlesPerSecond: Minimal amount of particles emitted per
  189. second.
  190. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  191. second.
  192. \param minStartColor: Minimal initial start color of a particle. The
  193. real color of every particle is calculated as random interpolation
  194. between minStartColor and maxStartColor.
  195. \param maxStartColor: Maximal initial start color of a particle. The
  196. real color of every particle is calculated as random interpolation
  197. between minStartColor and maxStartColor.
  198. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  199. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  200. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  201. direction of the particle will differ from the original direction.
  202. \param minStartSize: Minimal initial start size of a particle. The
  203. real size of every particle is calculated as random interpolation
  204. between minStartSize and maxStartSize.
  205. \param maxStartSize: Maximal initial start size of a particle. The
  206. real size of every particle is calculated as random interpolation
  207. between minStartSize and maxStartSize.
  208. \return Pointer to the created particle emitter. To set this emitter
  209. as new emitter of this particle system, just call setEmitter(). Note
  210. that you'll have to drop() the returned pointer, after you don't need
  211. it any more, see IReferenceCounted::drop() for more information. */
  212. virtual IParticleBoxEmitter* createBoxEmitter(
  213. const core::aabbox3df& box = core::aabbox3df(-10,28,-10,10,30,10),
  214. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  215. u32 minParticlesPerSecond = 5,
  216. u32 maxParticlesPerSecond = 10,
  217. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  218. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  219. u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
  220. s32 maxAngleDegrees=0,
  221. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  222. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  223. //! Creates a particle emitter for emitting from a cylinder
  224. /** \param center: The center of the circle at the base of the cylinder
  225. \param radius: The thickness of the cylinder
  226. \param normal: Direction of the length of the cylinder
  227. \param length: The length of the the cylinder
  228. \param outlineOnly: Whether or not to put points inside the cylinder or
  229. on the outline only
  230. \param direction: Direction and speed of particle emission.
  231. \param minParticlesPerSecond: Minimal amount of particles emitted per
  232. second.
  233. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  234. second.
  235. \param minStartColor: Minimal initial start color of a particle. The
  236. real color of every particle is calculated as random interpolation
  237. between minStartColor and maxStartColor.
  238. \param maxStartColor: Maximal initial start color of a particle. The
  239. real color of every particle is calculated as random interpolation
  240. between minStartColor and maxStartColor.
  241. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  242. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  243. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  244. direction of the particle will differ from the original direction.
  245. \param minStartSize: Minimal initial start size of a particle. The
  246. real size of every particle is calculated as random interpolation
  247. between minStartSize and maxStartSize.
  248. \param maxStartSize: Maximal initial start size of a particle. The
  249. real size of every particle is calculated as random interpolation
  250. between minStartSize and maxStartSize.
  251. \return Pointer to the created particle emitter. To set this emitter
  252. as new emitter of this particle system, just call setEmitter(). Note
  253. that you'll have to drop() the returned pointer, after you don't need
  254. it any more, see IReferenceCounted::drop() for more information. */
  255. virtual IParticleCylinderEmitter* createCylinderEmitter(
  256. const core::vector3df& center, f32 radius,
  257. const core::vector3df& normal, f32 length,
  258. bool outlineOnly = false,
  259. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  260. u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
  261. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  262. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  263. u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
  264. s32 maxAngleDegrees = 0,
  265. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  266. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  267. //! Creates a mesh particle emitter.
  268. /** \param mesh: Pointer to mesh to emit particles from
  269. \param useNormalDirection: If true, the direction of each particle
  270. created will be the normal of the vertex that it's emitting from. The
  271. normal is divided by the normalDirectionModifier parameter, which
  272. defaults to 100.0f.
  273. \param direction: Direction and speed of particle emission.
  274. \param normalDirectionModifier: If the emitter is using the normal
  275. direction then the normal of the vertex that is being emitted from is
  276. divided by this number.
  277. \param mbNumber: This allows you to specify a specific meshBuffer for
  278. the IMesh* to emit particles from. The default value is -1, which
  279. means a random meshBuffer picked from all of the meshes meshBuffers
  280. will be selected to pick a random vertex from. If the value is 0 or
  281. greater, it will only pick random vertices from the meshBuffer
  282. specified by this value.
  283. \param everyMeshVertex: If true, the emitter will emit between min/max
  284. particles every second, for every vertex in the mesh, if false, it will
  285. emit between min/max particles from random vertices in the mesh.
  286. \param minParticlesPerSecond: Minimal amount of particles emitted per
  287. second.
  288. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  289. second.
  290. \param minStartColor: Minimal initial start color of a particle. The
  291. real color of every particle is calculated as random interpolation
  292. between minStartColor and maxStartColor.
  293. \param maxStartColor: Maximal initial start color of a particle. The
  294. real color of every particle is calculated as random interpolation
  295. between minStartColor and maxStartColor.
  296. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  297. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  298. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  299. direction of the particle will differ from the original direction.
  300. \param minStartSize: Minimal initial start size of a particle. The
  301. real size of every particle is calculated as random interpolation
  302. between minStartSize and maxStartSize.
  303. \param maxStartSize: Maximal initial start size of a particle. The
  304. real size of every particle is calculated as random interpolation
  305. between minStartSize and maxStartSize.
  306. \return Pointer to the created particle emitter. To set this emitter
  307. as new emitter of this particle system, just call setEmitter(). Note
  308. that you'll have to drop() the returned pointer, after you don't need
  309. it any more, see IReferenceCounted::drop() for more information. */
  310. virtual IParticleMeshEmitter* createMeshEmitter(
  311. scene::IMesh* mesh, bool useNormalDirection = true,
  312. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  313. f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
  314. bool everyMeshVertex = false,
  315. u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
  316. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  317. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  318. u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000,
  319. s32 maxAngleDegrees = 0,
  320. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  321. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  322. //! Creates a point particle emitter.
  323. /** \param direction: Direction and speed of particle emission.
  324. \param minParticlesPerSecond: Minimal amount of particles emitted per
  325. second.
  326. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  327. second.
  328. \param minStartColor: Minimal initial start color of a particle. The
  329. real color of every particle is calculated as random interpolation
  330. between minStartColor and maxStartColor.
  331. \param maxStartColor: Maximal initial start color of a particle. The
  332. real color of every particle is calculated as random interpolation
  333. between minStartColor and maxStartColor.
  334. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  335. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  336. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  337. direction of the particle will differ from the original direction.
  338. \param minStartSize: Minimal initial start size of a particle. The
  339. real size of every particle is calculated as random interpolation
  340. between minStartSize and maxStartSize.
  341. \param maxStartSize: Maximal initial start size of a particle. The
  342. real size of every particle is calculated as random interpolation
  343. between minStartSize and maxStartSize.
  344. \return Pointer to the created particle emitter. To set this emitter
  345. as new emitter of this particle system, just call setEmitter(). Note
  346. that you'll have to drop() the returned pointer, after you don't need
  347. it any more, see IReferenceCounted::drop() for more information. */
  348. virtual IParticlePointEmitter* createPointEmitter(
  349. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  350. u32 minParticlesPerSecond = 5,
  351. u32 maxParticlesPerSecond = 10,
  352. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  353. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  354. u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
  355. s32 maxAngleDegrees=0,
  356. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  357. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  358. //! Creates a ring particle emitter.
  359. /** \param center: Center of ring
  360. \param radius: Distance of points from center, points will be rotated
  361. around the Y axis at a random 360 degrees and will then be shifted by
  362. the provided ringThickness values in each axis.
  363. \param ringThickness : thickness of the ring or how wide the ring is
  364. \param direction: Direction and speed of particle emission.
  365. \param minParticlesPerSecond: Minimal amount of particles emitted per
  366. second.
  367. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  368. second.
  369. \param minStartColor: Minimal initial start color of a particle. The
  370. real color of every particle is calculated as random interpolation
  371. between minStartColor and maxStartColor.
  372. \param maxStartColor: Maximal initial start color of a particle. The
  373. real color of every particle is calculated as random interpolation
  374. between minStartColor and maxStartColor.
  375. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  376. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  377. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  378. direction of the particle will differ from the original direction.
  379. \param minStartSize: Minimal initial start size of a particle. The
  380. real size of every particle is calculated as random interpolation
  381. between minStartSize and maxStartSize.
  382. \param maxStartSize: Maximal initial start size of a particle. The
  383. real size of every particle is calculated as random interpolation
  384. between minStartSize and maxStartSize.
  385. \return Pointer to the created particle emitter. To set this emitter
  386. as new emitter of this particle system, just call setEmitter(). Note
  387. that you'll have to drop() the returned pointer, after you don't need
  388. it any more, see IReferenceCounted::drop() for more information. */
  389. virtual IParticleRingEmitter* createRingEmitter(
  390. const core::vector3df& center, f32 radius, f32 ringThickness,
  391. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  392. u32 minParticlesPerSecond = 5,
  393. u32 maxParticlesPerSecond = 10,
  394. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  395. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  396. u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
  397. s32 maxAngleDegrees=0,
  398. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  399. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  400. //! Creates a sphere particle emitter.
  401. /** \param center: Center of sphere
  402. \param radius: Radius of sphere
  403. \param direction: Direction and speed of particle emission.
  404. \param minParticlesPerSecond: Minimal amount of particles emitted per
  405. second.
  406. \param maxParticlesPerSecond: Maximal amount of particles emitted per
  407. second.
  408. \param minStartColor: Minimal initial start color of a particle. The
  409. real color of every particle is calculated as random interpolation
  410. between minStartColor and maxStartColor.
  411. \param maxStartColor: Maximal initial start color of a particle. The
  412. real color of every particle is calculated as random interpolation
  413. between minStartColor and maxStartColor.
  414. \param lifeTimeMin: Minimal lifetime of a particle, in milliseconds.
  415. \param lifeTimeMax: Maximal lifetime of a particle, in milliseconds.
  416. \param maxAngleDegrees: Maximal angle in degrees, the emitting
  417. direction of the particle will differ from the original direction.
  418. \param minStartSize: Minimal initial start size of a particle. The
  419. real size of every particle is calculated as random interpolation
  420. between minStartSize and maxStartSize.
  421. \param maxStartSize: Maximal initial start size of a particle. The
  422. real size of every particle is calculated as random interpolation
  423. between minStartSize and maxStartSize.
  424. \return Pointer to the created particle emitter. To set this emitter
  425. as new emitter of this particle system, just call setEmitter(). Note
  426. that you'll have to drop() the returned pointer, after you don't need
  427. it any more, see IReferenceCounted::drop() for more information. */
  428. virtual IParticleSphereEmitter* createSphereEmitter(
  429. const core::vector3df& center, f32 radius,
  430. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  431. u32 minParticlesPerSecond = 5,
  432. u32 maxParticlesPerSecond = 10,
  433. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  434. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  435. u32 lifeTimeMin=2000, u32 lifeTimeMax=4000,
  436. s32 maxAngleDegrees=0,
  437. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  438. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f) ) = 0;
  439. //! Creates a point attraction affector.
  440. /** This affector modifies the positions of the particles and attracts
  441. them to a specified point at a specified speed per second.
  442. \param point: Point to attract particles to.
  443. \param speed: Speed in units per second, to attract to the specified
  444. point.
  445. \param attract: Whether the particles attract or detract from this
  446. point.
  447. \param affectX: Whether or not this will affect the X position of the
  448. particle.
  449. \param affectY: Whether or not this will affect the Y position of the
  450. particle.
  451. \param affectZ: Whether or not this will affect the Z position of the
  452. particle.
  453. \return Pointer to the created particle affector. To add this affector
  454. as new affector of this particle system, just call addAffector(). Note
  455. that you'll have to drop() the returned pointer, after you don't need
  456. it any more, see IReferenceCounted::drop() for more information. */
  457. virtual IParticleAttractionAffector* createAttractionAffector(
  458. const core::vector3df& point, f32 speed = 1.0f, bool attract = true,
  459. bool affectX = true, bool affectY = true, bool affectZ = true) = 0;
  460. //! Creates a scale particle affector.
  461. /** This affector scales the particle to the a multiple of its size defined
  462. by the scaleTo variable.
  463. \param scaleTo: multiple of the size which the particle will be scaled to until deletion
  464. \return Pointer to the created particle affector.
  465. To add this affector as new affector of this particle system,
  466. just call addAffector(). Note that you'll have to drop() the
  467. returned pointer, after you don't need it any more, see
  468. IReferenceCounted::drop() for more information. */
  469. virtual IParticleAffector* createScaleParticleAffector(const core::dimension2df& scaleTo = core::dimension2df(1.0f, 1.0f)) = 0;
  470. //! Creates a fade out particle affector.
  471. /** This affector modifies the color of every particle and and reaches
  472. the final color when the particle dies. This affector looks really
  473. good, if the EMT_TRANSPARENT_ADD_COLOR material is used and the
  474. targetColor is video::SColor(0,0,0,0): Particles are fading out into
  475. void with this setting.
  476. \param targetColor: Color whereto the color of the particle is changed.
  477. \param timeNeededToFadeOut: How much time in milliseconds should the
  478. affector need to change the color to the targetColor.
  479. \return Pointer to the created particle affector. To add this affector
  480. as new affector of this particle system, just call addAffector(). Note
  481. that you'll have to drop() the returned pointer, after you don't need
  482. it any more, see IReferenceCounted::drop() for more information. */
  483. virtual IParticleFadeOutAffector* createFadeOutParticleAffector(
  484. const video::SColor& targetColor = video::SColor(0,0,0,0),
  485. u32 timeNeededToFadeOut = 1000) = 0;
  486. //! Creates a gravity affector.
  487. /** This affector modifies the direction of the particle. It assumes
  488. that the particle is fired out of the emitter with huge force, but is
  489. loosing this after some time and is caught by the gravity then. This
  490. affector is ideal for creating things like fountains.
  491. \param gravity: Direction and force of gravity.
  492. \param timeForceLost: Time in milliseconds when the force of the
  493. emitter is totally lost and the particle does not move any more. This
  494. is the time where gravity fully affects the particle.
  495. \return Pointer to the created particle affector. To add this affector
  496. as new affector of this particle system, just call addAffector(). Note
  497. that you'll have to drop() the returned pointer, after you don't need
  498. it any more, see IReferenceCounted::drop() for more information. */
  499. virtual IParticleGravityAffector* createGravityAffector(
  500. const core::vector3df& gravity = core::vector3df(0.0f,-0.03f,0.0f),
  501. u32 timeForceLost = 1000) = 0;
  502. //! Creates a rotation affector.
  503. /** This affector modifies the positions of the particles and attracts
  504. them to a specified point at a specified speed per second.
  505. \param speed: Rotation in degrees per second
  506. \param pivotPoint: Point to rotate the particles around
  507. \return Pointer to the created particle affector. To add this affector
  508. as new affector of this particle system, just call addAffector(). Note
  509. that you'll have to drop() the returned pointer, after you don't need
  510. it any more, see IReferenceCounted::drop() for more information. */
  511. virtual IParticleRotationAffector* createRotationAffector(
  512. const core::vector3df& speed = core::vector3df(5.0f,5.0f,5.0f),
  513. const core::vector3df& pivotPoint = core::vector3df(0.0f,0.0f,0.0f) ) = 0;
  514. //! Writes attributes of the scene node.
  515. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const IRR_OVERRIDE
  516. {
  517. out->addInt("ParticleBehavior", ParticleBehavior);
  518. }
  519. //! Reads attributes of the scene node.
  520. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) IRR_OVERRIDE
  521. {
  522. ParticleBehavior = in->getAttributeAsInt("ParticleBehavior", ParticleBehavior);
  523. }
  524. protected:
  525. s32 ParticleBehavior;
  526. };
  527. } // end namespace scene
  528. } // end namespace irr
  529. #endif