Mindinsomnia

miNav Documentation

Classes and their Functions

There is only 3 classes in the miNav library, the miNavDevice class, the Map class and the Node class.

class miNavDevice

This class allows you to make a miNav device that can have maps added to it. Deleting this device will delete all the maps and nodes created in it, so it's handy to use this to clean up everything at the end.

The miNavDevice class has 2 functions: addMap() and deleteMap(). The addMap() function returns a pointer to a class of type Map. The deleteMap() function takes one agrument in it's parameters, a pointer to a Map.

Example:
miNavDevice* myDevice = new miNavDevice; // Make a new miNav Device
Map* myMap = myDevice->addMap(); // Makes a new Map
myDevice->deleteMap(myMap); // Deletes the map

class Map

This class manages a collection of Nodes. Deleting this class will delete all the Nodes created by it. This class contains the most functions, it contains 8 functions. The first ones you will be needing are addNode and deleteNode.

addNode() requires 3 parameters, all of which are numbers of type float, these numbers are the X,Y,Z position of the Node. The function returns a pointer of type Node. deleteNode() takes one parameter, a pointer to a Node and returns nothing.

The next functions are to do with connecting the Nodes and disconnecting them. To create a ONE-WAY connection between two nodes, use the connect(Node1,Node2) function, putting in two pointers to nodes in Node1 and Node 2. To create a TWO-WAY connection use the function connect2way(Node1,Node2), which again takes in it's parameters two pointers to nodes. To disconnect the connection between 2 nodes, use the disconnect(Node1, Node2) function, this will remove the connection from Node1 to Node2, NOT FROM Node2 TO Node1!

This class also has a distance function, this function is used in the pathfinding process but you may also use it yourself if you wish. The distance() function takes 2 parameters, both pointers to Nodes and returns a value of type float.

The last two functions are for actually doing the pathfinding. solve() and getSolution(). solve() takes no parameters and returns no value, it solves all the possible pathfinding queries which can be performed on the Nodes and stores them in the Nodes. To access these stored solutions you can use the getSolution() function, this function takes two parameter, both pointers to Nodes, the first is the current Node and the second is the destination Node. The function returns a pointer to a Node, this Node is the FIRST Node you must travel to, to reach your destination Node.

Example
Node* myNode = myMap->addNode(float X, float Y, float Z); // create a Node and add it to the Map
myMap->deleteNode(myNode); // Delete the Node in that Map

myMap->connect(NodeOne,NodeTwo); // ONE-WAY connection from NodeOne to NodeTwo
myMap->disconnect(NodeOne,NodeTwo); // Removes that connection
myMap->connect2way(NodeOne,NodeTwo); // Makes a TWO-WAY connection from NodeOne to NodeTwo
myMap->disconnect(NodeOne,NodeTwo); // Removes the connection from NodeOne to NodeTwo BUT NOT THE CONNECTION FROM NodeTwo TO NodeOne.

myMap->distance(NodeOne,NodeTwo); // Returns the distance between these Nodes

myMap->solve(); // Solves this map, stores all solutions generated
Node* FirstStep = myMap->getSolution(Position,Destination); // Returns the first Node you must go to to reach the Destination.

class Node

The Node class has no functions but stores 3 values. The values are of type float and called X, Y, Z. This is the position of the Node. You access the values at any time, and even modify them. If you do modify the values then it's recommended that you use the solve() function again to update the pathfinding solutions, as the different position of the Node can have an influence of the accurancy of the pathfinding.

Example
float targetX;
float targetY;
float targetZ;

Node* Target = myMap->getSolution(Position, Destination);

targetX = Target->X;
targetY = Target->Y;
targetZ = Target->Z;