Torque3D Documentation / _generateds / VActorPhysicsController.h

VActorPhysicsController.h

Engine/source/Verve/VActor/VActorPhysicsController.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Verve
  4// Copyright (C) 2014 - Violent Tulip
  5//
  6// Permission is hereby granted, free of charge, to any person obtaining a copy
  7// of this software and associated documentation files (the "Software"), to
  8// deal in the Software without restriction, including without limitation the
  9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10// sell copies of the Software, and to permit persons to whom the Software is
 11// furnished to do so, subject to the following conditions:
 12//
 13// The above copyright notice and this permission notice shall be included in
 14// all copies or substantial portions of the Software.
 15//
 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 22// IN THE SOFTWARE.
 23//-----------------------------------------------------------------------------
 24#ifndef _VT_VACTORPHYSICSCONTROLLER_H_
 25#define _VT_VACTORPHYSICSCONTROLLER_H_
 26
 27#ifndef _VT_TYPES_H_
 28#include "Types/VTypes.h"
 29#endif
 30
 31#ifndef _VT_VACTORSTATETABLE_H_
 32#include "VActorStateTable.h"
 33#endif
 34
 35#ifndef _VT_VACTOR_H_
 36#include "VActor.h"
 37#endif
 38
 39#ifndef _VT_VINTERPCONTROLLER_H_
 40#include "VInterpController.h"
 41#endif
 42
 43#ifndef _BOXCONVEX_H_
 44#include "collision/boxConvex.h"
 45#endif
 46
 47//-----------------------------------------------------------------------------
 48
 49class VPath;
 50
 51//-----------------------------------------------------------------------------
 52
 53class VActorPhysicsController
 54{
 55protected:
 56
 57    SimObjectPtr<VActor>         mObject;
 58    SimObjectPtr<VPath>          mMountedPath;
 59
 60    VActorStateTable             mPhysicsStateTable;
 61
 62    VInterpController            mInterpController;
 63
 64    U32                          mPhysicsState;
 65    U32                          mControlState;
 66    U32                          mMoveState;
 67
 68    OrthoBoxConvex               mConvex;
 69
 70    VectorF                      mGravity;
 71    VectorF                      mVelocity;
 72
 73    bool                         mOnGround;
 74    SimObjectPtr<SceneObject>    mGroundObject;
 75    VectorF                      mGroundNormal;
 76
 77public:
 78
 79    VActorPhysicsController( void );
 80    virtual ~VActorPhysicsController( void );
 81
 82    // Initialisation Methods.
 83
 84    bool                     initPhysicsController( VActor *pObject );
 85    bool                     initPhysicsTable( void );
 86
 87    // Accessor Methods.
 88
 89    bool                     isValidObject( void );
 90    VActor                  *getObject( void );
 91    VActorData              *getObjectDataBlock( void );
 92    void                     clearObject( void );
 93
 94    virtual const U32        getControlState( void );
 95    virtual void             clearControlState( const U32 &pControlState );
 96    virtual void             setControlState( const U32 &pControlState );
 97
 98    virtual const bool       isMoving( void );
 99    virtual const bool       isMoving( const U32 &pMoveState );
100    virtual const U32        getMoveState( void );
101    virtual void             clearMoveState( const U32 &pMoveState );
102    virtual void             setMoveState( const U32 &pMoveState );
103
104    virtual const bool       isPathing( void );
105    virtual VPath           *getPathObject( void );
106
107    virtual const bool       isInWater( void );
108    virtual WaterObject     *getWaterObject( void );
109
110    virtual const bool       isOnGround( void );
111    virtual const bool       isInAir( void );
112    inline  SceneObject     *getGroundObject( void ) { return mGroundObject; };
113    inline  const VectorF   &getGroundNormal( void ) { return mGroundNormal; };
114
115    inline  const U32       &getPhysicsState( void ) { return mPhysicsState; };
116    inline  void             setPhysicsState( const U32 &pState ) { mPhysicsState = pState; };
117
118    virtual MatrixF          getTransform( void );
119    virtual void             setTransform( const MatrixF &pTransform );
120
121    virtual Point3F          getPosition( void );
122    virtual void             setPosition( const Point3F &pPosition );
123
124    inline  VectorF          getGravity( void ) { return mGravity; };
125    inline  void             setGravity( VectorF &pGravity ) { mGravity = pGravity; };
126    virtual void             applyGravity( const F32 &pElapsedTime );
127
128    virtual VectorF          getVelocity( void );
129    virtual void             setVelocity( const VectorF &pVelocity );
130
131    // Physics Methods.
132
133    void                     update( const F32 &pDelta, const Move *pMove );
134
135    virtual void             preTickUpdate( const F32 &pDelta );
136    virtual void             integrateTickUpdate( const F32 &pDelta, const Move *pMove );
137    virtual void             postTickUpdate( const F32 &pDelta );
138
139    void                     interpolateTick( const F32 &pDelta );
140
141    void                     updateWorkingCollisionSet( void );
142
143    void                     updateMoveState( void );
144
145    void                     clearGroundStatus( void );
146    void                     updateGroundStatus( void );
147    bool                     findGroundContact( SceneObject *&pContactObject, Point3F &pContactPoint, VectorF &pContactNormal );
148
149    void                     processCollisions( void );
150    bool                     findCollision( Collision *&pCollision );
151    void                     solveCollision( Collision *pCollision );
152
153    // Updates Methods.
154
155    void                     onActorEvent( const VActor::eEventType &pEvent );
156
157    U32                      packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream );
158    void                     unpackUpdate( NetConnection *pConnection, BitStream *pStream );
159};
160
161#endif // _VT_VACTORANIMATIONCONTROLLER_H_
162