Torque3D Documentation / _generateds / afxChoreographer.h

afxChoreographer.h

Engine/source/afx/afxChoreographer.h

More...

Classes:

Detailed Description

  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_CHOREOGRAPHER_H_
 28#define _AFX_CHOREOGRAPHER_H_
 29
 30//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 31
 32#include "afxEffectDefs.h"
 33#include "afxEffectWrapper.h"
 34#include "afxMagicMissile.h"
 35
 36//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 37// afxChoreographerData
 38
 39class afxChoreographerData : public GameBaseData, public afxEffectDefs
 40{
 41  typedef GameBaseData  Parent;
 42
 43public:
 44  bool              exec_on_new_clients;
 45  U8                echo_packet_usage;
 46  StringTableEntry  client_script_file;
 47  StringTableEntry  client_init_func;
 48
 49public:
 50  /*C*/         afxChoreographerData();
 51  /*C*/         afxChoreographerData(const afxChoreographerData&, bool = false);
 52
 53  virtual void  packData(BitStream*);
 54  virtual void  unpackData(BitStream*);
 55
 56  bool          preload(bool server, String &errorStr);
 57
 58  static void   initPersistFields();
 59
 60  DECLARE_CONOBJECT(afxChoreographerData);
 61  DECLARE_CATEGORY("AFX");
 62};
 63
 64//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 65// afxChoreographer
 66
 67class afxConstraint;
 68class afxConstraintMgr;
 69class afxEffectWrapper;
 70class afxParticlePool;
 71class afxParticlePoolData;
 72class SimSet;
 73class afxForceSetMgr;
 74
 75class afxChoreographer : public GameBase, public afxEffectDefs, public afxMagicMissileCallback
 76{
 77  typedef GameBase  Parent;
 78
 79public:
 80  enum MaskBits 
 81  {
 82    TriggerMask         = Parent::NextFreeMask << 0,
 83    RemapConstraintMask = Parent::NextFreeMask << 1, // CONSTRAINT REMAPPING
 84    NextFreeMask        = Parent::NextFreeMask << 2
 85  };
 86
 87  enum 
 88  { 
 89    USER_EXEC_CONDS_MASK = 0x00ffffff
 90  };
 91
 92protected:
 93  struct dynConstraintDef
 94  {
 95    StringTableEntry  cons_name;
 96    U8                cons_type;
 97    union
 98    {
 99      SceneObject* object;
100      Point3F*     point;
101      MatrixF*     xfm;
102      U16          scope_id;
103    } cons_obj;
104  };
105
106private:
107  afxChoreographerData*    datablock;
108  SimSet                   named_effects;
109  SimObject*               exeblock;
110  afxForceSetMgr*          force_set_mgr;
111  Vector<afxParticlePool*> particle_pools;
112  Vector<dynConstraintDef> dc_defs_a;
113  Vector<dynConstraintDef> dc_defs_b;
114  GameBase*                proc_after_obj;
115  U32                      trigger_mask;
116
117protected:
118  Vector<dynConstraintDef>* dyn_cons_defs;
119  Vector<dynConstraintDef>* dyn_cons_defs2;
120  afxConstraintMgr* constraint_mgr;
121  U32               choreographer_id;
122  U8                ranking;
123  U8                lod;
124  U32               exec_conds_mask;
125  SimObject*        mExtra;
126  Vector<NetConnection*> explicit_clients;
127  bool              started_with_newop;
128  bool              postpone_activation;
129
130  virtual void      pack_constraint_info(NetConnection* conn, BitStream* stream);
131  virtual void      unpack_constraint_info(NetConnection* conn, BitStream* stream);
132  void              setup_dynamic_constraints();
133  void              check_packet_usage(NetConnection*, BitStream*, S32 mark_stream_pos, const char* msg_tag);
134  SceneObject*      get_camera(Point3F* cam_pos=0) const;
135
136public:
137  /*C*/             afxChoreographer();
138  virtual           ~afxChoreographer();
139
140  static void       initPersistFields();
141
142  virtual bool      onAdd();
143  virtual void      onRemove();
144  virtual void      onDeleteNotify(SimObject*);
145  virtual bool      onNewDataBlock(GameBaseData* dptr, bool reload);
146  virtual U32       packUpdate(NetConnection*, U32, BitStream*);
147  virtual void      unpackUpdate(NetConnection*, BitStream*);
148
149  virtual void      sync_with_clients() { }
150  
151  afxConstraintMgr* getConstraintMgr() { return constraint_mgr; }
152  afxForceSetMgr*   getForceSetMgr() { return force_set_mgr; }
153
154  afxParticlePool*  findParticlePool(afxParticlePoolData* key_block, U32 key_index);
155  void              registerParticlePool(afxParticlePool*);
156  void              unregisterParticlePool(afxParticlePool*);
157
158  void              setRanking(U8 value) { ranking = value; }
159  U8                getRanking() const { return ranking; }
160  bool              testRanking(U8 low, U8 high) { return (ranking <= high && ranking >= low); }
161  void              setLevelOfDetail(U8 value) { lod = value; }
162  U8                getLevelOfDetail() const { return lod; }
163  bool              testLevelOfDetail(U8 low, U8 high) { return (lod <= high && lod >= low); }
164  void              setExecConditions(U32 mask) { exec_conds_mask = mask; }
165  U32               getExecConditions() const { return exec_conds_mask; }
166
167  virtual void      executeScriptEvent(const char* method, afxConstraint*, 
168                                       const MatrixF& xfm, const char* data);
169
170  virtual void      inflictDamage(const char * label, const char* flavor, SimObjectId target,
171                                  F32 amt, U8 count, F32 ad_amt, F32 rad, Point3F pos, F32 imp) { }
172
173  void              addObjectConstraint(SceneObject*, const char* cons_name);
174  void              addObjectConstraint(U16 scope_id, const char* cons_name, bool is_shape);
175  void              addPointConstraint(Point3F&, const char* cons_name);
176  void              addTransformConstraint(MatrixF&, const char* cons_name);
177  bool              addConstraint(const char* source_spec, const char* cons_name);
178
179  void              addNamedEffect(afxEffectWrapper*);
180  void              removeNamedEffect(afxEffectWrapper*);
181  afxEffectWrapper* findNamedEffect(StringTableEntry);
182
183  void              clearChoreographerId() { choreographer_id = 0; }
184  U32               getChoreographerId() { return choreographer_id; }
185  void              setGhostConstraintObject(SceneObject*, StringTableEntry cons_name);
186  void              setExtra(SimObject* extra) { mExtra = extra; }
187  void              addExplicitClient(NetConnection* conn);
188  void              removeExplicitClient(NetConnection* conn);
189  U32               getExplicitClientCount() { return explicit_clients.size(); }
190
191  void              restoreScopedObject(SceneObject* obj);
192  virtual void      restoreObject(SceneObject*) { };
193
194  void              postProcessAfterObject(GameBase* obj);
195  U32               getTriggerMask() const { return trigger_mask; }
196  void              setTriggerMask(U32 trigger_mask);
197
198//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
199// missile watcher callbacks
200public:
201  virtual void  impactNotify(const Point3F& p, const Point3F& n, SceneObject*) { }
202
203  DECLARE_CONOBJECT(afxChoreographer);
204  DECLARE_CATEGORY("AFX");
205  
206  // CONSTRAINT REMAPPING <<
207protected:
208  Vector<dynConstraintDef*> remapped_cons_defs;
209  bool              remapped_cons_sent;
210  virtual bool      remap_builtin_constraint(SceneObject*, const char* cons_name) { return false; }     
211  dynConstraintDef* find_cons_def_by_name(const char* cons_name);
212public:
213  void              remapObjectConstraint(SceneObject*, const char* cons_name);
214  void              remapObjectConstraint(U16 scope_id, const char* cons_name, bool is_shape);
215  void              remapPointConstraint(Point3F&, const char* cons_name);
216  void              remapTransformConstraint(MatrixF&, const char* cons_name);
217  bool              remapConstraint(const char* source_spec, const char* cons_name);
218  // CONSTRAINT REMAPPING >> 
219};
220
221//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
222
223#endif // _AFX_CHOREOGRAPHER_H_
224