00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _PATHFINDER_H
00017 #define _PATHFINDER_H
00018
00019 #include "meshNode.h"
00020 #include "cmath.h"
00021 #include "lineSegs.h"
00022
00023 typedef vector<Node *> NodeArray;
00024 typedef vector<NodeArray> NavMesh;
00025
00026 Node* find_in_mesh(NavMesh nav_mesh, LVecBase3f pos, int grid_size);
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class EXPCL_PANDAAI PathFinder {
00037 public:
00038 Node *_src_node;
00039 Node *_dest_node;
00040 vector<Node*> _open_list;
00041 vector<Node*> _closed_list;
00042
00043 NavMesh _grid;
00044
00045 void identify_neighbors(Node *nd);
00046 int calc_cost_frm_src(Node *nd);
00047 int calc_heuristic(Node *nd);
00048 void calc_node_score(Node *nd);
00049 bool is_diagonal_node(Node *nd);
00050
00051 void add_to_olist(Node *nd);
00052 void remove_from_olist();
00053
00054 void add_to_clist(Node *nd);
00055 void remove_from_clist(int r, int c);
00056
00057 void generate_path();
00058 void find_path(Node *src_node, Node *dest_node);
00059 PathFinder(NavMesh nav_mesh);
00060 ~PathFinder();
00061 };
00062
00063 #endif
00064