physicalZone.h

Engine/source/T3D/physicalZone.h

More...

Classes:

Public Typedefs

PhysicalZone_ForceType 

Detailed Description

Public Typedefs

typedef PhysicalZone::ForceType PhysicalZone_ForceType 

Public Functions

DefineEnumType(PhysicalZone_ForceType )

  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//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 25// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
 26// Copyright (C) 2015 Faust Logic, Inc.
 27//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 28
 29#ifndef _H_PHYSICALZONE
 30#define _H_PHYSICALZONE
 31
 32#ifndef _SCENEOBJECT_H_
 33#include "scene/sceneObject.h"
 34#endif
 35#ifndef _EARLYOUTPOLYLIST_H_
 36#include "collision/earlyOutPolyList.h"
 37#endif
 38#ifndef _MPOLYHEDRON_H_
 39#include "math/mPolyhedron.h"
 40#endif
 41
 42class Convex;
 43
 44
 45class PhysicalZone : public SceneObject
 46{
 47   typedef SceneObject Parent;
 48
 49   enum UpdateMasks {
 50      ActiveMask        = Parent::NextFreeMask << 0,
 51      SettingsMask      = Parent::NextFreeMask << 1,
 52      FadeMask          = Parent::NextFreeMask << 2,
 53      PolyhedronMask    = Parent::NextFreeMask << 3,
 54      MoveMask          = Parent::NextFreeMask << 4,
 55      ExclusionMask     = Parent::NextFreeMask << 5,
 56      NextFreeMask      = Parent::NextFreeMask << 6
 57   };
 58
 59  protected:
 60   static bool smRenderPZones;
 61
 62   F32        mVelocityMod;
 63   F32        mGravityMod;
 64   Point3F    mAppliedForce;
 65
 66   // Basically ripped from trigger
 67   Polyhedron           mPolyhedron;
 68   EarlyOutPolyList     mClippedList;
 69
 70   bool mActive;
 71
 72   Convex* mConvexList;
 73   void buildConvex(const Box3F& box, Convex* convex);
 74
 75  public:
 76   PhysicalZone();
 77   ~PhysicalZone();
 78
 79   // SimObject
 80   DECLARE_CONOBJECT(PhysicalZone);
 81   static void consoleInit();
 82   static void initPersistFields();
 83   bool onAdd();
 84   void onRemove();
 85   void inspectPostApply();
 86
 87   // NetObject
 88   U32  packUpdate  (NetConnection *conn, U32 mask, BitStream *stream);
 89   void unpackUpdate(NetConnection *conn,           BitStream *stream);
 90
 91   // SceneObject
 92   void setTransform(const MatrixF &mat);
 93   void prepRenderImage( SceneRenderState* state );
 94
 95   inline F32 getVelocityMod() const      { return mVelocityMod; }
 96   inline F32 getGravityMod()  const      { return mGravityMod;  }
 97   // the scene object is now passed in to getForce() where
 98   // it is needed to calculate the applied force when the
 99   // force is radial.
100   const Point3F& getForce(const Point3F* center=0) const;
101
102   void setPolyhedron(const Polyhedron&);
103   bool testObject(SceneObject*);
104
105   bool testBox( const Box3F &box ) const;
106
107   void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
108
109   void activate();
110   void deactivate();
111   inline bool isActive() const { return mActive; }
112
113protected:
114   friend class afxPhysicalZoneData;
115   friend class afxEA_PhysicalZone;
116   Vector<SceneObject*>  excluded_objects;
117   S32    force_type;
118   F32    force_mag;
119   bool   orient_force;
120   F32    fade_amt;
121   void   setFadeAmount(F32 amt) { fade_amt = amt; if (fade_amt < 1.0f) setMaskBits(FadeMask); }
122public:
123   enum ForceType { VECTOR, SPHERICAL, CYLINDRICAL };
124   enum { FORCE_TYPE_BITS = 2 };
125   virtual void onStaticModified(const char* slotName, const char*newValue = NULL);
126   bool   isExcludedObject(SceneObject*) const;
127   void   registerExcludedObject(SceneObject*);
128   void   unregisterExcludedObject(SceneObject*);
129};
130
131typedef PhysicalZone::ForceType PhysicalZone_ForceType;
132DefineEnumType( PhysicalZone_ForceType );
133#endif // _H_PHYSICALZONE
134
135