00001 00002 #ifndef _MESHNODE_H 00003 #define _MESHNODE_H 00004 00005 #include "aiGlobals.h" 00006 00007 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00008 // 00009 // Class : Node 00010 // Description : This class is used to assign the nodes on the mesh. It holds all the data necessary to 00011 // compute A* algorithm. It also maintains a lot of vital information such as the neighbor 00012 // nodes of each node and also its position on the mesh. 00013 // Note: The Mesh Generator which is a stand alone tool makes use of this class to generate the nodes on the 00014 // mesh. 00015 00016 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00017 00018 class EXPCL_PANDAAI Node { 00019 public: 00020 // This variable specifies whether the node is an obtacle or not. 00021 // Used for dynamic obstacle addition to the environment. 00022 // obstacle = false 00023 // navigational = true 00024 bool _type; 00025 00026 // This variable specifies the node status whether open, close or neutral. 00027 // open = belongs to _open_list. 00028 // close = belongs to _closed_list. 00029 // neutral = unexamined node. 00030 enum Status { 00031 open, 00032 close, 00033 neutral 00034 }; 00035 Status _status; 00036 00037 // The score is used to compute the traversal expense to nodes when using A*. 00038 // _score = _cost + heuristic 00039 int _score; 00040 int _cost; 00041 int _heuristic; 00042 00043 // Used to trace back the path after it is generated using A*. 00044 Node *_prv_node; 00045 00046 // Position of the node in the 2d grid. 00047 int _grid_x, _grid_y; 00048 00049 // Position of the node in 3D space. 00050 LVecBase3f _position; 00051 00052 // Dimensions of each face / cell on the mesh. 00053 // Height is given in case of expansion to a 3d mesh. Currently not used. 00054 float _width, _length ,_height; 00055 Node *_neighbours[8]; // anti-clockwise from top left corner. 00056 00057 // The _next pointer is used for traversal during mesh generation from the model. 00058 // Note: The data in this member is discarded when mesh data is written into navmesh.csv file. 00059 Node *_next; 00060 00061 Node(int grid_x, int grid_y, LVecBase3f pos, float w, float l, float h); 00062 ~Node(); 00063 00064 bool contains(float x, float y); 00065 }; 00066 00067 #endif