Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
PathFind Class Reference

This class contains all the members and functions that are required to form an interface between the AIBehaviors class and the PathFinder class. More...

#include "pathFind.h"

Public Member Functions

 PathFind (AICharacter *ai_ch)
 
void add_obstacle_to_mesh (NodePath obstacle)
 This function allows the user to dynamically add obstacles to the game environment.
 
void assign_neighbor_nodes (const char *navmesh_filename)
 This function assigns the neighbor nodes for each main node present in _nav_mesh.
 
void clear_path ()
 Helper function to restore the path and mesh to its initial state.
 
void clear_previous_obstacles ()
 Helper function to reset the collisions if the obstacle is not on the node anymore.
 
void create_nav_mesh (const char *navmesh_filename)
 This function recreates the navigation mesh from the .csv file.
 
void do_dynamic_avoid ()
 This function does the updation of the collisions to the mesh based on the new positions of the obstacles.
 
void dynamic_avoid (NodePath obstacle)
 This function starts the pathfinding obstacle navigation for the passed in obstacle.
 
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 finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.
 
void path_find (NodePath target, std::string type="normal")
 This function checks for the source and target in the navigation mesh for its availability and then finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.
 
 PT (GeomNode) _parent
 
void set_path_find (const char *navmesh_filename)
 This function starts the path finding process after reading the given navigation mesh.
 
void trace_path (Node *src)
 This function is the function which sends the path information one by one to the path follower so that it can store the path needed to be traversed by the pathfinding object.
 

Public Attributes

AICharacter_ai_char
 
bool _dynamic_avoid
 
std::vector< NodePath_dynamic_obstacle
 
int _grid_size
 
NavMesh _nav_mesh
 
NodePath _path_find_target
 
PathFinder_path_finder_obj
 
LineSegs_pen
 
LVecBase3 _prev_position
 
std::vector< int > _previous_obstacles
 
NavMesh _stage_mesh
 

Detailed Description

This class contains all the members and functions that are required to form an interface between the AIBehaviors class and the PathFinder class.

An object (pointer) of this class is provided in the AIBehaviors class. It is only via this object that the user can activate pathfinding.

Definition at line 30 of file pathFind.h.

Constructor & Destructor Documentation

◆ PathFind()

PathFind::PathFind ( AICharacter * ai_ch)

Definition at line 22 of file pathFind.cxx.

◆ ~PathFind()

PathFind::~PathFind ( )

Definition at line 36 of file pathFind.cxx.

Member Function Documentation

◆ add_obstacle_to_mesh()

void PathFind::add_obstacle_to_mesh ( NodePath obstacle)

This function allows the user to dynamically add obstacles to the game environment.

The function will update the nodes within the bounding volume of the obstacle as non-traversable. Hence will not be considered by the pathfinding algorithm.

Definition at line 336 of file pathFind.cxx.

References find_in_mesh(), and NodePath::get_pos().

Referenced by AIBehaviors::add_static_obstacle(), and do_dynamic_avoid().

◆ assign_neighbor_nodes()

void PathFind::assign_neighbor_nodes ( const char * navmesh_filename)

This function assigns the neighbor nodes for each main node present in _nav_mesh.

Definition at line 119 of file pathFind.cxx.

Referenced by create_nav_mesh().

◆ clear_path()

void PathFind::clear_path ( )

Helper function to restore the path and mesh to its initial state.

Definition at line 282 of file pathFind.cxx.

Referenced by path_find(), and path_find().

◆ clear_previous_obstacles()

void PathFind::clear_previous_obstacles ( )

Helper function to reset the collisions if the obstacle is not on the node anymore.

Definition at line 379 of file pathFind.cxx.

Referenced by do_dynamic_avoid().

◆ create_nav_mesh()

void PathFind::create_nav_mesh ( const char * navmesh_filename)

This function recreates the navigation mesh from the .csv file.

Definition at line 42 of file pathFind.cxx.

References assign_neighbor_nodes().

Referenced by set_path_find().

◆ do_dynamic_avoid()

void PathFind::do_dynamic_avoid ( )

This function does the updation of the collisions to the mesh based on the new positions of the obstacles.

Definition at line 367 of file pathFind.cxx.

References add_obstacle_to_mesh(), and clear_previous_obstacles().

Referenced by PathFollow::do_follow().

◆ dynamic_avoid()

void PathFind::dynamic_avoid ( NodePath obstacle)

This function starts the pathfinding obstacle navigation for the passed in obstacle.

Definition at line 389 of file pathFind.cxx.

Referenced by AIBehaviors::add_dynamic_obstacle().

◆ path_find() [1/2]

void PathFind::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 finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.

Definition at line 203 of file pathFind.cxx.

References clear_path(), find_in_mesh(), PathFinder::find_path(), NodePath::get_pos(), AIBehaviors::path_follow(), AIBehaviors::remove_ai(), AIBehaviors::start_follow(), and trace_path().

Referenced by PathFollow::do_follow(), AIBehaviors::path_find_to(), and AIBehaviors::path_find_to().

◆ path_find() [2/2]

void PathFind::path_find ( NodePath target,
std::string type = "normal" )

This function checks for the source and target in the navigation mesh for its availability and then finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.

Definition at line 241 of file pathFind.cxx.

References clear_path(), find_in_mesh(), PathFinder::find_path(), NodePath::get_pos(), AIBehaviors::path_follow(), AIBehaviors::remove_ai(), AIBehaviors::start_follow(), and trace_path().

◆ set_path_find()

void PathFind::set_path_find ( const char * navmesh_filename)

This function starts the path finding process after reading the given navigation mesh.

Definition at line 181 of file pathFind.cxx.

References create_nav_mesh(), AIBehaviors::path_follow(), and AIBehaviors::remove_ai().

Referenced by AIBehaviors::init_path_find().

◆ trace_path()

void PathFind::trace_path ( Node * src)

This function is the function which sends the path information one by one to the path follower so that it can store the path needed to be traversed by the pathfinding object.

Definition at line 307 of file pathFind.cxx.

References AIBehaviors::add_to_path(), LineSegs::create(), LineSegs::draw_to(), and LineSegs::move_to().

Referenced by path_find(), and path_find().

Member Data Documentation

◆ _ai_char

AICharacter* PathFind::_ai_char

Definition at line 32 of file pathFind.h.

◆ _dynamic_avoid

bool PathFind::_dynamic_avoid

Definition at line 44 of file pathFind.h.

◆ _dynamic_obstacle

std::vector<NodePath> PathFind::_dynamic_obstacle

Definition at line 45 of file pathFind.h.

◆ _grid_size

int PathFind::_grid_size

Definition at line 38 of file pathFind.h.

◆ _nav_mesh

NavMesh PathFind::_nav_mesh

Definition at line 35 of file pathFind.h.

◆ _path_find_target

NodePath PathFind::_path_find_target

Definition at line 39 of file pathFind.h.

◆ _path_finder_obj

PathFinder* PathFind::_path_finder_obj

Definition at line 33 of file pathFind.h.

◆ _pen

LineSegs* PathFind::_pen

Definition at line 42 of file pathFind.h.

◆ _prev_position

LVecBase3 PathFind::_prev_position

Definition at line 40 of file pathFind.h.

◆ _previous_obstacles

std::vector<int> PathFind::_previous_obstacles

Definition at line 43 of file pathFind.h.

◆ _stage_mesh

NavMesh PathFind::_stage_mesh

Definition at line 36 of file pathFind.h.


The documentation for this class was generated from the following files: