physicalZone.h

Engine/source/T3D/physicalZone.h

More...

Classes:

Detailed Description

  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 _H_PHYSICALZONE
 25#define _H_PHYSICALZONE
 26
 27#ifndef _SCENEOBJECT_H_
 28#include "scene/sceneObject.h"
 29#endif
 30#ifndef _EARLYOUTPOLYLIST_H_
 31#include "collision/earlyOutPolyList.h"
 32#endif
 33#ifndef _MPOLYHEDRON_H_
 34#include "math/mPolyhedron.h"
 35#endif
 36
 37class Convex;
 38
 39
 40class PhysicalZone : public SceneObject
 41{
 42   typedef SceneObject Parent;
 43
 44   enum UpdateMasks {      
 45      ActiveMask        = Parent::NextFreeMask << 0,
 46      NextFreeMask      = Parent::NextFreeMask << 1
 47   };
 48
 49  protected:
 50   static bool smRenderPZones;
 51
 52   F32        mVelocityMod;
 53   F32        mGravityMod;
 54   Point3F    mAppliedForce;
 55
 56   // Basically ripped from trigger
 57   Polyhedron           mPolyhedron;
 58   EarlyOutPolyList     mClippedList;
 59
 60   bool mActive;
 61
 62   Convex* mConvexList;
 63   void buildConvex(const Box3F& box, Convex* convex);
 64
 65  public:
 66   PhysicalZone();
 67   ~PhysicalZone();
 68
 69   // SimObject
 70   DECLARE_CONOBJECT(PhysicalZone);
 71   static void consoleInit();
 72   static void initPersistFields();
 73   bool onAdd();
 74   void onRemove();
 75   void inspectPostApply();
 76
 77   // NetObject
 78   U32  packUpdate  (NetConnection *conn, U32 mask, BitStream *stream);
 79   void unpackUpdate(NetConnection *conn,           BitStream *stream);
 80
 81   // SceneObject
 82   void setTransform(const MatrixF &mat);
 83   void prepRenderImage( SceneRenderState* state );
 84
 85   inline F32 getVelocityMod() const      { return mVelocityMod; }
 86   inline F32 getGravityMod()  const      { return mGravityMod;  }
 87   inline const Point3F& getForce() const { return mAppliedForce; }
 88
 89   void setPolyhedron(const Polyhedron&);
 90   bool testObject(SceneObject*);
 91
 92   bool testBox( const Box3F &box ) const;
 93
 94   void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
 95
 96   void activate();
 97   void deactivate();
 98   inline bool isActive() const { return mActive; }
 99
100};
101
102#endif // _H_PHYSICALZONE
103
104