fxShapeReplicator.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. InteriorObjectType | \
  36. StaticShapeObjectType | \
  37. WaterObjectType )
  38. #define FXREPLICATOR_NOWATER_COLLISION_MASK ( TerrainObjectType | \
  39. InteriorObjectType | \
  40. StaticShapeObjectType )
  41. //------------------------------------------------------------------------------
  42. // Class: fxShapeReplicatedStatic
  43. //------------------------------------------------------------------------------
  44. class fxShapeReplicatedStatic : public TSStatic
  45. {
  46. private:
  47. typedef SceneObject Parent;
  48. public:
  49. fxShapeReplicatedStatic() {};
  50. ~fxShapeReplicatedStatic() {};
  51. void touchNetFlags(const U32 m, bool setflag = true) { if (setflag) mNetFlags.set(m); else mNetFlags.clear(m); };
  52. TSShape* getShape(void) { return mShapeInstance->getShape(); };
  53. void setTransform(const MatrixF & mat) { Parent::setTransform(mat); setRenderTransform(mat); };
  54. DECLARE_CONOBJECT(fxShapeReplicatedStatic);
  55. };
  56. //------------------------------------------------------------------------------
  57. // Class: fxShapeReplicator
  58. //------------------------------------------------------------------------------
  59. class fxShapeReplicator : public SceneObject
  60. {
  61. private:
  62. typedef SceneObject Parent;
  63. protected:
  64. void CreateShapes(void);
  65. void DestroyShapes(void);
  66. void RenewShapes(void);
  67. enum { ReplicationMask = (1 << 0) };
  68. U32 mCreationAreaAngle;
  69. U32 mCurrentShapeCount;
  70. Vector<fxShapeReplicatedStatic*> mReplicatedShapes;
  71. MRandomLCG RandomGen;
  72. S32 mLastRenderTime;
  73. public:
  74. fxShapeReplicator();
  75. ~fxShapeReplicator();
  76. void StartUp(void);
  77. void ShowReplication(void);
  78. void HideReplication(void);
  79. GFXStateBlockRef mPlacementSB;
  80. void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance*);
  81. void renderArc(const F32 fRadiusX, const F32 fRadiusY);
  82. void renderPlacementArea(const F32 ElapsedTime);
  83. // SceneObject
  84. virtual void prepRenderImage( SceneRenderState *state );
  85. // SimObject
  86. bool onAdd();
  87. void onRemove();
  88. void inspectPostApply();
  89. // NetObject
  90. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
  91. void unpackUpdate(NetConnection *conn, BitStream *stream);
  92. // Editor
  93. void onGhostAlwaysDone();
  94. // ConObject.
  95. static void initPersistFields();
  96. // Field Data.
  97. class tagFieldData
  98. {
  99. public:
  100. U32 mSeed;
  101. StringTableEntry mShapeFile;
  102. U32 mShapeCount;
  103. U32 mShapeRetries;
  104. Point3F mShapeScaleMin;
  105. Point3F mShapeScaleMax;
  106. Point3F mShapeRotateMin;
  107. Point3F mShapeRotateMax;
  108. U32 mInnerRadiusX;
  109. U32 mInnerRadiusY;
  110. U32 mOuterRadiusX;
  111. U32 mOuterRadiusY;
  112. S32 mOffsetZ;
  113. bool mAllowOnTerrain;
  114. bool mAllowOnInteriors;
  115. bool mAllowStatics;
  116. bool mAllowOnWater;
  117. S32 mAllowedTerrainSlope;
  118. bool mAlignToTerrain;
  119. bool mAllowWaterSurface;
  120. Point3F mTerrainAlignment;
  121. bool mInteractions;
  122. bool mHideReplications;
  123. bool mShowPlacementArea;
  124. U32 mPlacementBandHeight;
  125. ColorF mPlaceAreaColour;
  126. tagFieldData()
  127. {
  128. // Set Defaults.
  129. mSeed = 1376312589;
  130. mShapeFile = StringTable->insert("");
  131. mShapeCount = 10;
  132. mShapeRetries = 100;
  133. mInnerRadiusX = 0;
  134. mInnerRadiusY = 0;
  135. mOuterRadiusX = 100;
  136. mOuterRadiusY = 100;
  137. mOffsetZ = 0;
  138. mAllowOnTerrain = true;
  139. mAllowOnInteriors = true;
  140. mAllowStatics = true;
  141. mAllowOnWater = false;
  142. mAllowWaterSurface = false;
  143. mAllowedTerrainSlope= 90;
  144. mAlignToTerrain = false;
  145. mInteractions = true;
  146. mHideReplications = false;
  147. mShowPlacementArea = true;
  148. mPlacementBandHeight = 25;
  149. mPlaceAreaColour .set(0.4f, 0, 0.8f);
  150. mShapeScaleMin .set(1, 1, 1);
  151. mShapeScaleMax .set(1, 1, 1);
  152. mShapeRotateMin .set(0, 0, 0);
  153. mShapeRotateMax .set(0, 0, 0);
  154. mTerrainAlignment .set(1, 1, 1);
  155. }
  156. } mFieldData;
  157. // Declare Console Object.
  158. DECLARE_CONOBJECT(fxShapeReplicator);
  159. };
  160. #endif // _SHAPEREPLICATOR_H_