how to integrate A* pathfinding algorithm with 3d engine?

087e56f196063293a42f713b3b04e9bf
0
michael520 101 Nov 21, 2005 at 07:00

I am using Irrlicht 3d engine and going to add AI to my project.
I still don’t know how to do with that, i am finding relative materials.
If anyone know about this, please give me some advices! Thanks a lot!

5 Replies

Please log in or register to post a reply.

8563f7b73aeb34bb8604f1dd8f546c88
0
Mattias_Gustavsson 101 Nov 21, 2005 at 10:20

Theres a couple of really good articles on path finding in the first Game Programming Gems book, well worth getting.

Basically, what you do with A* is find the least expensive route from one node to another node. “Expensive” can mean just about anything, and “node” can also be just about anything. In the most common case of pathfinding, a node is usually a cell in a 2d grid, and the cost is distance. You provide A* with the node, and a way to get to each nodes neighbours, as well as two methods for cost calculation: the first calculates the cost for moving to a specific node from the start node (this we can usually calculate accurately, with a 2d grid for nodes it’s very straightforward) and the second one calculates the cost for moving to the end node from a specific node (this is usually an estimate, as we probably don’t know for sure until we’ve found the path).

To extend this to a 3D world, all we need to do is use a suitable type for our nodes, along with functions to get a nodes neighbours and calculate and estimate the costs.

What type of nodes we use can have a huge impact on performance. The most efficient type of nodes is probably if you manually create a pathfinding network for each level, by placing and connecting nodes. A quite inefficient way would be to use a 3d grid (like a cube build up of many little cubes, each a node for the pathfinding, with some marked as not walkable), but this could be automatically generated. Other techniques involve using the existing polygons of, say, the floors, as pathfinding nodes, but this makes the cost estimate/calculate methods slightly more complicated.

There’s lots of different ways to do 3d pathfinding with A*, but what they all have in common is that they all have the nodes, with neighbours, and cost calculate/estimate functions.

An interesting thing to note, is that A* can be used for all sorts of problem solving besides path finding, where you can break down the problem into nodes and write good enough cost calculate/estimate functions.

087e56f196063293a42f713b3b04e9bf
0
michael520 101 Dec 06, 2005 at 02:31

Oh Mattias, thank very much!

My 3d simulation project must have a path-finding algorithm to make objects go the right and shortest way. Or could I just provide some polygon-paths for the terrain?

All I have to do is hard-hard working to search and think\~\~\~\~

Thanks for giving me more advices…

065f0635a4c94d685583c20132a4559d
0
Ed_Mack 101 Dec 07, 2005 at 06:48

You can split the terrain up into possible paths, but you really need an algorithm to find a route for players to move over - try A*.

8a5fa29138fe68bea393768458910e16
0
opcode_foo 101 Dec 20, 2005 at 21:43

What you are looking for is usually called waypoints.

How you set them depends on the style of map. On a terrain, you could as simply just set a point in the center of each tile on a quadtree. In a map like a quake game, your mappers would most likely place them in strategic points to optimize the performance of searching. Typically, you would break the pathing down in some way in a real-time game, from smaller searches. In an RTS, for instance, paths can change dynamically (buildings get put down on the map) and recalculating the A* all the time is expensive. So you break it down into smaller subsearches to get to the final goal. Then there are other tricks, to make it smoother, or more realistic. It is annoying if the robot follows the path, well… like a robot…

Game Gems had a ton of articles about this year’s ago, you might want to go to the bookstore and (ahem) get a coffee and read the chapters. I think it was book’s 1 and 2.

2adc5b9473b73e8c77134fb86cc9fd4f
0
Scramasax 101 Feb 12, 2006 at 21:50

I posted this in a latter forum:

http://www.devmaster.net/forums/showthread.php?t=5058
Hope it helps.


bluemarssmall.gif