Panda3D
 All Classes Functions Variables Enumerations
aiNode.h
1 // Filename: aiNode.h
2 // Created by: Deepak, John, Navin (18Nov2009)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef AINODE_H
16 #define AINODE_H
17 
18 #include "aiGlobals.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Class : AINode
22 // Description : This class is used to assign the nodes on the mesh.
23 // It holds all the data necessary to compute A*
24 // algorithm. It also maintains a lot of vital
25 // information such as the neighbor nodes of each
26 // node and also its position on the mesh.
27 // Note: The Mesh Generator which is a standalone
28 // tool makes use of this class to generate the nodes
29 // on the mesh.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDAAI AINode {
32 public:
33  // This variable specifies the node status whether open, close
34  // or neutral.
35  // open = belongs to _open_list.
36  // close = belongs to _closed_list.
37  // neutral = unexamined node.
38  enum Status {
39  ST_open,
40  ST_close,
41  ST_neutral
42  };
43  Status _status;
44 
45  // This variable specifies whether the node is an obtacle or not.
46  // Used for dynamic obstacle addition to the environment.
47  // obstacle = false
48  // navigational = true
49  bool _type;
50 
51  // The score is used to compute the traversal expense to nodes
52  // when using A*.
53  // _score = _cost + heuristic
54  int _score;
55  int _cost;
56  int _heuristic;
57 
58  // Used to trace back the path after it is generated using A*.
59  AINode *_prv_node;
60 
61  // Position of the node in the 2d grid.
62  int _grid_x, _grid_y;
63 
64  // Position of the node in 3D space.
65  LVecBase3 _position;
66 
67  // Dimensions of each face / cell on the mesh.
68  // Height is given in case of expansion to a 3d mesh. Currently
69  // not used.
70  float _width, _length ,_height;
71  AINode *_neighbours[8]; // anti-clockwise from top left corner.
72 
73  // The _next pointer is used for traversal during mesh
74  // generation from the model.
75  // Note: The data in this member is discarded when mesh data
76  // is written into navmesh.csv file.
77  AINode *_next;
78 
79 PUBLISHED:
80  AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h);
81  ~AINode();
82 
83  bool contains(float x, float y);
84 };
85 
86 #endif
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: aiNode.h:31