fxShapeReplicator.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SHAPEREPLICATOR_H_
  23. #define _SHAPEREPLICATOR_H_
  24. #ifndef _TSSTATIC_H_
  25. #include "T3D/tsStatic.h"
  26. #endif
  27. #ifndef _TSSHAPEINSTANCE_H_
  28. #include "ts/tsShapeInstance.h"
  29. #endif
  30. #ifndef _RENDERPASSMANAGER_H_
  31. #include "renderInstance/renderPassManager.h"
  32. #endif
  33. #define AREA_ANIMATION_ARC (1.0f / 360.0f)
  34. #define FXREPLICATOR_COLLISION_MASK ( TerrainObjectType | \
  35. StaticShapeObjectType | \
  36. WaterObjectType )
  37. #define FXREPLICATOR_NOWATER_COLLISION_MASK ( TerrainObjectType | \
  38. StaticShapeObjectType )
  39. //------------------------------------------------------------------------------
  40. // Class: fxShapeReplicatedStatic
  41. //------------------------------------------------------------------------------
  42. class fxShapeReplicatedStatic : public TSStatic
  43. {
  44. private:
  45. typedef SceneObject Parent;
  46. public:
  47. fxShapeReplicatedStatic() {};
  48. ~fxShapeReplicatedStatic() {};
  49. void touchNetFlags(const U32 m, bool setflag = true) { if (setflag) mNetFlags.set(m); else mNetFlags.clear(m); };
  50. TSShape* getShape(void) { return mShapeInstance->getShape(); };
  51. void setTransform(const MatrixF & mat) { Parent::setTransform(mat); setRenderTransform(mat); };
  52. DECLARE_CONOBJECT(fxShapeReplicatedStatic);
  53. };
  54. //------------------------------------------------------------------------------
  55. // Class: fxShapeReplicator
  56. //------------------------------------------------------------------------------
  57. class fxShapeReplicator : public SceneObject
  58. {
  59. private:
  60. typedef SceneObject Parent;
  61. protected:
  62. void CreateShapes(void);
  63. void DestroyShapes(void);
  64. void RenewShapes(void);
  65. enum { ReplicationMask = (1 << 0) };
  66. U32 mCreationAreaAngle;
  67. U32 mCurrentShapeCount;
  68. Vector<fxShapeReplicatedStatic*> mReplicatedShapes;
  69. MRandomLCG RandomGen;
  70. S32 mLastRenderTime;
  71. public:
  72. fxShapeReplicator();
  73. ~fxShapeReplicator();
  74. void StartUp(void);
  75. void ShowReplication(void);
  76. void HideReplication(void);
  77. GFXStateBlockRef mPlacementSB;
  78. void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance*);
  79. void renderArc(const F32 fRadiusX, const F32 fRadiusY);
  80. void renderPlacementArea(const F32 ElapsedTime);
  81. // SceneObject
  82. virtual void prepRenderImage( SceneRenderState *state );
  83. // SimObject
  84. bool onAdd();
  85. void onRemove();
  86. void inspectPostApply();
  87. // NetObject
  88. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
  89. void unpackUpdate(NetConnection *conn, BitStream *stream);
  90. // Editor
  91. void onGhostAlwaysDone();
  92. // ConObject.
  93. static void initPersistFields();
  94. // Field Data.
  95. class tagFieldData
  96. {
  97. public:
  98. U32 mSeed;
  99. StringTableEntry mShapeFile;
  100. U32 mShapeCount;
  101. U32 mShapeRetries;
  102. Point3F mShapeScaleMin;
  103. Point3F mShapeScaleMax;
  104. Point3F mShapeRotateMin;
  105. Point3F mShapeRotateMax;
  106. U32 mInnerRadiusX;
  107. U32 mInnerRadiusY;
  108. U32 mOuterRadiusX;
  109. U32 mOuterRadiusY;
  110. S32 mOffsetZ;
  111. bool mAllowOnTerrain;
  112. bool mAllowStatics;
  113. bool mAllowOnWater;
  114. S32 mAllowedTerrainSlope;
  115. bool mAlignToTerrain;
  116. bool mAllowWaterSurface;
  117. Point3F mTerrainAlignment;
  118. bool mInteractions;
  119. bool mHideReplications;
  120. bool mShowPlacementArea;
  121. U32 mPlacementBandHeight;
  122. LinearColorF mPlaceAreaColour;
  123. tagFieldData()
  124. {
  125. // Set Defaults.
  126. mSeed = 1376312589;
  127. mShapeFile = StringTable->EmptyString();
  128. mShapeCount = 10;
  129. mShapeRetries = 100;
  130. mInnerRadiusX = 0;
  131. mInnerRadiusY = 0;
  132. mOuterRadiusX = 100;
  133. mOuterRadiusY = 100;
  134. mOffsetZ = 0;
  135. mAllowOnTerrain = true;
  136. mAllowStatics = true;
  137. mAllowOnWater = false;
  138. mAllowWaterSurface = false;
  139. mAllowedTerrainSlope= 90;
  140. mAlignToTerrain = false;
  141. mInteractions = true;
  142. mHideReplications = false;
  143. mShowPlacementArea = true;
  144. mPlacementBandHeight = 25;
  145. mPlaceAreaColour .set(0.4f, 0, 0.8f);
  146. mShapeScaleMin .set(1, 1, 1);
  147. mShapeScaleMax .set(1, 1, 1);
  148. mShapeRotateMin .set(0, 0, 0);
  149. mShapeRotateMax .set(0, 0, 0);
  150. mTerrainAlignment .set(1, 1, 1);
  151. }
  152. } mFieldData;
  153. // Declare Console Object.
  154. DECLARE_CONOBJECT(fxShapeReplicator);
  155. };
  156. #endif // _SHAPEREPLICATOR_H_