Torque3D Documentation / _generateds / afxXM_OscillateZodiacColor.cpp

afxXM_OscillateZodiacColor.cpp

Engine/source/afx/xm/afxXM_OscillateZodiacColor.cpp

More...

Classes:

Public Functions

ConsoleDocClass(afxXM_OscillateZodiacColorData , "@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_OscillateZodiacColorData , "@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_OscillateZodiacColorData )

  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#include "afx/afxEffectWrapper.h"
 29#include "afx/xm/afxXfmMod.h"
 30
 31//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 32
 33class afxXM_OscillateZodiacColorData : public afxXM_WeightedBaseData
 34{
 35  typedef afxXM_WeightedBaseData Parent;
 36
 37public:
 38  LinearColorF        color_a;
 39  LinearColorF        color_b;
 40  F32           speed;
 41
 42public:
 43  /*C*/         afxXM_OscillateZodiacColorData();
 44
 45  void          packData(BitStream* stream);
 46  void          unpackData(BitStream* stream);
 47  static void   initPersistFields();
 48
 49  afxXM_Base*   create(afxEffectWrapper* fx, bool on_server);
 50
 51  DECLARE_CONOBJECT(afxXM_OscillateZodiacColorData);
 52  DECLARE_CATEGORY("AFX");
 53};
 54
 55class afxXM_OscillateZodiacColor : public afxXM_WeightedBase
 56{
 57  typedef afxXM_WeightedBase Parent;
 58
 59  LinearColorF        color_a;
 60  LinearColorF        color_b;
 61  F32           speed;
 62
 63  LinearColorF*       liveColor_ptr;
 64  F32*          liveColorFactor_ptr;
 65
 66public:
 67  /*C*/         afxXM_OscillateZodiacColor(afxXM_OscillateZodiacColorData*, afxEffectWrapper*);
 68
 69  virtual void  update(F32 dt, F32 elapsed, Point3F& pos, MatrixF& ori, Point3F& pos2, 
 70                       Point3F& scale);
 71};
 72
 73//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 74
 75IMPLEMENT_CO_DATABLOCK_V1(afxXM_OscillateZodiacColorData);
 76
 77ConsoleDocClass( afxXM_OscillateZodiacColorData,
 78   "@brief An xmod datablock.\n\n"
 79
 80   "@ingroup afxXMods\n"
 81   "@ingroup AFX\n"
 82   "@ingroup Datablocks\n"
 83);
 84
 85afxXM_OscillateZodiacColorData::afxXM_OscillateZodiacColorData()
 86{
 87  color_a.set(0.0f, 0.0f, 0.0f, 0.0f);
 88  color_b.set(1.0f, 1.0f, 1.0f, 1.0f);
 89  speed = 1.0f;
 90}
 91
 92void afxXM_OscillateZodiacColorData::initPersistFields()
 93{
 94  addField("colorA",              TypeColorF,   Offset(color_a,   afxXM_OscillateZodiacColorData),
 95    "...");
 96  addField("colorB",              TypeColorF,   Offset(color_b,   afxXM_OscillateZodiacColorData),
 97    "...");
 98  addField("speed",               TypeF32,      Offset(speed, afxXM_OscillateZodiacColorData),
 99    "...");
100
101  Parent::initPersistFields();
102}
103
104void afxXM_OscillateZodiacColorData::packData(BitStream* stream)
105{
106  Parent::packData(stream);
107  stream->write(color_a);
108  stream->write(color_b);
109  stream->write(speed);
110}
111
112void afxXM_OscillateZodiacColorData::unpackData(BitStream* stream)
113{
114  Parent::unpackData(stream);
115  stream->read(&color_a);
116  stream->read(&color_b);
117  stream->read(&speed);
118}
119
120afxXM_Base* afxXM_OscillateZodiacColorData::create(afxEffectWrapper* fx, bool on_server)
121{
122  return new afxXM_OscillateZodiacColor(this, fx);
123}
124
125//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
126
127afxXM_OscillateZodiacColor::afxXM_OscillateZodiacColor(afxXM_OscillateZodiacColorData* db, afxEffectWrapper* fxw) 
128: afxXM_WeightedBase(db, fxw) 
129{ 
130  color_a = db->color_a;
131  color_b = db->color_b;
132  speed = db->speed;
133
134  const AbstractClassRep::Field* field;
135  field = fxw->getClassRep()->findField(StringTable->insert("liveColor"));
136  if (field && field->type == TypeColorF)
137    liveColor_ptr = (LinearColorF*)(((const char *)(fxw)) + field->offset);
138  else
139    liveColor_ptr = 0;
140
141  field = fxw->getClassRep()->findField(StringTable->insert("liveColorFactor"));
142  if (field && field->type == TypeF32)
143    liveColorFactor_ptr = (F32*)(((const char *)(fxw)) + field->offset);
144  else
145    liveColorFactor_ptr = 0;
146}
147
148void afxXM_OscillateZodiacColor::update(F32 dt, F32 elapsed, Point3F& pos, MatrixF& ori, Point3F& pos2, Point3F& scale)
149{
150  F32 wt_factor = calc_weight_factor(elapsed);
151
152  if (liveColor_ptr)
153  {
154    F32 t = (1.0f + mSin((3.0f*M_PI_F)/2.0f + speed*elapsed*M_2PI_F))*0.5f;
155    liveColor_ptr->interpolate(color_a, color_b, t);
156  }
157
158  if (liveColorFactor_ptr)
159    *liveColorFactor_ptr = wt_factor;
160}
161
162//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
163