pathManager.h

Engine/source/scene/pathManager.h

More...

Classes:

Detailed Description

Public Variables

PathManager * gClientPathManager 
PathManager * gServerPathManager 
  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 _PATHMANAGER_H_
 25#define _PATHMANAGER_H_
 26
 27#ifndef _PLATFORM_H_
 28#include "platform/platform.h"
 29#endif
 30#ifndef _TVECTOR_H_
 31#include "core/util/tVector.h"
 32#endif
 33#ifndef _MPOINT3_H_
 34#include "math/mPoint3.h"
 35#endif
 36#ifndef _MQUAT_H_
 37#include "math/mQuat.h"
 38#endif
 39#ifndef _SCENEOBJECT_H_
 40#include "scene/sceneObject.h"
 41#endif
 42
 43class NetConnection;
 44class BitStream;
 45
 46class PathManager
 47{
 48   friend class PathManagerEvent;
 49
 50  private:
 51   struct PathEntry {
 52      U32             totalTime;
 53
 54      Vector<Point3F> positions;
 55      Vector<QuatF>   rotations;
 56      Vector<U32>     smoothingType;
 57      Vector<U32>     msToNext;
 58
 59      PathEntry() {
 60         VECTOR_SET_ASSOCIATION(positions);
 61         VECTOR_SET_ASSOCIATION(rotations);
 62         VECTOR_SET_ASSOCIATION(smoothingType);
 63         VECTOR_SET_ASSOCIATION(msToNext);
 64      }
 65   };
 66
 67   Vector<PathEntry*> mPaths;
 68
 69  public:
 70   enum PathType {
 71      BackAndForth,
 72      Looping
 73   };
 74
 75  public:
 76   PathManager(const bool isServer);
 77   ~PathManager();
 78
 79   void clearPaths();
 80
 81   //-------------------------------------- Path querying
 82  public:
 83   bool isValidPath(const U32 id) const;
 84   void getPathPosition(const U32 id, const F64 msPosition, Point3F& rPosition, QuatF &rotation);
 85   U32  getPathTotalTime(const U32 id) const;
 86   U32  getPathNumWaypoints(const U32 id) const;
 87   U32  getWaypointTime(const U32 id, const U32 wayPoint) const;
 88
 89   U32 getPathTimeBits(const U32 id);
 90   U32 getPathWaypointBits(const U32 id);
 91
 92   //-------------------------------------- Path Registration/Transmission/Management
 93  public:
 94   // Called after mission load to clear out the paths on the client, and to transmit
 95   //  the information for the current mission's paths.
 96   void transmitPaths(NetConnection*);
 97   void transmitPath(U32);
 98
 99   U32  allocatePathId();
100   void updatePath(const U32 id, const Vector<Point3F>&, const Vector<QuatF>&, const Vector<U32> &, const Vector<U32>&);
101
102   //-------------------------------------- State dumping/reading
103  public:
104   bool dumpState(BitStream*) const;
105   bool readState(BitStream*);
106
107  private:
108   bool mIsServer;
109   bool mPathsSent;
110};
111
112struct PathNode {
113   Point3F  position;
114   QuatF    rotation;
115   U32      smoothingType;
116   U32      msToNext;
117};
118
119extern PathManager* gClientPathManager;
120extern PathManager* gServerPathManager;
121
122//--------------------------------------------------------------------------
123inline bool PathManager::isValidPath(const U32 id) const
124{
125   return (id < U32(mPaths.size())) && mPaths[id]->positions.size() > 0;
126}
127
128
129
130#endif // _H_PATHMANAGER
131