Artificial Intelligence
Public Member Functions | Protected Attributes | Private Attributes

GamePipe::GraphWorld Class Reference

use graph to represent the world for AI More...

#include <GraphWorld.h>

List of all members.

Public Member Functions

 GraphWorld ()
 ~GraphWorld ()
bool addNode (GraphNode *newNode)
 add node to the world and also add edges containing the node to the world
bool deleteNode (GraphNode *delNode)
 delete node
bool deleteNodeByIndex (int i)
 delete node
void drawPath (Ogre::SceneManager *, std::list< GraphNode * >)
std::list< GraphEdge * > getEdgeList (std::list< GraphNode * > givenNodeList)
 input a givenNodeList, this function will return the edges containing adjacent nodes in the givenNodeList in given sequence
std::list< GraphEdge * > getEdgeList (GraphNode *node)
 input the pointer to a node and return all the edge containing this node
std::list< GraphEdge * > getEdgeList ()
 get the EdgeList in GraphWorld
GraphNodegetNearestNode (Ogre::Vector3 pos)
 this function will return the pointer to the node which is nearest to the position
GraphNodegetNodeByIndex (int i)
 get node by index in NodeList
GraphNodegetNodeByPos (Ogre::Vector3 pos)
 input a position, this function will return the pointer to the node
GraphEdgegetEdgeByIndex (int i)
 get edge by index in EdgeList
std::list< GraphNode * > getNodeList ()
GraphEdgegetEdge (Ogre::Vector3 node1, Ogre::Vector3 node2)
 get the edge by the 2 end points
void removePath ()
bool updateGraphWorld ()
 use this function to update the graph world every frame
void initializeDebug (Ogre::SceneManager *)
void setDebug (bool)
void updateDebug (float)

Protected Attributes

std::list< DebugObject * > * m_pathDebugObjects
std::list< DebugObject * > * m_lineDebugObjects

Private Attributes

std::list< GraphNode * > NodeList
 NodeList contains pointers to all the node in the world.
std::list< GraphEdge * > EdgeList
 EdgeList contains pointers to all the edge in the world.
bool m_debug

Detailed Description

use graph to represent the world for AI

<author>Lin Tian tina.tian1987@gmail.com</author>


Constructor & Destructor Documentation

GamePipe::GraphWorld::GraphWorld ( )
GamePipe::GraphWorld::~GraphWorld ( )

Member Function Documentation

bool GamePipe::GraphWorld::addNode ( GraphNode newNode)

add node to the world and also add edges containing the node to the world

Parameters:
newNodethe pointer to the node to add
Returns:
return true if add successfully
bool GamePipe::GraphWorld::deleteNode ( GraphNode delNode)

delete node

Parameters:
delNodethe pointer to the node to delete
Returns:
return true if delete successfully
bool GamePipe::GraphWorld::deleteNodeByIndex ( int  i)

delete node

Parameters:
ithe index of the node to delete in Nodelist
Returns:
return true if delete successfully
void GamePipe::GraphWorld::drawPath ( Ogre::SceneManager *  ,
std::list< GraphNode * >   
)
GraphEdge * GamePipe::GraphWorld::getEdge ( Ogre::Vector3  node1,
Ogre::Vector3  node2 
)

get the edge by the 2 end points

Parameters:
node1the coordinate of one of the end points
node2the coordinate of the other end point
Returns:
return the pointer to the edge. If there is no edge between these 2 points, then return an edge with -1 cost. If this 2 nodes are not in the world, then return null
GraphEdge * GamePipe::GraphWorld::getEdgeByIndex ( int  i)

get edge by index in EdgeList

Parameters:
iindex in EdgeList
Returns:
pointer to the edge
std::list< GraphEdge * > GamePipe::GraphWorld::getEdgeList ( std::list< GraphNode * >  givenNodeList)

input a givenNodeList, this function will return the edges containing adjacent nodes in the givenNodeList in given sequence

Parameters:
givenNodeListnodeList contains the sequence of the nodes
Returns:
return the edge in given sequence
std::list< GraphEdge * > GamePipe::GraphWorld::getEdgeList ( GraphNode node)

input the pointer to a node and return all the edge containing this node

Parameters:
nodepointer to the node
Returns:
a list of pointer to the edges containing the node
std::list<GraphEdge*> GamePipe::GraphWorld::getEdgeList ( ) [inline]

get the EdgeList in GraphWorld

Returns:
return a list which contains pointer to all the Edge in GraphWorld
GraphNode * GamePipe::GraphWorld::getNearestNode ( Ogre::Vector3  pos)

this function will return the pointer to the node which is nearest to the position

Parameters:
posinput the position
Returns:
return the pointer to the node
GraphNode * GamePipe::GraphWorld::getNodeByIndex ( int  i)

get node by index in NodeList

Parameters:
iindex in NodeList
Returns:
pointer to the node
GraphNode * GamePipe::GraphWorld::getNodeByPos ( Ogre::Vector3  pos)

input a position, this function will return the pointer to the node

Parameters:
posthe position of the node
Returns:
if the node exists return the pointer to the node, or else return pointer to the node with position (0,0,0)
std::list<GraphNode*> GamePipe::GraphWorld::getNodeList ( ) [inline]

get the NodeList in GraphWorld

Returns:
return a list which contains pointer to all the node in GraphWorld
void GamePipe::GraphWorld::initializeDebug ( Ogre::SceneManager *  manager)
void GamePipe::GraphWorld::removePath ( )
void GamePipe::GraphWorld::setDebug ( bool  debug)
void GamePipe::GraphWorld::updateDebug ( float  deltaTime)
bool GamePipe::GraphWorld::updateGraphWorld ( )

use this function to update the graph world every frame


Member Data Documentation

EdgeList contains pointers to all the edge in the world.

NodeList contains pointers to all the node in the world.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines