Panda3D

Loading...
Searching...
No Matches
pathFind.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 pathFind.h
10 * @author Deepak, John, Navin
11 * @date 2009-10-12
12 */
13
14#ifndef _PATHFIND_H
15#define _PATHFIND_H
16
17#include "aiGlobals.h"
18#include "aiCharacter.h"
19#include "aiPathFinder.h"
20#include "boundingSphere.h"
21
22 class AICharacter;
23
24/**
25 * This class contains all the members and functions that are required to form
26 * an interface between the AIBehaviors class and the PathFinder class. An
27 * object (pointer) of this class is provided in the AIBehaviors class. It is
28 * only via this object that the user can activate pathfinding.
29 */
30 class EXPCL_PANDAAI PathFind {
31 public:
32 AICharacter *_ai_char;
33 PathFinder *_path_finder_obj;
34
35 NavMesh _nav_mesh;
36 NavMesh _stage_mesh;
37
38 int _grid_size;
39 NodePath _path_find_target;
40 LVecBase3 _prev_position;
41 PT(GeomNode) _parent;
42 LineSegs *_pen;
43 std::vector<int> _previous_obstacles;
44 bool _dynamic_avoid;
45 std::vector<NodePath> _dynamic_obstacle;
46
47 PathFind(AICharacter *ai_ch);
48 ~PathFind();
49
50 void clear_path();
51 void trace_path(Node* src);
52
53 void create_nav_mesh(const char* navmesh_filename);
54 void assign_neighbor_nodes(const char* navmesh_filename);
55 void do_dynamic_avoid();
56 void clear_previous_obstacles();
57
58 void set_path_find(const char* navmesh_filename);
59 void path_find(LVecBase3 pos, std::string type = "normal");
60 void path_find(NodePath target, std::string type = "normal");
61 void add_obstacle_to_mesh(NodePath obstacle);
62 void dynamic_avoid(NodePath obstacle);
63};
64
65#endif
aiCharacter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
aiGlobals.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
aiPathFinder.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
boundingSphere.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AICharacter
Definition aiCharacter.h:29
GeomNode
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
LineSegs
Encapsulates creation of a series of connected or disconnected line segments or points,...
Definition lineSegs.h:33
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
Node
This class is used to assign the nodes on the mesh.
Definition meshNode.h:16
PathFind::path_find
void path_find(LVecBase3 pos, std::string type="normal")
This function checks for the source and target in the navigation mesh for its availability and then f...
Definition pathFind.cxx:203
PathFind::add_obstacle_to_mesh
void add_obstacle_to_mesh(NodePath obstacle)
This function allows the user to dynamically add obstacles to the game environment.
Definition pathFind.cxx:336
PathFind::create_nav_mesh
void create_nav_mesh(const char *navmesh_filename)
This function recreates the navigation mesh from the .csv file.
Definition pathFind.cxx:42
PathFind::dynamic_avoid
void dynamic_avoid(NodePath obstacle)
This function starts the pathfinding obstacle navigation for the passed in obstacle.
Definition pathFind.cxx:389
PathFind::clear_path
void clear_path()
Helper function to restore the path and mesh to its initial state.
Definition pathFind.cxx:282
PathFind::trace_path
void trace_path(Node *src)
This function is the function which sends the path information one by one to the path follower so tha...
Definition pathFind.cxx:307
PathFind::set_path_find
void set_path_find(const char *navmesh_filename)
This function starts the path finding process after reading the given navigation mesh.
Definition pathFind.cxx:181
PathFind::clear_previous_obstacles
void clear_previous_obstacles()
Helper function to reset the collisions if the obstacle is not on the node anymore.
Definition pathFind.cxx:379
PathFind::do_dynamic_avoid
void do_dynamic_avoid()
This function does the updation of the collisions to the mesh based on the new positions of the obsta...
Definition pathFind.cxx:367
PathFind::assign_neighbor_nodes
void assign_neighbor_nodes(const char *navmesh_filename)
This function assigns the neighbor nodes for each main node present in _nav_mesh.
Definition pathFind.cxx:119
PathFinder
This class implements pathfinding using A* algorithm.
Definition aiPathFinder.h:31