/usr/include/OGRE/OgreParticleSystem.h is in libogre-1.9-dev 1.9.0+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __ParticleSystem_H__
#define __ParticleSystem_H__
#include "OgrePrerequisites.h"
#include "OgreVector3.h"
#include "OgreString.h"
#include "OgreParticleIterator.h"
#include "OgreStringInterface.h"
#include "OgreMovableObject.h"
#include "OgreRadixSort.h"
#include "OgreController.h"
#include "OgreResourceGroupManager.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup Effects
* @{
*/
/** Class defining particle system based special effects.
@remarks
Particle systems are special effects generators which are based on a
number of moving points to create the impression of things like like
sparkles, smoke, blood spurts, dust etc.
@par
This class simply manages a single collection of particles in world space
with a shared local origin for emission. The visual aspect of the
particles is handled by a ParticleSystemRenderer instance.
@par
Particle systems are created using the SceneManager, never directly.
In addition, like all subclasses of MovableObject, the ParticleSystem
will only be considered for rendering once it has been attached to a
SceneNode.
*/
class _OgreExport ParticleSystem : public StringInterface, public MovableObject
{
public:
/** Command object for quota (see ParamCommand).*/
class _OgrePrivate CmdQuota : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for emittedEmitterQuota (see ParamCommand).*/
class _OgrePrivate CmdEmittedEmitterQuota : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for material (see ParamCommand).*/
class _OgrePrivate CmdMaterial : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for cull_each (see ParamCommand).*/
class _OgrePrivate CmdCull : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for particle_width (see ParamCommand).*/
class _OgrePrivate CmdWidth : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for particle_height (see ParamCommand).*/
class _OgrePrivate CmdHeight : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for renderer (see ParamCommand).*/
class _OgrePrivate CmdRenderer : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for sorting (see ParamCommand).*/
class CmdSorted : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for local space (see ParamCommand).*/
class CmdLocalSpace : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for iteration interval(see ParamCommand).*/
class CmdIterationInterval : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/** Command object for nonvisible timeout (see ParamCommand).*/
class CmdNonvisibleTimeout : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Default constructor required for STL creation in manager
ParticleSystem();
/** Creates a particle system with no emitters or affectors.
@remarks
You should use the ParticleSystemManager to create particle systems rather than creating
them directly.
*/
ParticleSystem(const String& name, const String& resourceGroupName);
virtual ~ParticleSystem();
/** Sets the ParticleRenderer to be used to render this particle system.
@remarks
The main ParticleSystem just manages the creation and movement of
particles; they are rendered using functions in ParticleRenderer
and the ParticleVisual instances they create.
@param typeName String identifying the type of renderer to use; a new
instance of this type will be created; a factory must have been registered
with ParticleSystemManager.
*/
void setRenderer(const String& typeName);
/** Gets the ParticleRenderer to be used to render this particle system. */
ParticleSystemRenderer* getRenderer(void) const;
/** Gets the name of the ParticleRenderer to be used to render this particle system. */
const String& getRendererName(void) const;
/** Adds an emitter to this particle system.
@remarks
Particles are created in a particle system by emitters - see the ParticleEmitter
class for more details.
@param
emitterType String identifying the emitter type to create. Emitter types are defined
by registering new factories with the manager - see ParticleEmitterFactory for more details.
Emitter types can be extended by OGRE, plugin authors or application developers.
*/
ParticleEmitter* addEmitter(const String& emitterType);
/** Retrieves an emitter by it's index (zero-based).
@remarks
Used to retrieve a pointer to an emitter for a particle system to procedurally change
emission parameters etc.
You should check how many emitters are registered against this system before calling
this method with an arbitrary index using getNumEmitters.
@param
index Zero-based index of the emitter to retrieve.
*/
ParticleEmitter* getEmitter(unsigned short index) const;
/** Returns the number of emitters for this particle system. */
unsigned short getNumEmitters(void) const;
/** Removes an emitter from the system.
@remarks
Drops the emitter with the index specified from this system.
You should check how many emitters are registered against this system before calling
this method with an arbitrary index using getNumEmitters.
@param
index Zero-based index of the emitter to retrieve.
*/
void removeEmitter(unsigned short index);
/** Removes all the emitters from this system. */
void removeAllEmitters(void);
/** Adds an affector to this particle system.
@remarks
Particles are modified over time in a particle system by affectors - see the ParticleAffector
class for more details.
@param
affectorType String identifying the affector type to create. Affector types are defined
by registering new factories with the manager - see ParticleAffectorFactory for more details.
Affector types can be extended by OGRE, plugin authors or application developers.
*/
ParticleAffector* addAffector(const String& affectorType);
/** Retrieves an affector by it's index (zero-based).
@remarks
Used to retrieve a pointer to an affector for a particle system to procedurally change
affector parameters etc.
You should check how many affectors are registered against this system before calling
this method with an arbitrary index using getNumAffectors.
@param
index Zero-based index of the affector to retrieve.
*/
ParticleAffector* getAffector(unsigned short index) const;
/** Returns the number of affectors for this particle system. */
unsigned short getNumAffectors(void) const;
/** Removes an affector from the system.
@remarks
Drops the affector with the index specified from this system.
You should check how many affectors are registered against this system before calling
this method with an arbitrary index using getNumAffectors.
@param
index Zero-based index of the affector to retrieve.
*/
void removeAffector(unsigned short index);
/** Removes all the affectors from this system. */
void removeAllAffectors(void);
/** Empties this set of all particles.
*/
void clear();
/** Gets the number of individual particles in the system right now.
@remarks
The number of particles active in a system at a point in time depends on
the number of emitters, their emission rates, the time-to-live (TTL) each particle is
given on emission (and whether any affectors modify that TTL) and the maximum
number of particles allowed in this system at once (particle quota).
*/
size_t getNumParticles(void) const;
/** Manually add a particle to the system.
@remarks
Instead of using an emitter, you can manually add a particle to the system.
You must initialise the returned particle instance immediately with the
'emission' state.
@note
There is no corresponding 'destroyParticle' method - if you want to dispose of a
particle manually (say, if you've used setSpeedFactor(0) to make particles live forever)
you should use getParticle() and modify it's timeToLive to zero, meaning that it will
get cleaned up in the next update.
*/
Particle* createParticle(void);
/** Manually add an emitter particle to the system.
@remarks
The purpose of a particle emitter is to emit particles. Besides visual particles, also other other
particle types can be emitted, other emitters for example. The emitted emitters have a double role;
they behave as particles and can be influenced by affectors, but they are still emitters and capable
to emit other particles (or emitters). It is possible to create a chain of emitters - emitters
emitting other emitters, which also emit emitters.
@param emitterName The name of a particle emitter that must be emitted.
*/
Particle* createEmitterParticle(const String& emitterName);
/** Retrieve a particle from the system for manual tweaking.
@remarks
Normally you use an affector to alter particles in flight, but
for small manually controlled particle systems you might want to use
this method.
*/
Particle* getParticle(size_t index);
/** Returns the maximum number of particles this system is allowed to have active at once.
@remarks
See ParticleSystem::setParticleQuota for more info.
*/
size_t getParticleQuota(void) const;
/** Sets the maximum number of particles this system is allowed to have active at once.
@remarks
Particle systems all have a particle quota, i.e. a maximum number of particles they are
allowed to have active at a time. This allows the application to set a keep particle systems
under control should they be affected by complex parameters which alter their emission rates
etc. If a particle system reaches it's particle quota, none of the emitters will be able to
emit any more particles. As existing particles die, the spare capacity will be allocated
equally across all emitters to be as consistent to the original particle system style as possible.
The quota can be increased but not decreased after the system has been created.
@param quota The maximum number of particles this system is allowed to have.
*/
void setParticleQuota(size_t quota);
/** Returns the maximum number of emitted emitters this system is allowed to have active at once.
@remarks
See ParticleSystem::setEmittedEmitterQuota for more info.
*/
size_t getEmittedEmitterQuota(void) const;
/** Sets the maximum number of emitted emitters this system is allowed to have active at once.
@remarks
Particle systems can have - besides a particle quota - also an emitted emitter quota.
@param quota The maximum number of emitted emitters this system is allowed to have.
*/
void setEmittedEmitterQuota(size_t quota);
/** Assignment operator for copying.
@remarks
This operator deep copies all particle emitters and effectors, but not particles. The
system's name is also not copied.
*/
ParticleSystem& operator=(const ParticleSystem& rhs);
/** Updates the particles in the system based on time elapsed.
@remarks
This is called automatically every frame by OGRE.
@param
timeElapsed The amount of time, in seconds, since the last frame.
*/
void _update(Real timeElapsed);
/** Returns an iterator for stepping through all particles in this system.
@remarks
This method is designed to be used by people providing new ParticleAffector subclasses,
this is the easiest way to step through all the particles in a system and apply the
changes the affector wants to make.
*/
ParticleIterator _getIterator(void);
/** Sets the name of the material to be used for this billboard set.
@param
name The new name of the material to use for this set.
*/
virtual void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
/** Sets the name of the material to be used for this billboard set.
@return The name of the material that is used for this set.
*/
virtual const String& getMaterialName(void) const;
/** Overridden from MovableObject
@see
MovableObject
*/
virtual void _notifyCurrentCamera(Camera* cam);
/** Overridden from MovableObject
@see
MovableObject
*/
void _notifyAttached(Node* parent, bool isTagPoint = false);
/** Overridden from MovableObject
@see
MovableObject
*/
virtual const AxisAlignedBox& getBoundingBox(void) const { return mAABB; }
/** Overridden from MovableObject
@see
MovableObject
*/
virtual Real getBoundingRadius(void) const { return mBoundingRadius; }
/** Overridden from MovableObject
@see
MovableObject
*/
virtual void _updateRenderQueue(RenderQueue* queue);
/// @copydoc MovableObject::visitRenderables
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
/** Fast-forwards this system by the required number of seconds.
@remarks
This method allows you to fast-forward a system so that it effectively looks like
it has already been running for the time you specify. This is useful to avoid the
'startup sequence' of a system, when you want the system to be fully populated right
from the start.
@param
time The number of seconds to fast-forward by.
@param
interval The sampling interval used to generate particles, apply affectors etc. The lower this
is the more realistic the fast-forward, but it takes more iterations to do it.
*/
void fastForward(Real time, Real interval = 0.1);
/** Sets a 'speed factor' on this particle system, which means it scales the elapsed
real time which has passed by this factor before passing it to the emitters, affectors,
and the particle life calculation.
@remarks
An interesting side effect - if you want to create a completely manual particle system
where you control the emission and life of particles yourself, you can set the speed
factor to 0.0f, thus disabling normal particle emission, alteration, and death.
*/
void setSpeedFactor(Real speedFactor) { mSpeedFactor = speedFactor; }
/** Gets the 'speed factor' on this particle system.
*/
Real getSpeedFactor(void) const { return mSpeedFactor; }
/** Sets a 'iteration interval' on this particle system.
@remarks
The default Particle system update interval, based on elapsed frame time,
will cause different behavior between low frame-rate and high frame-rate.
By using this option, you can make the particle system update at
a fixed interval, keeping the behavior the same no matter what frame-rate
is.
@par
When iteration interval is set to zero, it means the update occurs based
on an elapsed frame time, otherwise each iteration will take place
at the given interval, repeating until it has used up all the elapsed
frame time.
@param
iterationInterval The iteration interval, default to zero.
*/
void setIterationInterval(Real iterationInterval);
/** Gets a 'iteration interval' on this particle system.
*/
Real getIterationInterval(void) const { return mIterationInterval; }
/** Set the default iteration interval for all ParticleSystem instances.
*/
static void setDefaultIterationInterval(Real iterationInterval) { msDefaultIterationInterval = iterationInterval; }
/** Get the default iteration interval for all ParticleSystem instances.
*/
static Real getDefaultIterationInterval(void) { return msDefaultIterationInterval; }
/** Sets when the particle system should stop updating after it hasn't been
visible for a while.
@remarks
By default, visible particle systems update all the time, even when
not in view. This means that they are guaranteed to be consistent when
they do enter view. However, this comes at a cost, updating particle
systems can be expensive, especially if they are perpetual.
@par
This option lets you set a 'timeout' on the particle system, so that
if it isn't visible for this amount of time, it will stop updating
until it is next visible.
@param timeout The time after which the particle system will be disabled
if it is no longer visible. 0 to disable the timeout and always update.
*/
void setNonVisibleUpdateTimeout(Real timeout);
/** Gets when the particle system should stop updating after it hasn't been
visible for a while.
*/
Real getNonVisibleUpdateTimeout(void) const { return mNonvisibleTimeout; }
/** Set the default nonvisible timeout for all ParticleSystem instances.
*/
static void setDefaultNonVisibleUpdateTimeout(Real timeout)
{ msDefaultNonvisibleTimeout = timeout; }
/** Get the default nonvisible timeout for all ParticleSystem instances.
*/
static Real getDefaultNonVisibleUpdateTimeout(void) { return msDefaultNonvisibleTimeout; }
/** Overridden from MovableObject */
const String& getMovableType(void) const;
/** Internal callback used by Particles to notify their parent that they have been resized.
*/
virtual void _notifyParticleResized(void);
/** Internal callback used by Particles to notify their parent that they have been rotated.
*/
virtual void _notifyParticleRotated(void);
/** Sets the default dimensions of the particles in this set.
@remarks
All particles in a set are created with these default dimensions. The set will render most efficiently if
all the particles in the set are the default size. It is possible to alter the size of individual
particles at the expense of extra calculation. See the Particle class for more info.
@param width
The new default width for the particles in this set.
@param height
The new default height for the particles in this set.
*/
virtual void setDefaultDimensions(Real width, Real height);
/** See setDefaultDimensions - this sets 1 component individually. */
virtual void setDefaultWidth(Real width);
/** See setDefaultDimensions - this gets 1 component individually. */
virtual Real getDefaultWidth(void) const;
/** See setDefaultDimensions - this sets 1 component individually. */
virtual void setDefaultHeight(Real height);
/** See setDefaultDimensions - this gets 1 component individually. */
virtual Real getDefaultHeight(void) const;
/** Returns whether or not particles in this are tested individually for culling. */
virtual bool getCullIndividually(void) const;
/** Sets whether culling tests particles in this individually as well as in a group.
@remarks
Particle sets are always culled as a whole group, based on a bounding box which
encloses all particles in the set. For fairly localised sets, this is enough. However, you
can optionally tell the set to also cull individual particles in the set, i.e. to test
each individual particle before rendering. The default is not to do this.
@par
This is useful when you have a large, fairly distributed set of particles, like maybe
trees on a landscape. You probably still want to group them into more than one
set (maybe one set per section of landscape), which will be culled coarsely, but you also
want to cull the particles individually because they are spread out. Whilst you could have
lots of single-tree sets which are culled separately, this would be inefficient to render
because each tree would be issued as it's own rendering operation.
@par
By calling this method with a parameter of true, you can have large particle sets which
are spaced out and so get the benefit of batch rendering and coarse culling, but also have
fine-grained culling so unnecessary rendering is avoided.
@param cullIndividual If true, each particle is tested before being sent to the pipeline as well
as the whole set having to pass the coarse group bounding test.
*/
virtual void setCullIndividually(bool cullIndividual);
/// Return the resource group to be used to load dependent resources
virtual const String& getResourceGroupName(void) const { return mResourceGroupName; }
/** Get the origin of this particle system, e.g. a script file name.
@remarks
This property will only contain something if the creator of
this particle system chose to populate it. Script loaders are advised
to populate it.
*/
const String& getOrigin(void) const { return mOrigin; }
/// Notify this particle system of it's origin
void _notifyOrigin(const String& origin) { mOrigin = origin; }
/** @copydoc MovableObject::setRenderQueueGroup */
void setRenderQueueGroup(uint8 queueID);
/** @copydoc MovableObject::setRenderQueueGroupAndPriority */
void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
/** Set whether or not particles are sorted according to the camera.
@remarks
Enabling sorting alters the order particles are sent to the renderer.
When enabled, particles are sent to the renderer in order of
furthest distance from the camera.
*/
void setSortingEnabled(bool enabled) { mSorted = enabled; }
/// Gets whether particles are sorted relative to the camera.
bool getSortingEnabled(void) const { return mSorted; }
/** Set the (initial) bounds of the particle system manually.
@remarks
If you can, set the bounds of a particle system up-front and
call setBoundsAutoUpdated(false); this is the most efficient way to
organise it. Otherwise, set an initial bounds and let the bounds increase
for a little while (the default is 5 seconds), after which time the
AABB is fixed to save time.
@param aabb Bounds in local space.
*/
void setBounds(const AxisAlignedBox& aabb);
/** Sets whether the bounds will be automatically updated
for the life of the particle system
@remarks
If you have a stationary particle system, it would be a good idea to
call this method and set the value to 'false', since the maximum
bounds of the particle system will eventually be static. If you do
this, you can either set the bounds manually using the setBounds()
method, or set the second parameter of this method to a positive
number of seconds, so that the bounds are calculated for a few
seconds and then frozen.
@param autoUpdate If true (the default), the particle system will
update it's bounds every frame. If false, the bounds update will
cease after the 'stopIn' number of seconds have passed.
@param stopIn Only applicable if the first parameter is true, this is the
number of seconds after which the automatic update will cease.
*/
void setBoundsAutoUpdated(bool autoUpdate, Real stopIn = 0.0f);
/** Sets whether particles (and any affector effects) remain relative
to the node the particle system is attached to.
@remarks
By default particles are in world space once emitted, so they are not
affected by movement in the parent node of the particle system. This
makes the most sense when dealing with completely independent particles,
but if you want to constrain them to follow local motion too, you
can set this to true.
*/
void setKeepParticlesInLocalSpace(bool keepLocal);
/** Gets whether particles (and any affector effects) remain relative
to the node the particle system is attached to.
*/
bool getKeepParticlesInLocalSpace(void) const { return mLocalSpace; }
/** Internal method for updating the bounds of the particle system.
@remarks
This is called automatically for a period of time after the system's
creation (10 seconds by default, settable by setBoundsAutoUpdated)
to increase (and only increase) the bounds of the system according
to the emitted and affected particles. After this period, the
system is assumed to achieved its maximum size, and the bounds are
no longer computed for efficiency. You can tweak the behaviour by
either setting the bounds manually (setBounds, preferred), or
changing the time over which the bounds are updated (performance cost).
You can also call this method manually if you need to update the
bounds on an ad-hoc basis.
*/
void _updateBounds(void);
/** This is used to turn on or off particle emission for this system.
@remarks
By default particle system is always emitting particles (if a emitters exists)
and this can be used to stop the emission for all emitters. To turn it on again,
call it passing true.
Note that this does not detach the particle system from the scene node, it will
still use some CPU.
*/
void setEmitting(bool v);
/** Returns true if the particle system emitting flag is turned on.
@remarks
This function will not actually return whether the particles are being emitted.
It only returns the value of emitting flag.
*/
bool getEmitting() const;
/// Override to return specific type flag
uint32 getTypeFlags(void) const;
protected:
/// Command objects
static CmdCull msCullCmd;
static CmdHeight msHeightCmd;
static CmdMaterial msMaterialCmd;
static CmdQuota msQuotaCmd;
static CmdEmittedEmitterQuota msEmittedEmitterQuotaCmd;
static CmdWidth msWidthCmd;
static CmdRenderer msRendererCmd;
static CmdSorted msSortedCmd;
static CmdLocalSpace msLocalSpaceCmd;
static CmdIterationInterval msIterationIntervalCmd;
static CmdNonvisibleTimeout msNonvisibleTimeoutCmd;
AxisAlignedBox mAABB;
Real mBoundingRadius;
bool mBoundsAutoUpdate;
Real mBoundsUpdateTime;
Real mUpdateRemainTime;
/// World AABB, only used to compare world-space positions to calc bounds
AxisAlignedBox mWorldAABB;
/// Name of the resource group to use to load materials
String mResourceGroupName;
/// Name of the material to use
String mMaterialName;
/// Have we set the material etc on the renderer?
bool mIsRendererConfigured;
/// Pointer to the material to use
MaterialPtr mMaterial;
/// Default width of each particle
Real mDefaultWidth;
/// Default height of each particle
Real mDefaultHeight;
/// Speed factor
Real mSpeedFactor;
/// Iteration interval
Real mIterationInterval;
/// Iteration interval set? Otherwise track default
bool mIterationIntervalSet;
/// Particles sorted according to camera?
bool mSorted;
/// Particles in local space?
bool mLocalSpace;
/// Update timeout when nonvisible (0 for no timeout)
Real mNonvisibleTimeout;
/// Update timeout when nonvisible set? Otherwise track default
bool mNonvisibleTimeoutSet;
/// Amount of time non-visible so far
Real mTimeSinceLastVisible;
/// Last frame in which known to be visible
unsigned long mLastVisibleFrame;
/// Controller for time update
Controller<Real>* mTimeController;
/// Indication whether the emitted emitter pool (= pool with particle emitters that are emitted) is initialised
bool mEmittedEmitterPoolInitialised;
/// Used to control if the particle system should emit particles or not.
bool mIsEmitting;
typedef list<Particle*>::type ActiveParticleList;
typedef list<Particle*>::type FreeParticleList;
typedef vector<Particle*>::type ParticlePool;
/** Sort by direction functor */
struct SortByDirectionFunctor
{
/// Direction to sort in
Vector3 sortDir;
SortByDirectionFunctor(const Vector3& dir);
float operator()(Particle* p) const;
};
/** Sort by distance functor */
struct SortByDistanceFunctor
{
/// Position to sort in
Vector3 sortPos;
SortByDistanceFunctor(const Vector3& pos);
float operator()(Particle* p) const;
};
static RadixSort<ActiveParticleList, Particle*, float> mRadixSorter;
/** Active particle list.
@remarks
This is a linked list of pointers to particles in the particle pool.
@par
This allows very fast insertions and deletions from anywhere in
the list to activate / deactivate particles as well as reuse of
Particle instances in the pool without construction & destruction
which avoids memory thrashing.
*/
ActiveParticleList mActiveParticles;
/** Free particle queue.
@remarks
This contains a list of the particles free for use as new instances
as required by the set. Particle instances are preconstructed up
to the estimated size in the mParticlePool vector and are
referenced on this deque at startup. As they get used this list
reduces, as they get released back to to the set they get added
back to the list.
*/
FreeParticleList mFreeParticles;
/** Pool of particle instances for use and reuse in the active particle list.
@remarks
This vector will be preallocated with the estimated size of the set,and will extend as required.
*/
ParticlePool mParticlePool;
typedef list<ParticleEmitter*>::type FreeEmittedEmitterList;
typedef list<ParticleEmitter*>::type ActiveEmittedEmitterList;
typedef vector<ParticleEmitter*>::type EmittedEmitterList;
typedef map<String, FreeEmittedEmitterList>::type FreeEmittedEmitterMap;
typedef map<String, EmittedEmitterList>::type EmittedEmitterPool;
/** Pool of emitted emitters for use and reuse in the active emitted emitter list.
@remarks
The emitters in this pool act as particles and as emitters. The pool is a map containing lists
of emitters, identified by their name.
@par
The emitters in this pool are cloned using emitters that are kept in the main emitter list
of the ParticleSystem.
*/
EmittedEmitterPool mEmittedEmitterPool;
/** Free emitted emitter list.
@remarks
This contains a list of the emitters free for use as new instances as required by the set.
*/
FreeEmittedEmitterMap mFreeEmittedEmitters;
/** Active emitted emitter list.
@remarks
This is a linked list of pointers to emitters in the emitted emitter pool.
Emitters that are used are stored (their pointers) in both the list with active particles and in
the list with active emitted emitters. */
ActiveEmittedEmitterList mActiveEmittedEmitters;
typedef vector<ParticleEmitter*>::type ParticleEmitterList;
typedef vector<ParticleAffector*>::type ParticleAffectorList;
/// List of particle emitters, ie sources of particles
ParticleEmitterList mEmitters;
/// List of particle affectors, ie modifiers of particles
ParticleAffectorList mAffectors;
/// The renderer used to render this particle system
ParticleSystemRenderer* mRenderer;
/// Do we cull each particle individually?
bool mCullIndividual;
/// The name of the type of renderer used to render this system
String mRendererType;
/// The number of particles in the pool.
size_t mPoolSize;
/// The number of emitted emitters in the pool.
size_t mEmittedEmitterPoolSize;
/// Optional origin of this particle system (eg script name)
String mOrigin;
/// Default iteration interval
static Real msDefaultIterationInterval;
/// Default nonvisible update timeout
static Real msDefaultNonvisibleTimeout;
/** Internal method used to expire dead particles. */
void _expire(Real timeElapsed);
/** Spawn new particles based on free quota and emitter requirements. */
void _triggerEmitters(Real timeElapsed);
/** Helper function that actually performs the emission of particles
*/
void _executeTriggerEmitters(ParticleEmitter* emitter, unsigned requested, Real timeElapsed);
/** Updates existing particle based on their momentum. */
void _applyMotion(Real timeElapsed);
/** Applies the effects of affectors. */
void _triggerAffectors(Real timeElapsed);
/** Sort the particles in the system **/
void _sortParticles(Camera* cam);
/** Resize the internal pool of particles. */
void increasePool(size_t size);
/** Resize the internal pool of emitted emitters.
@remarks
The pool consists of multiple vectors containing pointers to particle emitters. Increasing the
pool with size implies that the vectors are equally increased. The quota of emitted emitters is
defined on a particle system level and not on a particle emitter level. This is to prevent that
the number of created emitters becomes too high; the quota is shared amongst the emitted emitters.
*/
void increaseEmittedEmitterPool(size_t size);
/** Internal method for initialising string interface. */
void initParameters(void);
/** Internal method to configure the renderer. */
void configureRenderer(void);
/// Internal method for creating ParticleVisualData instances for the pool
void createVisualParticles(size_t poolstart, size_t poolend);
/// Internal method for destroying ParticleVisualData instances for the pool
void destroyVisualParticles(size_t poolstart, size_t poolend);
/** Create a pool of emitted emitters and assign them to the free emitter list.
@remarks
The emitters in the pool are grouped by name. This name is the name of the base emitter in the
main list with particle emitters, which forms the template of the created emitted emitters.
*/
void initialiseEmittedEmitters(void);
/** Determine which emitters in the Particle Systems main emitter become a template for creating an
pool of emitters that can be emitted.
*/
void initialiseEmittedEmitterPool(void);
/** Add emitters from the pool to the free emitted emitter queue. */
void addFreeEmittedEmitters(void);
/** Removes all emitted emitters from this system. */
void removeAllEmittedEmitters(void);
/** Find the list with free emitted emitters.
@param name The name that identifies the list with free emitted emitters.
*/
FreeEmittedEmitterList* findFreeEmittedEmitter (const String& name);
/** Removes an emitter from the active emitted emitter list.
@remarks
The emitter will not be destroyed!
@param emitter Pointer to a particle emitter.
*/
void removeFromActiveEmittedEmitters (ParticleEmitter* emitter);
/** Moves all emitted emitters from the active list to the free list
@remarks
The active emitted emitter list will not be cleared and still keeps references to the emitters!
*/
void addActiveEmittedEmittersToFreeList (void);
/** This function clears all data structures that are used in combination with emitted emitters and
sets the flag to indicate that the emitted emitter pool must be initialised again.
@remarks
This function should be called if new emitters are added to a ParticleSystem or deleted from a
ParticleSystem. The emitted emitter data structures become out of sync and need to be build up
again. The data structures are not reorganised in this function, but by setting a flag,
they are rebuild in the regular process flow.
*/
void _notifyReorganiseEmittedEmitterData (void);
};
/** @} */
/** @} */
}
#include "OgreHeaderSuffix.h"
#endif
|