HOG2
MapAbstraction.h
Go to the documentation of this file.
1 /*
2  * $Id: MapAbstraction.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 6/3/05.
6  * Modified by Nathan Sturtevant on 02/29/20.
7  *
8  * This file is part of HOG2. See https://github.com/nathansttt/hog2 for licensing information.
9  *
10  */
11 
12 #include "Map.h"
13 #include "GraphAbstraction.h"
14 #include "GLUtil.h"
15 #include "MapProvider.h"
16 #include <stdlib.h>
17 
18 #ifndef MAPABSTRACTION_H
19 #define MAPABSTRACTION_H
20 
26 class MapAbstraction : public GraphAbstraction, public MapProvider {
27 public:
28  MapAbstraction(Map *_m) :m(_m), levelDraw(0) {}
29  virtual ~MapAbstraction();
31  virtual MapAbstraction *Clone(Map *) = 0;
32  node *GetNodeFromMap(int x, int y, tCorner c = kNone) { return abstractions[0]->GetNode(m->GetNodeNum(x, y, c)); }
33  void GetTileFromNode(node *n, int &x, int &y);
34  void GetRandomTileFromNode(node *n, int &x, int &y);
35 
37  void GetTileUnderLoc(int &x, int &y, const recVec &);
38 
39  Map* GetMap() const { return m; }
40  MapAbstraction *GetMapAbstraction() { return this; }
41 
42  virtual double h(node *a, node *b);
43 
44  double OctileDistance(double,double,double,double);
45 
46  // display functions
47  virtual void OpenGLDraw() const;
48  void ToggleDrawAbstraction(int which);
49  void ClearMarkedNodes();
50  recVec GetNodeLoc(node *n) const;
51 private:
52 
53  void DrawLevelConnections(node *n) const;
54  void DrawGraph(Graph *g, bool levels = true) const;
55 
56  Map *m;
57  unsigned long levelDraw;
58 };
59 
60 Graph *GetMapGraph(Map *m);
61 void AddMapEdges(Map *m, Graph *g, int x, int y);
62 
63 #endif
GraphAbstraction
A generic class for basic operations on Graph abstractions.
Definition: GraphAbstraction.h:63
MapProvider::GetMap
virtual Map * GetMap() const =0
MapProvider::GetMapAbstraction
virtual MapAbstraction * GetMapAbstraction()=0
recVec
A generic vector (essentially the same as a point, but offers normalization)
Definition: GLUtil.h:78
MapProvider
Definition: MapProvider.h:23
GraphAbstraction::OpenGLDraw
virtual void OpenGLDraw() const
Definition: GraphAbstraction.h:119
GraphAbstraction::ClearMarkedNodes
void ClearMarkedNodes()
rebuild hierarchy from original domain *‍/
Definition: GraphAbstraction.cpp:89
Graph
A generic Graph class.
Definition: Graph.h:66
tCorner
tCorner
Definition: Map.h:96
GraphAbstraction::h
virtual double h(node *a, node *b)=0
heuristic cost between any two nodes
GetMapGraph
Graph * GetMapGraph(Map *m)
GetMapGraph(map)
Definition: MapAbstraction.cpp:312
AddMapEdges
void AddMapEdges(Map *m, Graph *g, int x, int y)
Definition: MapAbstraction.cpp:430
GLUtil.h
GraphAbstraction::GetNodeLoc
virtual recVec GetNodeLoc(node *) const
Definition: GraphAbstraction.h:120
Map.h
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
Map
A tile-based representation of the world.
Definition: Map.h:142
GraphAbstraction.h
kNone
@ kNone
Definition: Map.h:97
MapProvider.h