Panda3D
|
00001 // Filename: aiNode.h 00002 // Created by: Deepak, John, Navin (18Nov2009) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef AINODE_H 00016 #define AINODE_H 00017 00018 #include "aiGlobals.h" 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Class : AINode 00022 // Description : This class is used to assign the nodes on the mesh. 00023 // It holds all the data necessary to compute A* 00024 // algorithm. It also maintains a lot of vital 00025 // information such as the neighbor nodes of each 00026 // node and also its position on the mesh. 00027 // Note: The Mesh Generator which is a standalone 00028 // tool makes use of this class to generate the nodes 00029 // on the mesh. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDAAI AINode { 00032 PUBLISHED: 00033 // This variable specifies whether the node is an obtacle or not. 00034 // Used for dynamic obstacle addition to the environment. 00035 // obstacle = false 00036 // navigational = true 00037 bool _type; 00038 00039 // This variable specifies the node status whether open, close 00040 // or neutral. 00041 // open = belongs to _open_list. 00042 // close = belongs to _closed_list. 00043 // neutral = unexamined node. 00044 enum Status { 00045 ST_open, 00046 ST_close, 00047 ST_neutral 00048 }; 00049 Status _status; 00050 00051 // The score is used to compute the traversal expense to nodes 00052 // when using A*. 00053 // _score = _cost + heuristic 00054 int _score; 00055 int _cost; 00056 int _heuristic; 00057 00058 // Used to trace back the path after it is generated using A*. 00059 AINode *_prv_node; 00060 00061 // Position of the node in the 2d grid. 00062 int _grid_x, _grid_y; 00063 00064 // Position of the node in 3D space. 00065 LVecBase3f _position; 00066 00067 // Dimensions of each face / cell on the mesh. 00068 // Height is given in case of expansion to a 3d mesh. Currently 00069 // not used. 00070 float _width, _length ,_height; 00071 AINode *_neighbours[8]; // anti-clockwise from top left corner. 00072 00073 // The _next pointer is used for traversal during mesh 00074 // generation from the model. 00075 // Note: The data in this member is discarded when mesh data 00076 // is written into navmesh.csv file. 00077 AINode *_next; 00078 00079 AINode(int grid_x, int grid_y, LVecBase3f pos, float w, float l, float h); 00080 ~AINode(); 00081 00082 bool contains(float x, float y); 00083 }; 00084 00085 #endif