afxParticlePool.h
Engine/source/afx/util/afxParticlePool.h
Classes:
class
class
Public Typedefs
afxParticlePool_PoolType
Vector< ParticleEmitter * >
ParticleEmitterList
Public Functions
Detailed Description
Public Typedefs
typedef afxParticlePoolData::PoolType afxParticlePool_PoolType
typedef Vector< ParticleEmitter * > ParticleEmitterList
Public Functions
DefineEnumType(afxParticlePool_PoolType )
1 2 3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames 5// Copyright (C) 2015 Faust Logic, Inc. 6// 7// Permission is hereby granted, free of charge, to any person obtaining a copy 8// of this software and associated documentation files (the "Software"), to 9// deal in the Software without restriction, including without limitation the 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11// sell copies of the Software, and to permit persons to whom the Software is 12// furnished to do so, subject to the following conditions: 13// 14// The above copyright notice and this permission notice shall be included in 15// all copies or substantial portions of the Software. 16// 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23// IN THE SOFTWARE. 24// 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 26 27#ifndef _AFX_PARTICLE_POOL_H_ 28#define _AFX_PARTICLE_POOL_H_ 29 30class afxParticlePoolData : public GameBaseData 31{ 32private: 33 typedef GameBaseData Parent; 34 35public: 36 enum PoolType 37 { 38 POOL_NORMAL, 39 POOL_TWOPASS 40 }; 41 42 U32 pool_type; 43 LinearColorF base_color; 44 F32 blend_weight; 45 46public: 47 /*C*/ afxParticlePoolData(); 48 /*C*/ afxParticlePoolData(const afxParticlePoolData&, bool = false); 49 /*D*/ ~afxParticlePoolData(); 50 51 virtual void packData(BitStream*); 52 virtual void unpackData(BitStream*); 53 54 virtual bool allowSubstitutions() const { return true; } 55 56 static void initPersistFields(); 57 58 DECLARE_CONOBJECT(afxParticlePoolData); 59 DECLARE_CATEGORY("AFX"); 60}; 61 62typedef afxParticlePoolData::PoolType afxParticlePool_PoolType; 63DefineEnumType( afxParticlePool_PoolType ); 64 65//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 66 67struct Particle; 68class ParticleEmitter; 69class afxChoreographer; 70 71typedef Vector<ParticleEmitter*> ParticleEmitterList; 72 73class afxParticlePool : public GameBase 74{ 75 typedef GameBase Parent; 76 77 class ObjectDeleteEvent : public SimEvent 78 { 79 public: 80 void process(SimObject *obj) { if (obj) obj->deleteObject(); } 81 }; 82 83 struct SortParticlePool 84 { 85 Particle* p; 86 F32 k; // interpreted differently depending on rendering method 87 ParticleEmitter* emitter; 88 }; 89 90private: 91 afxParticlePoolData* mDataBlock; 92 afxParticlePoolData* key_block; 93 U32 key_index; 94 ParticleEmitterList emitters; 95 afxChoreographer* choreographer; 96 S8 sort_priority; 97 98 static Vector<SortParticlePool> orderedVector; 99 static int QSORT_CALLBACK cmpSortParticlePool(const void* p1, const void* p2); 100 101 S32 mCurBuffSize; 102 GFXVertexBufferHandle<GFXVertexPCT> mVertBuff; 103 S32 mCurBuffSize2; 104 GFXVertexBufferHandle<GFXVertexPCT> mVertBuff2; 105 106protected: 107 virtual void prepRenderImage(SceneRenderState*); 108 109 void pool_prepBatchRender(RenderPassManager*, const Point3F &camPos, const LinearColorF &ambientColor); 110 void pool_renderObject_Normal(RenderPassManager*, const Point3F &camPos, const LinearColorF &ambientColor); 111 void pool_renderObject_TwoPass(RenderPassManager*, const Point3F &camPos, const LinearColorF &ambientColor); 112 113 virtual bool onAdd(); 114 virtual void onRemove(); 115 116 void renderBillboardParticle_blend(Particle&, const Point3F* basePnts, const MatrixF& camView, const F32 spinFactor, 117 const F32 blend_factor, ParticleEmitter*); 118 void renderBillboardParticle_color(Particle&, const Point3F* basePnts, const MatrixF& camView, const F32 spinFactor, 119 const LinearColorF& color, ParticleEmitter*); 120 121public: 122 /*C*/ afxParticlePool(); 123 /*D*/ ~afxParticlePool(); 124 125 virtual bool onNewDataBlock(GameBaseData* dptr, bool reload); 126 127 void addParticleEmitter(ParticleEmitter*); 128 void removeParticleEmitter(ParticleEmitter*); 129 130 void setChoreographer(afxChoreographer* ch) { choreographer = ch; } 131 void setKeyBlock(afxParticlePoolData* db, U32 idx) { key_block = db; key_index = idx; } 132 bool hasMatchingKeyBlock(const afxParticlePoolData* db, U32 idx) const { return (db == key_block && idx == key_index); } 133 134 void updatePoolBBox(ParticleEmitter*); 135 136 void setSortPriority(S8 priority); 137 138 DECLARE_CONOBJECT(afxParticlePool); 139 DECLARE_CATEGORY("AFX"); 140}; 141 142//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 143 144#endif // _AFX_PARTICLE_POOL_H_ 145