afxSpotLight_T3D.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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/afxSpotLight_T3D.h"
  28. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  29. // afxT3DSpotLightData
  30. IMPLEMENT_CO_DATABLOCK_V1(afxT3DSpotLightData);
  31. ConsoleDocClass( afxT3DSpotLightData,
  32. "@brief A datablock that specifies a dynamic Spot Light effect.\n\n"
  33. "A Spot Light effect that uses the T3D SpotLight object. afxT3DSpotLightData has the same fields found in SpotLight but in "
  34. "a datablock structure."
  35. "\n\n"
  36. "@ingroup afxEffects\n"
  37. "@ingroup AFX\n"
  38. "@ingroup Datablocks\n"
  39. );
  40. afxT3DSpotLightData::afxT3DSpotLightData()
  41. : mRange( 10.0f ),
  42. mInnerConeAngle( 40.0f ),
  43. mOuterConeAngle( 45.0f )
  44. {
  45. }
  46. afxT3DSpotLightData::afxT3DSpotLightData(const afxT3DSpotLightData& other, bool temp_clone) : afxT3DLightBaseData(other, temp_clone)
  47. {
  48. mRange = other.mRange;
  49. mInnerConeAngle = other.mInnerConeAngle;
  50. mOuterConeAngle = other.mOuterConeAngle;
  51. }
  52. //
  53. // NOTE: keep this as consistent as possible with PointLight::initPersistFields()
  54. //
  55. void afxT3DSpotLightData::initPersistFields()
  56. {
  57. addGroup( "Light" );
  58. addField( "range", TypeF32, Offset( mRange, afxT3DSpotLightData ),
  59. "...");
  60. addField( "innerAngle", TypeF32, Offset( mInnerConeAngle, afxT3DSpotLightData ),
  61. "...");
  62. addField( "outerAngle", TypeF32, Offset( mOuterConeAngle, afxT3DSpotLightData ),
  63. "...");
  64. endGroup( "Light" );
  65. // We do the parent fields at the end so that
  66. // they show up that way in the inspector.
  67. Parent::initPersistFields();
  68. }
  69. bool afxT3DSpotLightData::onAdd()
  70. {
  71. if (Parent::onAdd() == false)
  72. return false;
  73. return true;
  74. }
  75. void afxT3DSpotLightData::packData(BitStream* stream)
  76. {
  77. Parent::packData(stream);
  78. stream->write( mRange );
  79. stream->write( mInnerConeAngle );
  80. stream->write( mOuterConeAngle );
  81. }
  82. void afxT3DSpotLightData::unpackData(BitStream* stream)
  83. {
  84. Parent::unpackData(stream);
  85. stream->read( &mRange );
  86. stream->read( &mInnerConeAngle );
  87. stream->read( &mOuterConeAngle );
  88. }
  89. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//