Torque3D Documentation / _generateds / afxXM_Shockwave.cpp

afxXM_Shockwave.cpp

Engine/source/afx/xm/afxXM_Shockwave.cpp

More...

Classes:

Public Functions

ConsoleDocClass(afxXM_ShockwaveData , "@brief An xmod <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">datablock.\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxXMods\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Datablocks\n</a>" )

Detailed Description

Public Functions

ConsoleDocClass(afxXM_ShockwaveData , "@brief An xmod <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">datablock.\n\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxXMods\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Datablocks\n</a>" )

IMPLEMENT_CO_DATABLOCK_V1(afxXM_ShockwaveData )

  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#include "afx/arcaneFX.h"
 28
 29#include "math/mathIO.h"
 30#include "math/mathUtils.h"
 31
 32#include "afx/afxEffectWrapper.h"
 33#include "afx/afxChoreographer.h"
 34#include "afx/xm/afxXfmMod.h"
 35#include "afx/util/afxPath3D.h"
 36#include "afx/util/afxPath.h"
 37
 38//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 39
 40class afxXM_ShockwaveData : public afxXM_BaseData
 41{
 42  typedef afxXM_BaseData Parent;
 43
 44public:
 45  F32           rate;
 46  bool          aim_z_only;
 47
 48public:
 49  /*C*/         afxXM_ShockwaveData();
 50  /*C*/         afxXM_ShockwaveData(const afxXM_ShockwaveData&, bool = false);
 51
 52  void          packData(BitStream* stream);
 53  void          unpackData(BitStream* stream);
 54
 55  virtual bool  allowSubstitutions() const { return true; }
 56
 57  static void   initPersistFields();
 58
 59  afxXM_Base*   create(afxEffectWrapper* fx, bool on_server);
 60
 61  DECLARE_CONOBJECT(afxXM_ShockwaveData);
 62  DECLARE_CATEGORY("AFX");
 63};
 64
 65class afxConstraint;
 66
 67class afxXM_Shockwave : public afxXM_Base
 68{
 69  typedef afxXM_Base Parent;
 70
 71  afxXM_ShockwaveData*  db;
 72  bool                  first;
 73  Point3F               fixed_pos;
 74
 75public:
 76  /*C*/         afxXM_Shockwave(afxXM_ShockwaveData*, afxEffectWrapper*);
 77
 78  virtual void  updateParams(F32 dt, F32 elapsed, afxXM_Params& params);
 79};
 80
 81//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 82
 83IMPLEMENT_CO_DATABLOCK_V1(afxXM_ShockwaveData);
 84
 85ConsoleDocClass( afxXM_ShockwaveData,
 86   "@brief An xmod datablock.\n\n"
 87
 88   "@ingroup afxXMods\n"
 89   "@ingroup AFX\n"
 90   "@ingroup Datablocks\n"
 91);
 92
 93afxXM_ShockwaveData::afxXM_ShockwaveData()
 94{
 95  rate = 1.0f;
 96  aim_z_only = false;
 97}
 98
 99afxXM_ShockwaveData::afxXM_ShockwaveData(const afxXM_ShockwaveData& other, bool temp_clone) : afxXM_BaseData(other, temp_clone)
100{
101  rate = other.rate;
102  aim_z_only = other.aim_z_only;
103}
104
105void afxXM_ShockwaveData::initPersistFields()
106{
107  addField("rate",      TypeF32,      Offset(rate, afxXM_ShockwaveData),
108    "...");
109  addField("aimZOnly",  TypeBool,     Offset(aim_z_only, afxXM_ShockwaveData),
110    "...");
111
112  Parent::initPersistFields();
113}
114
115void afxXM_ShockwaveData::packData(BitStream* stream)
116{
117  Parent::packData(stream);
118  stream->write(rate);
119  stream->write(aim_z_only);
120}
121
122void afxXM_ShockwaveData::unpackData(BitStream* stream)
123{
124  Parent::unpackData(stream);
125  stream->read(&rate);
126  stream->read(&aim_z_only);
127}
128
129afxXM_Base* afxXM_ShockwaveData::create(afxEffectWrapper* fx, bool on_server)
130{
131  afxXM_ShockwaveData* datablock = this;
132
133  if (getSubstitutionCount() > 0)
134  {
135    datablock = new afxXM_ShockwaveData(*this, true);
136    this->performSubstitutions(datablock, fx->getChoreographer(), fx->getGroupIndex());
137  }
138
139  return new afxXM_Shockwave(datablock, fx);
140}
141
142
143//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
144
145afxXM_Shockwave::afxXM_Shockwave(afxXM_ShockwaveData* db, afxEffectWrapper* fxw) 
146: afxXM_Base(db, fxw)
147{ 
148  this->db = db; 
149  first = true;
150  fixed_pos.zero();
151}
152
153void afxXM_Shockwave::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
154{
155  if (first)
156  {
157    fixed_pos = params.pos;
158    first = false;
159  }
160
161  Point3F aim_at_pos = params.pos2;
162  if (db->aim_z_only)
163    aim_at_pos.z = fixed_pos.z;
164  
165  VectorF line_of_sight = aim_at_pos - fixed_pos;
166  line_of_sight.normalize();
167
168  params.pos = fixed_pos + line_of_sight*(elapsed*db->rate);
169}
170
171//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
172