Panda3D

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