00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_PARTICLE_SYSTEM_H
00025 #define NL_PARTICLE_SYSTEM_H
00026
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/misc/matrix.h"
00029 #include "nel/misc/aabbox.h"
00030 #include "nel/misc/smart_ptr.h"
00031 #include "nel/misc/rgba.h"
00032 #include "nel/misc/object_arena_allocator.h"
00033 #include "nel/3d/animation_time.h"
00034 #include "nel/3d/animation_time.h"
00035 #include "nel/3d/animated_value.h"
00036 #include "nel/3d/particle_system_process.h"
00037 #include "nel/3d/ps_lod.h"
00038 #include "nel/3d/ps_attrib_maker.h"
00039 #include "nel/3d/ps_spawn_info.h"
00040
00041 #include <map>
00042
00043
00044
00045 namespace NL3D
00046 {
00047
00048 class CParticleSystemShape;
00049 class CParticleSystemModel;
00050 class CPSLocated;
00051 class CPSLocatedBindable;
00052 class CFontGenerator;
00053 class CFontManager;
00054 class CPSCopyHelper;
00055 class CScene;
00056 class CPSLocated;
00057 class IDriver;
00058 struct UPSSoundServer;
00059
00060
00061
00062
00064 const uint MaxPSUserParam = 4;
00065
00066
00078 class CParticleSystem : public NLMISC::CRefCount
00079 {
00080 public:
00081 PS_FAST_OBJ_ALLOC
00082
00083 enum TPass { Anim, SolidRender, BlendRender, ToolRender };
00084 public:
00085
00086
00088
00089
00090 CParticleSystem();
00092 virtual ~CParticleSystem();
00094 void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00100 bool merge(CParticleSystemShape *toMerge);
00101
00102
00103
00104
00105
00107
00108
00109
00111
00112
00120 void enableSharing(bool enabled = true) { _Sharing = enabled; }
00121
00123 bool isSharingEnabled() const { return _Sharing; }
00125
00126
00127
00129
00130
00131 void setDriver(IDriver *driver) { _Driver = driver; }
00132
00134 IDriver *getDriver(void) { return _Driver; }
00136
00137
00139
00140
00143 void setScene(CScene *scene) { _Scene = scene; }
00144
00146 CScene *getScene() const { return _Scene; }
00148
00149
00150
00152
00153
00157 void hide(bool hidden) { _HiddenAtCurrentFrame = hidden; }
00161 void onShow(bool shown);
00167 void setSysMat(const NLMISC::CMatrix *m);
00168
00172 void setUserMatrix(const NLMISC::CMatrix *m);
00173
00175 const NLMISC::CMatrix &getSysMat() const
00176 {
00177 return _CoordSystemInfo.Matrix ? *_CoordSystemInfo.Matrix : NLMISC::CMatrix::Identity;
00178 }
00179
00181 const NLMISC::CMatrix &getInvertedSysMat() const { return _CoordSystemInfo.InvMatrix; }
00182
00188 const NLMISC::CMatrix &getUserMatrix() const
00189 {
00190 NL_PS_FUNC_MAIN(getUserMatrix)
00191 return (_UserCoordSystemInfo && _UserCoordSystemInfo->CoordSystemInfo.Matrix) ? *(_UserCoordSystemInfo->CoordSystemInfo.Matrix) : getSysMat();
00192 }
00193
00199 const NLMISC::CMatrix &getInvertedUserMatrix() const { return (_UserCoordSystemInfo && _UserCoordSystemInfo->CoordSystemInfo.Matrix) ? _UserCoordSystemInfo->CoordSystemInfo.InvMatrix : getInvertedSysMat(); }
00200
00201
00202 const NLMISC::CMatrix &getUserToFXMatrix() const { return (_UserCoordSystemInfo && _UserCoordSystemInfo->CoordSystemInfo.Matrix) ? _UserCoordSystemInfo->UserBasisToFXBasis : NLMISC::CMatrix::Identity; }
00203
00204 const NLMISC::CMatrix &getFXToUserMatrix() const { return (_UserCoordSystemInfo && _UserCoordSystemInfo->CoordSystemInfo.Matrix) ? _UserCoordSystemInfo->FXBasisToUserBasis : NLMISC::CMatrix::Identity; }
00205
00209 void setViewMat(const NLMISC::CMatrix &m);
00210
00212 const NLMISC::CMatrix &getViewMat(void) const { return _ViewMat; }
00213
00215 const NLMISC::CMatrix &getInvertedViewMat(void) const { return _InvertedViewMat; }
00217
00218
00219
00220
00222
00223
00230 virtual void step(TPass pass, TAnimationTime ellapsedTime, CParticleSystemShape &shape, CParticleSystemModel &model);
00232
00233
00234
00236 static uint32 NbParticlesDrawn;
00237
00238
00239
00251 bool attach(CParticleSystemProcess *process);
00252
00255 CParticleSystemProcess *detach(uint index);
00256
00259 bool isProcess(const CParticleSystemProcess *process) const;
00260
00264 uint getIndexOf(const CParticleSystemProcess &process) const;
00265
00270 void remove(CParticleSystemProcess *process);
00271
00273 uint32 getNbProcess(void) const { return _ProcessVect.size(); }
00274
00279 CParticleSystemProcess *getProcess(uint32 index)
00280 {
00281 nlassert(index < _ProcessVect.size());
00282 return _ProcessVect[index];
00283 }
00284
00289 const CParticleSystemProcess *getProcess(uint32 index) const
00290 {
00291 nlassert(index < _ProcessVect.size());
00292 return _ProcessVect[index];
00293 }
00294
00296
00297
00298
00300
00301
00303 TAnimationTime getSystemDate(void) const { return _SystemDate; }
00304
00306 void setSystemDate(float date);
00307
00312 uint64 getDate(void) const
00313 {
00314 NL_PS_FUNC_MAIN(getDate)
00315 return _Date;
00316 }
00318
00319
00320
00329 void setUserParam(uint userParamIndex, float value)
00330 {
00331 NL_PS_FUNC_MAIN(setUserParam)
00332 nlassert(userParamIndex < MaxPSUserParam);
00333 NLMISC::clamp(value, 0, MaxInputValue);
00334 _UserParam[userParamIndex] = value;
00335 }
00336
00340 float getUserParam(uint userParamIndex) const
00341 {
00342 NL_PS_FUNC_MAIN(getUserParam)
00343 nlassert(userParamIndex < MaxPSUserParam);
00344 return _UserParam[userParamIndex];
00345 }
00346
00352 void bindGlobalValueToUserParam(const std::string &globalValueName, uint userParamIndex);
00353
00354 std::string getGlobalValueName(uint userParamIndex) const;
00355
00356 static void setGlobalValue(const std::string &name, float value);
00357
00358 static float getGlobalValue(const std::string &name);
00362 static void setGlobalVectorValue(const std::string &name, const NLMISC::CVector &value);
00363
00364 static NLMISC::CVector getGlobalVectorValue(const std::string &name);
00365
00366 class CGlobalVectorValueHandle
00367 {
00368 public:
00369 CGlobalVectorValueHandle() { reset(); }
00370 const NLMISC::CVector &get() const { nlassert(_Value); return *_Value; }
00371 void set(const NLMISC::CVector &value) { nlassert(_Value); *_Value = value; }
00372 const std::string &getName() const { nlassert(_Name); return *_Name; }
00373 bool isValid() const { return _Name != NULL && _Value != NULL; }
00374 void reset() { _Name = NULL; _Value = NULL; }
00376 private:
00377 friend class CParticleSystem;
00378 const std::string *_Name;
00379 NLMISC::CVector *_Value;
00380 };
00381
00382 static CGlobalVectorValueHandle getGlobalVectorValueHandle(const std::string &name);
00384
00385
00386
00387
00388
00390
00396 void setCurrentEditedElement(CPSLocated *loc = NULL , uint32 index = 0, class CPSLocatedBindable *bd = NULL )
00397 {
00398 NL_PS_FUNC_MAIN(setCurrentEditedElement)
00399 _CurrEditedElementLocated = loc;
00400 _CurrEditedElementLocatedBindable = bd;
00401 _CurrEditedElementIndex = index;
00402 }
00403
00407 void getCurrentEditedElement(CPSLocated *&loc , uint32 &index, CPSLocatedBindable *&lb)
00408 {
00409 NL_PS_FUNC_MAIN(getCurrentEditedElement)
00410 loc = _CurrEditedElementLocated;
00411 index = _CurrEditedElementIndex;
00412 lb = _CurrEditedElementLocatedBindable;
00413 }
00414
00416 void setFontGenerator(CFontGenerator *fg) { _FontGenerator = fg; }
00417
00419 CFontGenerator *getFontGenerator(void) { return _FontGenerator; }
00420
00422 const CFontGenerator *getFontGenerator(void) const { return _FontGenerator; }
00423
00425 void setFontManager(CFontManager *fg) { _FontManager = fg; }
00426
00428 CFontManager *getFontManager(void) { return _FontManager; }
00429
00431 const CFontManager *getFontManager(void) const { return _FontManager; }
00432
00433
00435 void setName(const std::string &s) { _Name = s; }
00436
00438 std::string getName(void) const { return _Name; }
00439
00440
00441
00443
00445 bool hasOpaqueObjects(void) const;
00446
00448 bool hasTransparentObjects(void) const;
00449
00450
00451
00452
00454
00456 bool hasLightableObjects() const;
00457
00458
00459
00460
00462
00466 void enableAccurateIntegration(bool enable = true) { _AccurateIntegration = enable; }
00467 bool isAccurateIntegrationEnabled(void) const { return _AccurateIntegration; }
00468
00474 void setAccurateIntegrationParams(TAnimationTime threshold,
00475 uint32 maxNbIntegrations,
00476 bool canSlowDown,
00477 bool keepEllapsedTimeForLifeUpdate
00478 )
00479 {
00480 NL_PS_FUNC_MAIN(setAccurateIntegrationParams)
00481 _TimeThreshold = threshold;
00482 _MaxNbIntegrations = maxNbIntegrations;
00483 _CanSlowDown = canSlowDown;
00484 if (_KeepEllapsedTimeForLifeUpdate != keepEllapsedTimeForLifeUpdate)
00485 {
00486 _KeepEllapsedTimeForLifeUpdate = keepEllapsedTimeForLifeUpdate;
00487 _PresetBehaviour = UserBehaviour;
00488 }
00489 }
00490
00494 void getAccurateIntegrationParams(TAnimationTime &threshold,
00495 uint32 &maxNbIntegrations,
00496 bool &canSlowDown,
00497 bool &keepEllapsedTimeForLifeUpdate
00498 )
00499 {
00500 NL_PS_FUNC_MAIN(getAccurateIntegrationParams)
00501 threshold = _TimeThreshold;
00502 maxNbIntegrations = _MaxNbIntegrations;
00503 canSlowDown = _CanSlowDown;
00504 keepEllapsedTimeForLifeUpdate = _KeepEllapsedTimeForLifeUpdate;
00505 }
00506
00507
00508 float getTimeTheshold() const { return _TimeThreshold; }
00512 uint getMaxNbIntegrations() const { return _MaxNbIntegrations; }
00513
00520 void setBypassMaxNumIntegrationSteps(bool bypass = true)
00521 {
00522 NL_PS_FUNC_MAIN(setBypassMaxNumIntegrationSteps)
00523 if (_BypassIntegrationStepLimit != bypass)
00524 {
00525 if (bypass)
00526 {
00527 if (!canFinish())
00528 {
00529 nlwarning("<CParticleSystem::setBypassMaxNumIntegrationSteps> Can't set flag to true. The system must have a finite duration");
00530 nlassert(0);
00531 return;
00532 }
00533 }
00534 _BypassIntegrationStepLimit = bypass;
00535 _PresetBehaviour = UserBehaviour;
00536 }
00537 }
00538 bool getBypassMaxNumIntegrationSteps() const { return _BypassIntegrationStepLimit; }
00539
00545 bool canFinish(CPSLocatedBindable **lastingForeverObj = NULL) const;
00546
00551 bool hasLoop(CPSLocatedBindable **loopingObj = NULL) const;
00552
00553
00554
00555
00556
00557
00566
00567
00569 void setMaxViewDist(float maxDist)
00570 {
00571 NL_PS_FUNC_MAIN(setMaxViewDist)
00572 nlassert(maxDist > 0.f);
00573 _MaxViewDist = maxDist;
00574 _InvCurrentViewDist = _InvMaxViewDist = 1.f / maxDist;
00575 }
00576
00578 float getMaxViewDist(void) const { return _MaxViewDist; }
00579
00581 void setLODRatio(float ratio) { nlassert(ratio > 0 && ratio <= 1.f); _LODRatio = ratio; }
00582
00584 float getLODRatio(void) const { return _LODRatio; }
00585
00586
00591 void getLODVect(NLMISC::CVector &v, float &offset, TPSMatrixMode matrixMode);
00592
00594 TPSLod getLOD(void) const;
00595
00597 float getOneMinusCurrentLODRatio(void) const { return _OneMinusCurrentLODRatio; }
00598
00604 void enableAutoLOD(bool enabled = true) { _AutoLOD = enabled; }
00605
00607 bool isAutoLODEnabled() const { return _AutoLOD; }
00608
00613 void setupAutoLOD(float startDistPercent, uint8 degradationExponent)
00614 {
00615 NL_PS_FUNC_MAIN(setupAutoLOD)
00616 nlassert(startDistPercent < 1.f);
00617 nlassert(degradationExponent > 0);
00618 _AutoLODStartDistPercent = startDistPercent;
00619 _AutoLODDegradationExponent = degradationExponent;
00620 }
00621
00627 void setMaxDistLODBias(float lodBias);
00628 float getMaxDistLODBias() const { return _MaxDistLODBias; }
00629
00630
00631
00632 float getAutoLODStartDistPercent() const { return _AutoLODStartDistPercent; }
00633 uint8 getAutoLODDegradationExponent() const { return _AutoLODDegradationExponent; }
00634
00639 void setAutoLODMode(bool skipParticles) { _AutoLODSkipParticles = skipParticles; }
00640 bool getAutoLODMode() const { return _AutoLODSkipParticles; }
00641
00648 void setColorAttenuationScheme(CPSAttribMaker<NLMISC::CRGBA> *colScheme)
00649 {
00650 NL_PS_FUNC_MAIN(setColorAttenuationScheme)
00651 delete _ColorAttenuationScheme;
00652 _ColorAttenuationScheme = colScheme;
00653 if (!colScheme)
00654 {
00655 _GlobalColor = NLMISC::CRGBA::White;
00656 }
00657 }
00658
00660 CPSAttribMaker<NLMISC::CRGBA> *getColorAttenuationScheme() { return _ColorAttenuationScheme; }
00661 const CPSAttribMaker<NLMISC::CRGBA> *getColorAttenuationScheme() const { return _ColorAttenuationScheme; }
00662
00668 void setUserColor(NLMISC::CRGBA userColor) { _UserColor = userColor; }
00669 NLMISC::CRGBA getUserColor() const { return _UserColor; }
00670
00671
00672 bool isUserColorUsed() const { return _UserColor != NLMISC::CRGBA::White; }
00673
00677 NLMISC::CRGBA getGlobalColor() const { return _GlobalColor; }
00680 NLMISC::CRGBA getGlobalColorLighted() const { return _GlobalColorLighted; }
00681
00682 bool getForceGlobalColorLightingFlag() { return _ForceGlobalColorLighting; }
00683
00684 void setForceGlobalColorLightingFlag(bool enable) { _ForceGlobalColorLighting = enable; }
00685
00686 void setLightingColor(NLMISC::CRGBA col) { _LightingColor = col; }
00687 NLMISC::CRGBA getLightingColor() const { return _LightingColor; }
00688
00689
00690
00691
00692
00693
00694
00695 float getWantedNumTris(float dist);
00696
00698 void setNumTris(uint numFaces);
00699
00703
00704
00706 bool isLoadBalancingEnabled() const { return _EnableLoadBalancing; }
00707
00709 void enableLoadBalancing(bool enabled = true);
00710
00711
00712
00713
00715
00720 void computeBBox(NLMISC::CAABBox &aabbox);
00721
00724 void forceComputeBBox(NLMISC::CAABBox &aabbox);
00725
00729 void setAutoComputeBBox(bool enable = true) { _ComputeBBox = enable; }
00730
00731
00733 bool getAutoComputeBBox(void) const { return _ComputeBBox; }
00734
00735
00740 void setPrecomputedBBox(const NLMISC::CAABBox &precompBBox)
00741 {
00742 NL_PS_FUNC_MAIN(setPrecomputedBBox)
00743 nlassert(!_ComputeBBox);
00744 _PreComputedBBox = precompBBox;
00745 }
00746
00748 void getLastComputedBBox(NLMISC::CAABBox &dest) { dest = _PreComputedBBox; }
00749
00750
00751
00752
00754
00758 void setDestroyModelWhenOutOfRange(bool enable = true)
00759 {
00760 NL_PS_FUNC_MAIN(setDestroyModelWhenOutOfRange)
00761 _DestroyModelWhenOutOfRange = enable;
00762 _PresetBehaviour = UserBehaviour;
00763 }
00764
00766 bool getDestroyModelWhenOutOfRange(void) const { return _DestroyModelWhenOutOfRange; }
00767
00768
00770 enum TDieCondition { none, noMoreParticles, noMoreParticlesAndEmitters };
00771
00772
00779 void setDestroyCondition(TDieCondition dieCondition)
00780 {
00781 NL_PS_FUNC_MAIN(setDestroyCondition)
00782 _DieCondition = dieCondition;
00783 _PresetBehaviour = UserBehaviour;
00784 }
00785
00786
00787 bool isDestroyConditionVerified() const;
00788
00790 TDieCondition getDestroyCondition(void) const { return _DieCondition; }
00791
00803 void setDelayBeforeDeathConditionTest(TAnimationTime delay)
00804 {
00805 NL_PS_FUNC_MAIN(setDelayBeforeDeathConditionTest)
00806
00807 _DelayBeforeDieTest = delay;
00808 }
00809
00817 void systemDurationChanged();
00818
00822 TAnimationTime getDelayBeforeDeathConditionTest() const;
00823
00830 void setAutoComputeDelayBeforeDeathConditionTest(bool computeAuto);
00831 bool getAutoComputeDelayBeforeDeathConditionTest() const { return _AutoComputeDelayBeforeDeathTest; }
00832
00838 void destroyWhenOutOfFrustum(bool enable = true)
00839 {
00840 _DestroyWhenOutOfFrustum = enable;
00841 _PresetBehaviour = UserBehaviour;
00842 }
00843
00847 bool doesDestroyWhenOutOfFrustum(void) const { return _DestroyWhenOutOfFrustum; }
00848
00849
00851 bool hasEmitters(void) const;
00852
00854 bool hasParticles() const;
00855
00857 bool hasTemporaryParticles() const;
00858
00860 enum TAnimType
00861 { AnimVisible = 0,
00862 AnimInCluster,
00863 AnimAlways,
00864 LastValue
00865 };
00866
00870 void performMotionWhenOutOfFrustum(bool enable = true)
00871 {
00872 NL_PS_FUNC_MAIN(performMotionWhenOutOfFrustum)
00873 _AnimType = enable ? AnimInCluster : AnimVisible;
00874 _PresetBehaviour = UserBehaviour;
00875 }
00876
00880 bool doesPerformMotionWhenOutOfFrustum(void) const { return _AnimType == AnimInCluster; }
00881
00883 void setAnimType(TAnimType animType)
00884 {
00885 NL_PS_FUNC_MAIN(setAnimType)
00886 nlassert(animType < LastValue);
00887 _AnimType = animType;
00888 _PresetBehaviour = UserBehaviour;
00889 }
00890
00892 TAnimType getAnimType() const { return _AnimType; }
00893
00905 enum TPresetBehaviour
00906 {
00907 EnvironmentFX = 0,
00908 RunningEnvironmentFX,
00909
00910
00911
00912
00913 SpellFX,
00914 LoopingSpellFX,
00915 MinorFX,
00916 UserBehaviour,
00917 MovingLoopingFX,
00918 SpawnedEnvironmentFX,
00919 GroundFX,
00922 Projectile,
00923 PresetLast
00924 };
00925
00926 void activatePresetBehaviour(TPresetBehaviour behaviour);
00927
00928 TPresetBehaviour getBehaviourType() const
00929 {
00930 NL_PS_FUNC_MAIN(getBehaviourType)
00931 return _PresetBehaviour;
00932 }
00933
00934
00935
00936
00937
00938
00939
00941
00943 static void registerSoundServer(UPSSoundServer *soundServer);
00944
00946 static UPSSoundServer * getSoundServer(void)
00947 {
00948 NL_PS_FUNC(getSoundServer)
00949 return _SoundServer;
00950 }
00951
00953 void stopSound();
00954
00955
00956 void reactivateSound();
00957
00958
00959
00960
00962
00967 void registerLocatedBindableExternID(uint32 id, CPSLocatedBindable *lb);
00968
00970 void unregisterLocatedBindableExternID(CPSLocatedBindable *lb);
00971
00972
00973
00975
00977 uint getNumLocatedBindableByExternID(uint32 id) const;
00981 CPSLocatedBindable *getLocatedBindableByExternID(uint32 id, uint index);
00982 const CPSLocatedBindable *getLocatedBindableByExternID(uint32 id, uint index) const;
00984 uint getNumID() const;
00986 uint32 getID(uint index) const;
00990 void getIDs(std::vector<uint32> &dest) const;
00991
00992
00993
00995
01002 void enableEmitThreshold(bool enabled = true) { _EmitThreshold = enabled; }
01003 bool isEmitThresholdEnabled() const { return _EmitThreshold; }
01004
01005
01006 void activateEmitters(bool active);
01007
01008 bool hasActiveEmitters() const;
01009
01010 bool hasEmittersTemplates() const;
01017 float evalDuration() const;
01026 void setAutoCountFlag(bool enabled) { _AutoCount = enabled; }
01027 bool getAutoCountFlag() const { return _AutoCount; }
01032 void matchArraySize();
01033
01034 uint getMaxNumParticles() const;
01035
01036 uint getCurrNumParticles() const;
01037
01038 void getTargeters(const CPSLocated *target, std::vector<CPSTargetLocatedBindable *> &targeters);
01039
01040 static void setSerializeIdentifierFlag(bool on) { _SerialIdentifiers = on; }
01041 static bool getSerializeIdentifierFlag() { return _SerialIdentifiers; }
01042
01043 void enumTexs(std::vector<NLMISC::CSmartPtr<ITexture> > &dest, IDriver &drv);
01044
01045 void setZBias(float value);
01046
01047 static void forceDisplayBBox(bool on) { _ForceDisplayBBox = on; }
01051 void getSortingByEmitterPrecedence(std::vector<uint> &result) const;
01052
01053
01054
01055
01056 private:
01057 typedef std::map<std::string, float> TGlobalValuesMap;
01058 typedef std::map<std::string, NLMISC::CVector> TGlobalVectorValuesMap;
01059 private:
01060 friend class CParticleSystemModel;
01062 void stepLocated(TPSProcessPass pass);
01063
01064 float updateLODRatio();
01065 float getDistFromViewer() const;
01066 void updateColor(float distFromViewer);
01067 void updateNumWantedTris();
01068
01069 void updateProcessIndices();
01070
01071 void checkIntegrity();
01072
01073 static TGlobalValuesMap _GlobalValuesMap;
01074
01075 static TGlobalVectorValuesMap _GlobalVectorValuesMap;
01076
01077 NLMISC::CAABBox _PreComputedBBox;
01078
01079 IDriver *_Driver;
01080
01081 typedef CPSVector<CParticleSystemProcess *>::V TProcessVect;
01082 TProcessVect _ProcessVect;
01083 CFontGenerator *_FontGenerator;
01084 CFontManager *_FontManager;
01085
01086
01087 class CCoordSystemInfo
01088 {
01089 public:
01090 const NLMISC::CMatrix *Matrix;
01091 NLMISC::CMatrix InvMatrix;
01092 NLMISC::CVector OldPos;
01093 NLMISC::CVector CurrentDeltaPos;
01094 public:
01095 CCoordSystemInfo()
01096 {
01097 Matrix = NULL;
01098 }
01099 };
01100
01101
01102 class CUserCoordSystemInfo
01103 {
01104 public:
01105 CCoordSystemInfo CoordSystemInfo;
01106 NLMISC::CMatrix UserBasisToFXBasis;
01107 NLMISC::CMatrix FXBasisToUserBasis;
01108 uint16 NumRef;
01109
01110 public:
01111 CUserCoordSystemInfo()
01112 {
01113 NumRef = 0;
01114 }
01115 };
01116
01117 CCoordSystemInfo _CoordSystemInfo;
01118 CUserCoordSystemInfo *_UserCoordSystemInfo;
01119
01120
01121
01122
01123
01124
01125
01126 NLMISC::CMatrix _ViewMat;
01127
01128
01129 NLMISC::CMatrix _InvertedViewMat;
01130
01131
01132
01133 uint64 _Date;
01134
01136 sint64 _LastUpdateDate;
01137
01138
01139 CPSLocated *_CurrEditedElementLocated;
01140
01141 CPSLocatedBindable *_CurrEditedElementLocatedBindable;
01142
01143 uint32 _CurrEditedElementIndex;
01144
01145
01150 CScene *_Scene;
01151
01152
01153
01154 std::string _Name;
01155
01156 TAnimationTime _TimeThreshold;
01157 TAnimationTime _SystemDate;
01158 uint32 _MaxNbIntegrations;
01159
01160
01161 float _LODRatio;
01162 float _OneMinusCurrentLODRatio;
01163 float _MaxViewDist;
01164 float _MaxDistLODBias;
01165 float _InvMaxViewDist;
01166 float _InvCurrentViewDist;
01167
01168 float _AutoLODEmitRatio;
01169
01170 TDieCondition _DieCondition;
01171 mutable TAnimationTime _DelayBeforeDieTest;
01172 uint _NumWantedTris;
01173 TAnimType _AnimType;
01174
01175 static UPSSoundServer *_SoundServer;
01176
01177 float _UserParam[MaxPSUserParam];
01178 const TGlobalValuesMap::value_type **_UserParamGlobalValue;
01179
01180 uint8 _BypassGlobalUserParam;
01181
01182 TPresetBehaviour _PresetBehaviour;
01183
01184 typedef
01185 CPSMultiMap<uint32, CPSLocatedBindable *>::M TLBMap;
01186 TLBMap _LBMap;
01187
01188 float _AutoLODStartDistPercent;
01189 uint8 _AutoLODDegradationExponent;
01190
01191 CPSAttribMaker<NLMISC::CRGBA> *_ColorAttenuationScheme;
01192 NLMISC::CRGBA _GlobalColor;
01193 NLMISC::CRGBA _GlobalColorLighted;
01194 NLMISC::CRGBA _LightingColor;
01195 NLMISC::CRGBA _UserColor;
01196
01197 bool _ComputeBBox : 1;
01198 bool _BBoxTouched : 1;
01199 bool _AccurateIntegration : 1;
01200 bool _CanSlowDown : 1;
01201 bool _DestroyModelWhenOutOfRange : 1;
01202 bool _DestroyWhenOutOfFrustum : 1;
01203 bool _Sharing : 1;
01204 bool _AutoLOD : 1;
01205 bool _KeepEllapsedTimeForLifeUpdate : 1;
01206 bool _AutoLODSkipParticles : 1;
01207 bool _EnableLoadBalancing : 1;
01208 bool _EmitThreshold : 1;
01209 bool _BypassIntegrationStepLimit : 1;
01210 bool _ForceGlobalColorLighting : 1;
01211 bool _AutoComputeDelayBeforeDeathTest : 1;
01212 bool _AutoCount : 1;
01213 bool _HiddenAtCurrentFrame : 1;
01214 bool _HiddenAtPreviousFrame : 1;
01215
01216 static bool _SerialIdentifiers;
01217 static bool _ForceDisplayBBox;
01218
01219
01220 #ifdef NL_DEBUG
01221 static uint _NumInstances;
01222 #endif
01223 public:
01224
01225 void interpolateFXPosDelta(NLMISC::CVector &dest, TAnimationTime deltaT);
01226
01227 void interpolateUserPosDelta(NLMISC::CVector &dest, TAnimationTime deltaT);
01228
01229 float getAutoLODEmitRatio() const { return _AutoLODEmitRatio; }
01230
01231 void matrixModeChanged(CParticleSystemProcess *proc, TPSMatrixMode oldMode, TPSMatrixMode newMode);
01232
01233 void addRefForUserSysCoordInfo(uint numRefs = 1);
01234
01235 void releaseRefForUserSysCoordInfo(uint numRefs = 1);
01236
01237 void dumpHierarchy();
01238 public:
01239
01240 typedef std::vector<CPSSpawnInfo> TSpawnInfoVect;
01241 struct CSpawnVect : public NLMISC::CRefCount
01242 {
01243 TSpawnInfoVect SpawnInfos;
01244 uint MaxNumSpawns;
01245 };
01246 static std::vector<NLMISC::CSmartPtr<CSpawnVect> > _Spawns;
01247
01248
01249
01250
01251 static std::vector<uint> _ParticleToRemove;
01252 static std::vector<sint> _ParticleRemoveListIndex;
01253 static std::vector<uint> _CollidingParticles;
01254 static std::vector<NLMISC::CVector> _SpawnPos;
01255 public:
01256
01257 static TAnimationTime EllapsedTime;
01258 static TAnimationTime InverseTotalEllapsedTime;
01259 static TAnimationTime RealEllapsedTime;
01260 static float RealEllapsedTimeRatio;
01261 static bool InsideSimLoop;
01262 static bool InsideRemoveLoop;
01263 static bool InsideNewElementsLoop;
01264 static CParticleSystemModel *OwnerModel;
01265 };
01266
01267
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329 }
01330
01331
01332 #endif // NL_PARTICLE_SYSTEM_H
01333
01334