Planeshift

pspathnetwork.h

Go to the documentation of this file.
00001 /*
00002  * pspathnetwork.h
00003  *
00004  * Copyright (C) 2007 Atomic Blue ([email protected], http://www.atomicblue.org) 
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef __PSPATHNETWORK_H__
00020 #define __PSPATHNETWORK_H__
00021 
00022 #include <csutil/array.h>
00023 #include <csutil/list.h>
00024 
00025 #include <idal.h>
00026 
00027 #include "util/pspath.h"
00028 
00029 class Edge;
00030 class Waypoint;
00031 class WaypointAlias;
00032 class psPath;
00033 class psWorld;
00034 
00042 class psPathNetwork
00043 {
00044 public:
00045 
00049     class RouteFilter
00050     {
00051       public:
00055         virtual bool Filter(const Waypoint* wp) const = 0;
00056     };
00057 
00058 
00059     csPDelArray<Waypoint> waypoints;
00060     csPDelArray<psPath> paths;
00061     
00062     csArray<csString> waypointGroupNames;
00063     csArray< csList<Waypoint*> > waypointGroups;
00064 
00065     csWeakRef<iEngine> engine;
00066     csWeakRef<iDataConnection> db;
00067     psWorld * world;
00068     
00069     
00073     bool Load(iEngine *engine, iDataConnection *db, psWorld * world);
00074 
00079     size_t AddWaypointToGroup(csString group, Waypoint * wp);
00080 
00084     Waypoint *FindWaypoint(int id);
00085 
00092     Waypoint *FindWaypoint(const char * name, WaypointAlias** alias = NULL);
00093     
00100     Waypoint *FindWaypoint(const csVector3& v, iSector *sector);
00101 
00111     Waypoint *FindNearestWaypoint(const csVector3& v,iSector *sector, float range, float * found_range = NULL);
00112 
00122     Waypoint *FindRandomWaypoint(const csVector3& v, iSector *sector, float range, float * found_range = NULL);
00123 
00134     Waypoint *FindNearestWaypoint(int group, const csVector3& v,iSector *sector, float range, float * found_range = NULL);
00135 
00146     Waypoint *FindRandomWaypoint(int group, const csVector3& v, iSector *sector, float range, float * found_range = NULL);
00147 
00151     int FindWaypointGroup(const char * groupName);
00152 
00156     psPathPoint* FindPathPoint(int id);
00157 
00167     psPathPoint* FindPoint(const psPath* path, const csVector3& pos, iSector* sector, float range, int& index);
00168     
00177     psPathPoint* FindNearestPoint(const psPath* path, const csVector3& v, const iSector *sector, float range);
00178 
00190     psPath *FindNearestPath(const csVector3& v, iSector *sector, float range, float * found_range = NULL, int * index = NULL, float * fraction = NULL);
00191     
00202     psPath *FindNearestPoint(const csVector3& v, iSector *sector, float range, float * found_range = NULL, int * index = NULL);
00203     
00207     csList<Waypoint*> FindWaypointRoute(Waypoint * start, Waypoint * end, const RouteFilter* routeFilter);
00208 
00212     csList<Edge*> FindEdgeRoute(Waypoint * start, Waypoint * end, const RouteFilter* routeFilter);
00213 
00217     size_t FindPointsInSector(iSector *sector, csList<psPathPoint*>& list);
00218 
00222     size_t FindWaypointsInSector(iSector *sector, csList<Waypoint*>& list);
00223 
00224     
00228     void ListWaypoints(const char *pattern);
00229     
00233     void ListPaths(const char *pattern);
00234 
00238     psPath* FindPath(const char *name);
00239 
00243     psPath* FindPath(int id);
00244     
00248     Edge* FindEdge(const Waypoint * wp1, const Waypoint * wp2);
00249 
00250 
00254     Waypoint* CreateWaypoint( iDataConnection *db, csString& name, csVector3& pos, csString& sectorName, float radius, csString& flags);
00255 
00259     Waypoint* CreateWaypoint( csString& name, csVector3& pos, csString& sectorName, float radius, csString& flags);
00260     
00264     psPath* CreatePath(iDataConnection *db, const csString& name, Waypoint* wp1, Waypoint* wp2, const csString& flags);
00265 
00269     psPath* CreatePath(iDataConnection *db, psPath * path);
00270 
00274     psPath* CreatePath(psPath * path);
00275     
00279     int GetNextWaypointCheck();
00280 
00284     bool Delete(psPath * path);
00285 };
00286 
00289 #endif