VPathNode.h

Engine/source/Verve/VPath/VPathNode.h

More...

Classes:

Public Typedefs

VPathNodeOrientationType 

Detailed Description

Public Typedefs

typedef VPathNode::eOrientationType VPathNodeOrientationType 

Public Functions

DefineEnumType(VPathNodeOrientationType )

  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_VPATHNODE_H_
 25#define _VT_VPATHNODE_H_
 26
 27#ifndef _GAMEBASE_H_
 28#include "T3D/gameBase/gameBase.h"
 29#endif
 30
 31#ifndef _VNETSTATE_H_
 32#include "VNetState.h"
 33#endif
 34
 35//-----------------------------------------------------------------------------
 36
 37class VPath;
 38class VPathNode
 39{
 40public:
 41
 42    enum eState
 43    {
 44        k_StateUpdatePosition    = BIT( 0 ),
 45        k_StateUpdateRotation    = BIT( 1 ),
 46        k_StateUpdateWeight      = BIT( 2 ),
 47
 48        k_StateUpdateOrientation = BIT( 3 ),
 49
 50        k_StateCreate            = BIT( 4 ),
 51        k_StateDelete            = BIT( 5 ),
 52
 53        k_StateUpdate            = ( k_StateUpdatePosition | k_StateUpdateRotation | k_StateUpdateWeight | k_StateUpdateOrientation ),
 54
 55        k_StateInit              = ( k_StateCreate | k_StateUpdate ),
 56    };
 57
 58    enum eOrientationType
 59    {
 60        k_OrientationFree,
 61        k_OrientationToPoint,
 62
 63        k_OrientationTypeSize,
 64    };
 65
 66    struct sOrientation
 67    {
 68        eOrientationType    Type;
 69
 70        // k_OrientationToPoint
 71        Point3F             Point;
 72    };
 73
 74protected:
 75
 76    VPath          *mPath;
 77
 78    VNetState       mNetState;
 79
 80    sOrientation    mOrientationMode;
 81
 82    Point3F         mLocalPosition;
 83    QuatF           mLocalRotation;
 84
 85    Point3F         mWorldPosition;
 86    QuatF           mWorldRotation;
 87
 88    F32             mWeight;
 89    F32             mLength;
 90
 91public:
 92
 93    VPathNode( void );
 94    virtual ~VPathNode( void );
 95
 96    // Serialisation Methods.
 97
 98    virtual U32             packNode( NetConnection *pConnection, BitStream *pStream );
 99    virtual void            unpackNode( NetConnection *pConnection, BitStream *pStream );
100
101    virtual String          toString( void );
102    virtual bool            fromString( const String &pString );
103
104    //-------------------------------------------------------------------------
105    //
106    // Gets
107    //
108    //-------------------------------------------------------------------------
109
110    inline VPath               *getPath( void ) const { return mPath; };
111
112    inline const Point3F       &getLocalPosition( void ) const { return mLocalPosition; };
113    inline const QuatF         &getLocalRotation( void ) const { return mLocalRotation; };
114
115    virtual Point3F             getWorldPosition( void ) const;
116    virtual QuatF               getWorldRotation( void ) const;
117    virtual MatrixF             getWorldTransform( void ) const;
118
119    inline const F32            &getWeight( void ) const { return mWeight; };
120    inline const F32            &getLength( void ) const { return mLength; };
121
122    inline const sOrientation   &getOrientationMode( void ) const { return mOrientationMode; };
123
124    //-------------------------------------------------------------------------
125    //
126    // Sets
127    //
128    //-------------------------------------------------------------------------
129
130    inline void             setPath( VPath *pPath ) { mPath = pPath; };
131
132    void                    setLocalPosition( const Point3F &pPosition );
133    void                    setLocalRotation( const QuatF &pRotation );
134
135    inline void             setWorldPosition( const Point3F &pPosition ) { mWorldPosition = pPosition; };
136    inline void             setWorldRotation( const QuatF &pRotation ) { mWorldRotation = pRotation; };
137
138    void                    setWeight( const F32 &pWeight );
139    inline void             setLength( const F32 &pLength ) { mLength = pLength; };
140    
141    void                    setOrientationMode( const eOrientationType &pType );
142    void                    setOrientationMode( const eOrientationType &pType, const Point3F &pPoint );
143
144    void                    updateWorldData( void );
145
146    // Net State Methods.
147
148    inline VNetStateInfo   *getState( NetConnection *pConnection ) { return mNetState.getState( pConnection );         };
149
150    inline void             setMaskBits( const U32 &pMask ) { mNetState.setMaskBits( pMask );                          };
151    inline void             clearMaskBits( const U32 &pMask ) { mNetState.clearMaskBits( pMask );                      };
152
153    inline bool             isConnection( NetConnection *pConnection ) { return mNetState.isConnection( pConnection ); };
154    inline void             addConnection( NetConnection *pConnection ) { mNetState.addConnection( pConnection );      };
155    inline void             clearConnection( NetConnection *pConnection ) { mNetState.clearConnection( pConnection );  };
156
157    // Enum Methods.
158
159    static eOrientationType    getOrientationTypeEnum( const char *pLabel );
160    static StringTableEntry    getOrientationTypeLabel( const eOrientationType &pType );
161};
162
163//-----------------------------------------------------------------------------
164
165// Define Types.
166typedef VPathNode::eOrientationType VPathNodeOrientationType;
167
168// Declare Enum Types.
169DefineEnumType( VPathNodeOrientationType );
170
171//-----------------------------------------------------------------------------
172
173#endif // _VT_VPATHNODE_H_
174