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