Torque3D Documentation / _generateds / fxShapeReplicator.h

fxShapeReplicator.h

Engine/source/T3D/fx/fxShapeReplicator.h

More...

Classes:

Public Defines

define
AREA_ANIMATION_ARC() (1.0f / 360.0f)
define

Detailed Description

Public Defines

AREA_ANIMATION_ARC() (1.0f / 360.0f)
FXREPLICATOR_COLLISION_MASK()                               (         |   \
                                    |   \
                                    )
FXREPLICATOR_NOWATER_COLLISION_MASK()                                     (         |   \
                                          )
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  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#ifndef _SHAPEREPLICATOR_H_
 25#define _SHAPEREPLICATOR_H_
 26
 27#ifndef _TSSTATIC_H_
 28#include "T3D/tsStatic.h"
 29#endif
 30#ifndef _TSSHAPEINSTANCE_H_
 31#include "ts/tsShapeInstance.h"
 32#endif
 33#ifndef _RENDERPASSMANAGER_H_
 34#include "renderInstance/renderPassManager.h"
 35#endif
 36
 37#define AREA_ANIMATION_ARC         (1.0f / 360.0f)
 38
 39#define FXREPLICATOR_COLLISION_MASK   (   TerrainObjectType      |   \
 40                              StaticShapeObjectType      |   \
 41                              WaterObjectType      )
 42
 43#define FXREPLICATOR_NOWATER_COLLISION_MASK   (   TerrainObjectType      |   \
 44                                    StaticShapeObjectType      )
 45
 46
 47//------------------------------------------------------------------------------
 48// Class: fxShapeReplicatedStatic
 49//------------------------------------------------------------------------------
 50class fxShapeReplicatedStatic : public TSStatic
 51{
 52private:
 53   typedef SceneObject         Parent;
 54
 55public:
 56   fxShapeReplicatedStatic() {};
 57   ~fxShapeReplicatedStatic() {};
 58   void touchNetFlags(const U32 m, bool setflag = true) { if (setflag) mNetFlags.set(m); else mNetFlags.clear(m); };
 59   TSShape* getShape(void) { return mShapeInstance->getShape(); };
 60   void setTransform(const MatrixF & mat) { Parent::setTransform(mat); setRenderTransform(mat); };
 61
 62   DECLARE_CONOBJECT(fxShapeReplicatedStatic);
 63};
 64
 65
 66//------------------------------------------------------------------------------
 67// Class: fxShapeReplicator
 68//------------------------------------------------------------------------------
 69class fxShapeReplicator : public SceneObject
 70{
 71private:
 72   typedef SceneObject      Parent;
 73
 74protected:
 75
 76   void CreateShapes(void);
 77   void DestroyShapes(void);
 78   void RenewShapes(void);
 79
 80   enum {   ReplicationMask   = (1 << 0) };
 81
 82   U32                              mCreationAreaAngle;
 83   U32                              mCurrentShapeCount;
 84   Vector<fxShapeReplicatedStatic*> mReplicatedShapes;
 85   MRandomLCG                       RandomGen;
 86   S32                              mLastRenderTime;
 87
 88
 89public:
 90   fxShapeReplicator();
 91   ~fxShapeReplicator();
 92
 93
 94   void StartUp(void);
 95   void ShowReplication(void);
 96   void HideReplication(void);
 97
 98   GFXStateBlockRef mPlacementSB;
 99
100   void renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance*);
101   void renderArc(const F32 fRadiusX, const F32 fRadiusY);
102   void renderPlacementArea(const F32 ElapsedTime);
103
104   // SceneObject
105   virtual void prepRenderImage( SceneRenderState *state );
106
107   // SimObject
108   bool onAdd();
109   void onRemove();
110   void inspectPostApply();
111
112   // NetObject
113   U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
114   void unpackUpdate(NetConnection *conn, BitStream *stream);
115
116   // Editor
117   void onGhostAlwaysDone();
118
119   // ConObject.
120   static void initPersistFields();
121
122   // Field Data.
123   class tagFieldData
124   {
125      public:
126
127      U32                mSeed;
128      StringTableEntry   mShapeFile;
129      U32                mShapeCount;
130      U32                mShapeRetries;
131      Point3F            mShapeScaleMin;
132      Point3F            mShapeScaleMax;
133      Point3F            mShapeRotateMin;
134      Point3F            mShapeRotateMax;
135      U32                mInnerRadiusX;
136      U32                mInnerRadiusY;
137      U32                mOuterRadiusX;
138      U32                mOuterRadiusY;
139      S32                mOffsetZ;
140      bool              mAllowOnTerrain;
141      bool              mAllowStatics;
142      bool              mAllowOnWater;
143      S32               mAllowedTerrainSlope;
144      bool              mAlignToTerrain;
145      bool              mAllowWaterSurface;
146      Point3F           mTerrainAlignment;
147      bool              mInteractions;
148      bool              mHideReplications;
149      bool              mShowPlacementArea;
150      U32               mPlacementBandHeight;
151      LinearColorF            mPlaceAreaColour;
152
153      tagFieldData()
154      {
155         // Set Defaults.
156         mSeed               = 1376312589;
157         mShapeFile          = StringTable->EmptyString();
158         mShapeCount         = 10;
159         mShapeRetries       = 100;
160         mInnerRadiusX       = 0;
161         mInnerRadiusY       = 0;
162         mOuterRadiusX       = 100;
163         mOuterRadiusY       = 100;
164         mOffsetZ            = 0;
165
166         mAllowOnTerrain     = true;
167         mAllowStatics       = true;
168         mAllowOnWater       = false;
169         mAllowWaterSurface  = false;
170         mAllowedTerrainSlope= 90;
171         mAlignToTerrain     = false;
172         mInteractions       = true;
173
174         mHideReplications   = false;
175
176         mShowPlacementArea    = true;
177         mPlacementBandHeight  = 25;
178         mPlaceAreaColour      .set(0.4f, 0, 0.8f);
179
180         mShapeScaleMin         .set(1, 1, 1);
181         mShapeScaleMax         .set(1, 1, 1);
182         mShapeRotateMin        .set(0, 0, 0);
183         mShapeRotateMax        .set(0, 0, 0);
184         mTerrainAlignment      .set(1, 1, 1);
185      }
186
187   } mFieldData;
188
189   // Declare Console Object.
190   DECLARE_CONOBJECT(fxShapeReplicator);
191};
192
193#endif // _SHAPEREPLICATOR_H_
194