afxPhysicalZone.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 "T3D/physicalZone.h"
  26. #include "afx/ce/afxPhysicalZone.h"
  27. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  28. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  29. // afxPhysicalZoneData
  30. IMPLEMENT_CO_DATABLOCK_V1(afxPhysicalZoneData);
  31. ConsoleDocClass( afxPhysicalZoneData,
  32. "@brief A datablock that specifies a PhysicalZone effect.\n\n"
  33. "A Physical Zone is a Torque effect that applies physical forces to Players and other movable objects that enter a specific "
  34. "region of influence. AFX has enhanced Physical Zones by allowing orientation of vector forces and adding radial forces. "
  35. "AFX has also optimized Physical Zone networking so that they can be constrained to moving objects for a variety of "
  36. "effects including repelling and flying."
  37. "\n\n"
  38. "@ingroup afxEffects\n"
  39. "@ingroup AFX\n"
  40. "@ingroup Datablocks\n"
  41. );
  42. afxPhysicalZoneData::afxPhysicalZoneData()
  43. {
  44. mVelocityMod = 1.0f;
  45. mGravityMod = 1.0f;
  46. mAppliedForce.zero();
  47. mPolyhedron = ST_NULLSTRING;
  48. force_type = PhysicalZone::VECTOR;
  49. orient_force = false;
  50. exclude_cons_obj = false;
  51. }
  52. afxPhysicalZoneData::afxPhysicalZoneData(const afxPhysicalZoneData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  53. {
  54. mVelocityMod = other.mVelocityMod;
  55. mGravityMod = other.mGravityMod;
  56. mAppliedForce = other.mAppliedForce;
  57. mPolyhedron = other.mPolyhedron;
  58. force_type = other.force_type;
  59. orient_force = other.orient_force;
  60. exclude_cons_obj = other.exclude_cons_obj;
  61. }
  62. #define myOffset(field) Offset(field, afxPhysicalZoneData)
  63. void afxPhysicalZoneData::initPersistFields()
  64. {
  65. addField("velocityMod", TypeF32, myOffset(mVelocityMod),
  66. "A multiplier that biases the velocity of an object every tick it is within the "
  67. "zone.");
  68. addField("gravityMod", TypeF32, myOffset(mGravityMod),
  69. "A multiplier that biases the influence of gravity on objects within the zone.");
  70. addField("appliedForce", TypePoint3F, myOffset(mAppliedForce),
  71. "A three-valued vector representing a directional force applied to objects withing "
  72. "the zone.");
  73. addField("polyhedron", TypeString, myOffset(mPolyhedron),
  74. "Floating point values describing the outer bounds of the PhysicalZone's region of "
  75. "influence.");
  76. addField("forceType", TYPEID<PhysicalZone::ForceType>(), myOffset(force_type),
  77. "This enumerated attribute defines the type of force used in the PhysicalZone. "
  78. "Possible values: vector, sphere, or cylinder.");
  79. addField("orientForce", TypeBool, myOffset(orient_force),
  80. "Determines if the force can be oriented by the PhysicalZone's transform matrix.");
  81. addField("excludeConstraintObject", TypeBool, myOffset(exclude_cons_obj),
  82. "When true, an object used as the primary position constraint of a physical-zone "
  83. "effect will not be influenced by the forces of the zone.");
  84. Parent::initPersistFields();
  85. }
  86. void afxPhysicalZoneData::packData(BitStream* stream)
  87. {
  88. Parent::packData(stream);
  89. }
  90. void afxPhysicalZoneData::unpackData(BitStream* stream)
  91. {
  92. Parent::unpackData(stream);
  93. }
  94. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//