particleEmitterNode.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _PARTICLEEMITTERDUMMY_H_
  23. #define _PARTICLEEMITTERDUMMY_H_
  24. #ifndef _GAMEBASE_H_
  25. #include "T3D/gameBase/gameBase.h"
  26. #endif
  27. class ParticleEmitterData;
  28. class ParticleEmitter;
  29. //*****************************************************************************
  30. // ParticleEmitterNodeData
  31. //*****************************************************************************
  32. class ParticleEmitterNodeData : public GameBaseData
  33. {
  34. typedef GameBaseData Parent;
  35. protected:
  36. bool onAdd();
  37. //-------------------------------------- Console set variables
  38. public:
  39. F32 timeMultiple;
  40. //-------------------------------------- load set variables
  41. public:
  42. public:
  43. ParticleEmitterNodeData();
  44. ~ParticleEmitterNodeData();
  45. void packData(BitStream*);
  46. void unpackData(BitStream*);
  47. bool preload(bool server, String &errorStr);
  48. DECLARE_CONOBJECT(ParticleEmitterNodeData);
  49. static void initPersistFields();
  50. };
  51. //*****************************************************************************
  52. // ParticleEmitterNode
  53. //*****************************************************************************
  54. class ParticleEmitterNode : public GameBase
  55. {
  56. typedef GameBase Parent;
  57. enum MaskBits
  58. {
  59. StateMask = Parent::NextFreeMask << 0,
  60. EmitterDBMask = Parent::NextFreeMask << 1,
  61. NextFreeMask = Parent::NextFreeMask << 2,
  62. };
  63. private:
  64. ParticleEmitterNodeData* mDataBlock;
  65. protected:
  66. bool onAdd();
  67. void onRemove();
  68. bool onNewDataBlock( GameBaseData *dptr, bool reload );
  69. void inspectPostApply();
  70. ParticleEmitterData* mEmitterDatablock;
  71. S32 mEmitterDatablockId;
  72. bool mActive;
  73. SimObjectPtr<ParticleEmitter> mEmitter;
  74. F32 mVelocity;
  75. public:
  76. ParticleEmitterNode();
  77. ~ParticleEmitterNode();
  78. ParticleEmitter *getParticleEmitter() {return mEmitter;}
  79. // Time/Move Management
  80. public:
  81. void processTick(const Move* move);
  82. void advanceTime(F32 dt);
  83. DECLARE_CONOBJECT(ParticleEmitterNode);
  84. static void initPersistFields();
  85. U32 packUpdate (NetConnection *conn, U32 mask, BitStream* stream);
  86. void unpackUpdate(NetConnection *conn, BitStream* stream);
  87. inline bool getActive( void ) { return mActive; };
  88. inline void setActive( bool active ) { mActive = active; setMaskBits( StateMask ); };
  89. void setEmitterDataBlock(ParticleEmitterData* data);
  90. };
  91. #endif // _H_PARTICLEEMISSIONDUMMY