123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
- // Copyright (C) 2015 Faust Logic, Inc.
- //
- // 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 _AFX_EMITTER_PARTICLE_H_
- #define _AFX_EMITTER_PARTICLE_H_
- #include "T3D/fx/particleEmitter.h"
- class afxPathData;
- class afxPath3D;
- class afxParticleEmitterData : public ParticleEmitterData
- {
- typedef ParticleEmitterData Parent;
- public:
- // The afx enhanced particle emitter allows fading
- // of particle color, size, velocity, and/or offset.
- // Fading is controlled by a common value which is
- // set externally using setFadeAmount().
- //
- bool fade_velocity;
- bool fade_offset;
- Point3F pe_vector;
- // new -- consider vector in world space?
- bool pe_vector_is_world;
- // new -- transform paths?
- StringTableEntry tpaths_string; //
- Vector<afxPathData*> tPathDataBlocks; // datablocks for paths
- Vector<U32> tPathDataBlockIds; // datablock IDs which correspond to the pathDataBlocks
- public:
- /*C*/ afxParticleEmitterData();
- /*C*/ afxParticleEmitterData(const afxParticleEmitterData&, bool = false);
- void packData(BitStream* stream) override;
- void unpackData(BitStream* stream) override;
- bool onAdd() override;
- bool preload(bool server, String &errorStr) override;
- bool allowSubstitutions() const override { return true; }
- static void initPersistFields();
- DECLARE_CONOBJECT(afxParticleEmitterData);
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // VECTOR
- class afxParticleEmitterVectorData : public afxParticleEmitterData
- {
- typedef afxParticleEmitterData Parent;
- public:
- /*C*/ afxParticleEmitterVectorData();
- /*C*/ afxParticleEmitterVectorData(const afxParticleEmitterVectorData&, bool = false);
- void packData(BitStream* stream) override;
- void unpackData(BitStream* stream) override;
- bool onAdd() override;
- bool preload(bool server, String &errorStr) override;
- bool allowSubstitutions() const override { return true; }
- static void initPersistFields();
- DECLARE_CONOBJECT(afxParticleEmitterVectorData);
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // CONE
- class afxParticleEmitterConeData : public afxParticleEmitterData
- {
- typedef afxParticleEmitterData Parent;
- public:
- F32 spread_min;
- F32 spread_max;
- public:
- /*C*/ afxParticleEmitterConeData();
- /*C*/ afxParticleEmitterConeData(const afxParticleEmitterConeData&, bool = false);
- void packData(BitStream* stream) override;
- void unpackData(BitStream* stream) override;
- bool onAdd() override;
- bool preload(bool server, String &errorStr) override;
- bool allowSubstitutions() const override { return true; }
- static void initPersistFields();
- DECLARE_CONOBJECT(afxParticleEmitterConeData);
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // PATH
- class afxParticleEmitterPathData : public afxParticleEmitterData
- {
- typedef afxParticleEmitterData Parent;
- public:
- enum PathOriginType
- {
- PATHEMIT_ORIGIN,
- PATHEMIT_POINT,
- PATHEMIT_VECTOR,
- PATHEMIT_TANGENT
- };
- StringTableEntry epaths_string; //
- Vector<afxPathData*> epathDataBlocks; // datablocks for paths
- Vector<U32> epathDataBlockIds; // datablock IDs which correspond to the pathDataBlocks
- U32 path_origin_type;
- bool ground_conform;
- bool ground_conform_terrain;
- bool ground_conform_interiors;
- F32 ground_conform_height;
- public:
- /*C*/ afxParticleEmitterPathData();
- /*C*/ afxParticleEmitterPathData(const afxParticleEmitterPathData&, bool = false);
- void packData(BitStream* stream) override;
- void unpackData(BitStream* stream) override;
- bool onAdd() override;
- bool preload(bool server, String &errorStr) override;
- void onPerformSubstitutions() override;
- bool allowSubstitutions() const override { return true; }
- static void initPersistFields();
- DECLARE_CONOBJECT(afxParticleEmitterPathData);
- };
- typedef afxParticleEmitterPathData::PathOriginType afxParticleEmitterPath_OriginType;
- DefineEnumType( afxParticleEmitterPath_OriginType );
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // DISC
- class afxParticleEmitterDiscData : public afxParticleEmitterData
- {
- typedef afxParticleEmitterData Parent;
- public:
- F32 pe_radius_min;
- F32 pe_radius_max;
- public:
- /*C*/ afxParticleEmitterDiscData();
- /*C*/ afxParticleEmitterDiscData(const afxParticleEmitterDiscData&, bool = false);
- void packData(BitStream* stream) override;
- void unpackData(BitStream* stream) override;
- bool onAdd() override;
- bool preload(bool server, String &errorStr) override;
- bool allowSubstitutions() const override { return true; }
- static void initPersistFields();
- DECLARE_CONOBJECT(afxParticleEmitterDiscData);
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- class afxParticleEmitter : public ParticleEmitter
- {
- typedef ParticleEmitter Parent;
- private:
- afxParticleEmitterData* mDataBlock;
- protected:
- Point3F pe_vector, pe_vector_norm;
- // these go with the "pathsTransform" field
- Vector<afxPath3D*> tpaths;
- Vector<F32> tpath_mults;
- U32 n_tpath_points;
- Point3F** tpath_points;
- const SimObject* afx_owner;
- void init_paths();
- void cleanup_paths();
- Particle* alloc_particle();
- ParticleData* pick_particle_type();
- void afx_emitParticles(const Point3F& point, const bool useLastPosition, const Point3F& velocity, const U32 numMilliseconds);
- void afx_emitParticles(const Point3F& start, const Point3F& end, const Point3F& velocity, const U32 numMilliseconds);
- void preCompute(const MatrixF& mat);
- void sub_particleUpdate(Particle*) override;
- virtual void sub_preCompute(const MatrixF& mat)=0;
- virtual void sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx)=0;
- public:
- /*C*/ afxParticleEmitter();
- /*D*/ ~afxParticleEmitter();
- void emitParticlesExt(const MatrixF& xfm, const Point3F& point, const Point3F& velocity, const U32 numMilliseconds) override;
- afxParticleEmitterData* getDataBlock(){ return mDataBlock; }
- void setAFXOwner(const SimObject* owner) { afx_owner = owner; }
- bool onNewDataBlock(GameBaseData* dptr, bool reload) override;
- bool onAdd() override;
- void onRemove() override;
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // VECTOR
- class afxParticleEmitterVector : public afxParticleEmitter
- {
- typedef afxParticleEmitter Parent;
- private:
- afxParticleEmitterVectorData* mDataBlock;
- public:
- /*C*/ afxParticleEmitterVector();
- /*D*/ ~afxParticleEmitterVector();
- bool onNewDataBlock(GameBaseData* dptr, bool reload) override;
- protected:
- void sub_preCompute(const MatrixF& mat) override;
- void sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offse, S32 part_idxt) override;
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // CONE
- class afxParticleEmitterCone : public afxParticleEmitter
- {
- typedef afxParticleEmitter Parent;
- private:
- afxParticleEmitterData* mDataBlock;
- Point3F cone_v, cone_s0, cone_s1;
- public:
- /*C*/ afxParticleEmitterCone();
- /*D*/ ~afxParticleEmitterCone();
- bool onNewDataBlock(GameBaseData* dptr, bool reload) override;
- protected:
- void sub_preCompute(const MatrixF& mat) override;
- void sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx) override;
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // PATH
- class afxParticleEmitterPath : public afxParticleEmitter
- {
- typedef afxParticleEmitter Parent;
- private:
- afxParticleEmitterPathData* mDataBlock;
- Vector<afxPath3D*> epaths;
- Vector<F32> epath_mults;
- U32 n_epath_points;
- Point3F** epath_points;
- void init_paths();
- void cleanup_paths();
- void groundConformPoint(Point3F& point, const MatrixF& mat);
- public:
- /*C*/ afxParticleEmitterPath();
- /*D*/ ~afxParticleEmitterPath();
- bool onNewDataBlock(GameBaseData* dptr, bool reload) override;
- protected:
- bool onAdd() override;
- void onRemove() override;
- void sub_preCompute(const MatrixF& mat) override;
- void sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx) override;
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- // DISC
- class afxParticleEmitterDisc : public afxParticleEmitter
- {
- typedef afxParticleEmitter Parent;
- private:
- afxParticleEmitterDiscData* mDataBlock;
- Point3F disc_v, disc_r;
- public:
- /*C*/ afxParticleEmitterDisc();
- /*D*/ ~afxParticleEmitterDisc();
- bool onNewDataBlock(GameBaseData* dptr, bool reload) override;
- protected:
- void sub_preCompute(const MatrixF& mat) override;
- void sub_addParticle(const Point3F& pos, const Point3F& vel, const U32 age_offset, S32 part_idx) override;
- };
- //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
- #endif // _AFX_EMITTER_PARTICLE_H_
|