Torque3D Documentation / _generateds / afxXM_Scale.cpp

afxXM_Scale.cpp

Engine/source/afx/xm/afxXM_Scale.cpp

More...

Classes:

Public Functions

ConsoleDocClass(afxXM_ScaleData , "@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_ScaleData , "@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_ScaleData )

  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_ScaleData : public afxXM_WeightedBaseData
 41{
 42  typedef afxXM_WeightedBaseData Parent;
 43
 44public:
 45  Point3F       scale;
 46
 47public:
 48  /*C*/         afxXM_ScaleData();
 49  /*C*/         afxXM_ScaleData(const afxXM_ScaleData&, bool = false);
 50
 51  void          packData(BitStream* stream);
 52  void          unpackData(BitStream* stream);
 53
 54  virtual bool  allowSubstitutions() const { return true; }
 55
 56  static void   initPersistFields();
 57
 58  afxXM_Base*   create(afxEffectWrapper* fx, bool on_server);
 59
 60  DECLARE_CONOBJECT(afxXM_ScaleData);
 61  DECLARE_CATEGORY("AFX");
 62};
 63
 64//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
 65
 66class afxXM_Scale_weighted : public afxXM_WeightedBase
 67{
 68  typedef afxXM_WeightedBase Parent;
 69
 70  Point3F       xm_scale;
 71
 72public:
 73  /*C*/         afxXM_Scale_weighted(afxXM_ScaleData*, afxEffectWrapper*);
 74
 75  virtual void  updateParams(F32 dt, F32 elapsed, afxXM_Params& params);
 76};
 77
 78//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 79
 80IMPLEMENT_CO_DATABLOCK_V1(afxXM_ScaleData);
 81
 82ConsoleDocClass( afxXM_ScaleData,
 83   "@brief An xmod datablock.\n\n"
 84
 85   "@ingroup afxXMods\n"
 86   "@ingroup AFX\n"
 87   "@ingroup Datablocks\n"
 88);
 89
 90afxXM_ScaleData::afxXM_ScaleData()
 91{
 92  scale.set(0,0,0);
 93}
 94
 95afxXM_ScaleData::afxXM_ScaleData(const afxXM_ScaleData& other, bool temp_clone) : afxXM_WeightedBaseData(other, temp_clone)
 96{
 97  scale = other.scale;
 98}
 99
100void afxXM_ScaleData::initPersistFields()
101{
102  addField("scale",  TypePoint3F,   Offset(scale, afxXM_ScaleData),
103    "...");
104
105  Parent::initPersistFields();
106}
107
108void afxXM_ScaleData::packData(BitStream* stream)
109{
110  Parent::packData(stream);
111  mathWrite(*stream, scale);
112}
113
114void afxXM_ScaleData::unpackData(BitStream* stream)
115{
116  Parent::unpackData(stream);
117  mathRead(*stream, &scale);
118}
119
120afxXM_Base* afxXM_ScaleData::create(afxEffectWrapper* fx, bool on_server)
121{
122  afxXM_ScaleData* datablock = this;
123
124  if (getSubstitutionCount() > 0)
125  {
126    datablock = new afxXM_ScaleData(*this, true);
127    this->performSubstitutions(datablock, fx->getChoreographer(), fx->getGroupIndex());
128  }
129
130  if (datablock->hasFixedWeight())
131    return new afxXM_Scale_weighted(datablock, fx);
132  else
133    return new afxXM_Scale_weighted(datablock, fx);
134}
135
136//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
137
138afxXM_Scale_weighted::afxXM_Scale_weighted(afxXM_ScaleData* db, afxEffectWrapper* fxw) 
139: afxXM_WeightedBase(db, fxw) 
140{ 
141  xm_scale = db->scale; 
142}
143
144void afxXM_Scale_weighted::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
145{
146  F32 wt_factor = calc_weight_factor(elapsed);
147  params.scale += xm_scale*wt_factor;
148  if (params.scale.x < 0.00001f) 
149    params.scale.x = 0.00001f;
150  if (params.scale.y < 0.00001f) 
151    params.scale.y = 0.00001f;
152  if (params.scale.z < 0.00001f) 
153    params.scale.z = 0.00001f;
154}
155
156//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
157