afxXM_Freeze.cpp
Engine/source/afx/xm/afxXM_Freeze.cpp
Classes:
class
class
class
class
class
Public Functions
ConsoleDocClass(afxXM_FreezeData , "@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_FreezeData , "@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_FreezeData )
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 "afx/afxEffectWrapper.h" 30#include "afx/afxChoreographer.h" 31#include "afx/xm/afxXfmMod.h" 32 33//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 34 35class afxXM_FreezeData : public afxXM_BaseData 36{ 37 typedef afxXM_BaseData Parent; 38 39public: 40 U32 mask; 41 F32 delay; 42 43public: 44 /*C*/ afxXM_FreezeData() : mask(POSITION | ORIENTATION | POSITION2), delay(0.0f) { } 45 /*C*/ afxXM_FreezeData(const afxXM_FreezeData&, bool = false); 46 47 void packData(BitStream* stream); 48 void unpackData(BitStream* stream); 49 50 virtual bool allowSubstitutions() const { return true; } 51 52 static void initPersistFields(); 53 54 afxXM_Base* create(afxEffectWrapper* fx, bool on_server); 55 56 DECLARE_CONOBJECT(afxXM_FreezeData); 57 DECLARE_CATEGORY("AFX"); 58}; 59 60//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 61 62class afxXM_Freeze : public afxXM_Base 63{ 64 typedef afxXM_Base Parent; 65 66 U32 mask; 67 bool first; 68 Point3F frozen_pos; 69 MatrixF frozen_ori; 70 Point3F frozen_aim; 71 F32 delay; 72 73public: 74 /*C*/ afxXM_Freeze(afxXM_FreezeData*, afxEffectWrapper*); 75 76 virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); 77}; 78 79//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 80 81class afxXM_Freeze_all_but_scale : public afxXM_Base 82{ 83 typedef afxXM_Base Parent; 84 85 bool first; 86 Point3F frozen_pos; 87 MatrixF frozen_ori; 88 Point3F frozen_aim; 89 F32 delay; 90 91public: 92 /*C*/ afxXM_Freeze_all_but_scale(afxXM_FreezeData*, afxEffectWrapper*); 93 94 virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); 95}; 96 97//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 98 99class afxXM_Freeze_pos : public afxXM_Base 100{ 101 typedef afxXM_Base Parent; 102 103 bool first; 104 Point3F frozen_pos; 105 F32 delay; 106 107public: 108 /*C*/ afxXM_Freeze_pos(afxXM_FreezeData*, afxEffectWrapper*); 109 110 virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); 111}; 112 113//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 114 115class afxXM_Freeze_pos2 : public afxXM_Base 116{ 117 typedef afxXM_Base Parent; 118 119 bool first; 120 Point3F frozen_pos2; 121 F32 delay; 122 123public: 124 /*C*/ afxXM_Freeze_pos2(afxXM_FreezeData*, afxEffectWrapper*); 125 126 virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); 127}; 128 129//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 130 131class afxXM_Freeze_ori : public afxXM_Base 132{ 133 typedef afxXM_Base Parent; 134 135 bool first; 136 MatrixF frozen_ori; 137 F32 delay; 138 139public: 140 /*C*/ afxXM_Freeze_ori(afxXM_FreezeData*, afxEffectWrapper*); 141 142 virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); 143}; 144 145//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 146 147IMPLEMENT_CO_DATABLOCK_V1(afxXM_FreezeData); 148 149ConsoleDocClass( afxXM_FreezeData, 150 "@brief An xmod datablock.\n\n" 151 152 "@ingroup afxXMods\n" 153 "@ingroup AFX\n" 154 "@ingroup Datablocks\n" 155); 156 157afxXM_FreezeData::afxXM_FreezeData(const afxXM_FreezeData& other, bool temp_clone) : afxXM_BaseData(other, temp_clone) 158{ 159 mask = other.mask; 160 delay = other.delay; 161} 162 163void afxXM_FreezeData::initPersistFields() 164{ 165 addField("mask", TypeS32, Offset(mask, afxXM_FreezeData), 166 "..."); 167 addField("delay", TypeF32, Offset(delay, afxXM_FreezeData), 168 "..."); 169 170 Parent::initPersistFields(); 171} 172 173void afxXM_FreezeData::packData(BitStream* stream) 174{ 175 Parent::packData(stream); 176 stream->write(mask); 177 stream->write(delay); 178} 179 180void afxXM_FreezeData::unpackData(BitStream* stream) 181{ 182 Parent::unpackData(stream); 183 stream->read(&mask); 184 stream->read(&delay); 185} 186 187afxXM_Base* afxXM_FreezeData::create(afxEffectWrapper* fx, bool on_server) 188{ 189 afxXM_FreezeData* datablock = this; 190 191 if (getSubstitutionCount() > 0) 192 { 193 datablock = new afxXM_FreezeData(*this, true); 194 this->performSubstitutions(datablock, fx->getChoreographer(), fx->getGroupIndex()); 195 } 196 197 if (datablock->mask == ALL_BUT_SCALE) 198 return new afxXM_Freeze_all_but_scale(datablock, fx); 199 if (datablock->mask == POSITION) 200 return new afxXM_Freeze_pos(datablock, fx); 201 if (datablock->mask == ORIENTATION) 202 return new afxXM_Freeze_ori(datablock, fx); 203 if (datablock->mask == POSITION2) 204 return new afxXM_Freeze_pos2(datablock, fx); 205 return new afxXM_Freeze(datablock, fx); 206} 207 208//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 209 210afxXM_Freeze::afxXM_Freeze(afxXM_FreezeData* db, afxEffectWrapper* fxw) 211: afxXM_Base(db, fxw) 212{ 213 mask = db->mask; 214 first = true; 215 delay = db->delay; 216} 217 218void afxXM_Freeze::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) 219{ 220 if (elapsed < delay) return; 221 222 if (first) 223 { 224 if (mask & POSITION) 225 frozen_pos = params.pos; 226 if (mask & ORIENTATION) 227 frozen_ori = params.ori; 228 if (mask & POSITION2) 229 frozen_aim = params.pos2; 230 first = false; 231 } 232 else 233 { 234 if (mask & POSITION) 235 params.pos = frozen_pos; 236 if (mask & ORIENTATION) 237 params.ori = frozen_ori; 238 if (mask & POSITION2) 239 params.pos2 = frozen_aim; 240 } 241} 242 243//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 244 245afxXM_Freeze_all_but_scale::afxXM_Freeze_all_but_scale(afxXM_FreezeData* db, afxEffectWrapper* fxw) 246: afxXM_Base(db, fxw) 247{ 248 first = true; 249 delay = db->delay; 250} 251 252void afxXM_Freeze_all_but_scale::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) 253{ 254 if (elapsed < delay) return; 255 256 if (first) 257 { 258 frozen_pos = params.pos; 259 frozen_ori = params.ori; 260 frozen_aim = params.pos2; 261 first = false; 262 } 263 else 264 { 265 params.pos = frozen_pos; 266 params.ori = frozen_ori; 267 params.pos2 = frozen_aim; 268 } 269} 270 271//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 272 273afxXM_Freeze_pos::afxXM_Freeze_pos(afxXM_FreezeData* db, afxEffectWrapper* fxw) 274: afxXM_Base(db, fxw) 275{ 276 first = true; 277 delay = db->delay; 278} 279 280void afxXM_Freeze_pos::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) 281{ 282 if (elapsed < delay) return; 283 284 if (first) 285 { 286 frozen_pos = params.pos; 287 first = false; 288 } 289 else 290 params.pos = frozen_pos; 291} 292 293//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 294 295afxXM_Freeze_pos2::afxXM_Freeze_pos2(afxXM_FreezeData* db, afxEffectWrapper* fxw) 296: afxXM_Base(db, fxw) 297{ 298 first = true; 299 delay = db->delay; 300} 301 302void afxXM_Freeze_pos2::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) 303{ 304 if (elapsed < delay) return; 305 306 if (first) 307 { 308 frozen_pos2 = params.pos2; 309 first = false; 310 } 311 else 312 params.pos2 = frozen_pos2; 313} 314 315//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// 316 317afxXM_Freeze_ori::afxXM_Freeze_ori(afxXM_FreezeData* db, afxEffectWrapper* fxw) 318: afxXM_Base(db, fxw) 319{ 320 first = true; 321 delay = db->delay; 322} 323 324void afxXM_Freeze_ori::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) 325{ 326 if (elapsed < delay) return; 327 328 if (first) 329 { 330 frozen_ori = params.ori; 331 first = false; 332 } 333 else 334 params.ori = frozen_ori; 335} 336 337//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 338