Panda3D
 All Classes Functions Variables Enumerations
aiPathFinder.h
1 ////////////////////////////////////////////////////////////////////////
2 // Filename : aiPathFinder.h
3 // Created by : Deepak, John, Navin
4 // Date : 10 Nov 09
5 ////////////////////////////////////////////////////////////////////
6 //
7 // PANDA 3D SOFTWARE
8 // Copyright (c) Carnegie Mellon University. All rights reserved.
9 //
10 // All use of this software is subject to the terms of the revised BSD
11 // license. You should have received a copy of this license along
12 // with this source code in a file named "LICENSE."
13 //
14 ////////////////////////////////////////////////////////////////////
15 
16 #ifndef _PATHFINDER_H
17 #define _PATHFINDER_H
18 
19 #include "meshNode.h"
20 #include "cmath.h"
21 #include "lineSegs.h"
22 
23 typedef vector<Node *> NodeArray;
24 typedef vector<NodeArray> NavMesh;
25 
26 Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size);
27 
28 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29 //
30 // Class : PathFinder
31 // Description : This class implements pathfinding using A* algorithm. It also uses a Binary Heap search to
32 // search the open list. The heuristics are calculated using the manhattan method.
33 
34 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
35 
36 class EXPCL_PANDAAI PathFinder {
37 public:
38  Node *_src_node;
39  Node *_dest_node;
40  vector<Node*> _open_list;
41  vector<Node*> _closed_list;
42 
43  NavMesh _grid;
44 
45  void identify_neighbors(Node *nd);
46  int calc_cost_frm_src(Node *nd);
47  int calc_heuristic(Node *nd);
48  void calc_node_score(Node *nd);
49  bool is_diagonal_node(Node *nd);
50 
51  void add_to_olist(Node *nd);
52  void remove_from_olist();
53 
54  void add_to_clist(Node *nd);
55  void remove_from_clist(int r, int c);
56 
57  void generate_path();
58  void find_path(Node *src_node, Node *dest_node);
59  PathFinder(NavMesh nav_mesh);
60  ~PathFinder();
61 };
62 
63 #endif
64 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This class is used to assign the nodes on the mesh.
Definition: meshNode.h:18
This class implements pathfinding using A* algorithm.
Definition: aiPathFinder.h:36