afxCameraShake.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #include "afx/arcaneFX.h"
  25. #include "console/consoleTypes.h"
  26. #include "core/stream/bitStream.h"
  27. #include "afx/ce/afxCameraShake.h"
  28. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  29. // afxCameraShakeData
  30. IMPLEMENT_CO_DATABLOCK_V1(afxCameraShakeData);
  31. ConsoleDocClass( afxCameraShakeData,
  32. "@brief A datablock that specifies a Camera Shake effect.\n\n"
  33. "Camera Shake internally utilizes the standard Torque CameraShake class to implement a shaken camera effect."
  34. "\n\n"
  35. "@ingroup afxEffects\n"
  36. "@ingroup AFX\n"
  37. "@ingroup Datablocks\n"
  38. );
  39. afxCameraShakeData::afxCameraShakeData()
  40. {
  41. camShakeFreq.set( 10.0, 10.0, 10.0 );
  42. camShakeAmp.set( 1.0, 1.0, 1.0 );
  43. camShakeRadius = 10.0;
  44. camShakeFalloff = 10.0;
  45. }
  46. afxCameraShakeData::afxCameraShakeData(const afxCameraShakeData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  47. {
  48. camShakeFreq = other.camShakeFreq;
  49. camShakeAmp = other.camShakeAmp;
  50. camShakeRadius = other.camShakeRadius;
  51. camShakeFalloff = other.camShakeFalloff;
  52. }
  53. #define myOffset(field) Offset(field, afxCameraShakeData)
  54. void afxCameraShakeData::initPersistFields()
  55. {
  56. addField("frequency", TypePoint3F, Offset(camShakeFreq, afxCameraShakeData),
  57. "The camera shake frequencies for all three axes: X, Y, Z.");
  58. addField("amplitude", TypePoint3F, Offset(camShakeAmp, afxCameraShakeData),
  59. "The camera shake amplitudes for all three axes: X, Y, Z.");
  60. addField("radius", TypeF32, Offset(camShakeRadius, afxCameraShakeData),
  61. "Radius about the effect position in which shaking will be applied.");
  62. addField("falloff", TypeF32, Offset(camShakeFalloff, afxCameraShakeData),
  63. "Magnitude by which shaking decreases over distance to radius.");
  64. Parent::initPersistFields();
  65. }
  66. bool afxCameraShakeData::onAdd()
  67. {
  68. if (Parent::onAdd() == false)
  69. return false;
  70. return true;
  71. }
  72. void afxCameraShakeData::packData(BitStream* stream)
  73. {
  74. Parent::packData(stream);
  75. stream->write(camShakeFreq.x);
  76. stream->write(camShakeFreq.y);
  77. stream->write(camShakeFreq.z);
  78. stream->write(camShakeAmp.x);
  79. stream->write(camShakeAmp.y);
  80. stream->write(camShakeAmp.z);
  81. stream->write(camShakeRadius);
  82. stream->write(camShakeFalloff);
  83. }
  84. void afxCameraShakeData::unpackData(BitStream* stream)
  85. {
  86. Parent::unpackData(stream);
  87. stream->read(&camShakeFreq.x);
  88. stream->read(&camShakeFreq.y);
  89. stream->read(&camShakeFreq.z);
  90. stream->read(&camShakeAmp.x);
  91. stream->read(&camShakeAmp.y);
  92. stream->read(&camShakeAmp.z);
  93. stream->read(&camShakeRadius);
  94. stream->read(&camShakeFalloff);
  95. }
  96. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//