Thank YouCZestmyr wrote:2 etcaptor: Will post a simplified project soon, with the bot animator as well
Irrlicht pathfinding class available
Demo project for Pathfinding class and pathfinding animator
Hi everyone, I've been to other sorts of things recently, but I decided to do what I've promised and post the demo project of my pathfinding class here. So here it is
You can download it here: http://czestmyr.wz.cz/other/PFProject.zip. (188kB)
I didn't include the project file in the archive, so you'll have to do that yourself. Also you'll have to add the map-20kdm2.pk3 archive to the directory of this project, because it uses it and I didn't include it in the zip file, because it would be too big then. You'll also find a precompiled version of the project in the zip file, but it'll work with the irr 0.10.0 only, I presume (that's my current version).
Take a look at the bot animator, which shows, how to implement pathfinding into animators. Another class is class selector, which selects a node by a ray. I use it for shooting. Another special feature is digit viewer, which is really ugly and awfully coded and I didn't want to modify my project too much, so I left it in.
Here is a screenshot of the project:
You can download it here: http://czestmyr.wz.cz/other/PFProject.zip. (188kB)
I didn't include the project file in the archive, so you'll have to do that yourself. Also you'll have to add the map-20kdm2.pk3 archive to the directory of this project, because it uses it and I didn't include it in the zip file, because it would be too big then. You'll also find a precompiled version of the project in the zip file, but it'll work with the irr 0.10.0 only, I presume (that's my current version).
Take a look at the bot animator, which shows, how to implement pathfinding into animators. Another class is class selector, which selects a node by a ray. I use it for shooting. Another special feature is digit viewer, which is really ugly and awfully coded and I didn't want to modify my project too much, so I left it in.
Here is a screenshot of the project:
Someone should preserve these kind of contributions in a easly accessible way. One idea: create another forum ONLY for finished code people what to contribute with.
"Yes, this is important. pathnet->loadNetFromFile("net.txt"), but how we can generate these datas."
One way is to use a Blender script. You load your level in Blender and then add marks (marks are just special objects that serve as a marker) to the places where you want nodes to be. A node marker could be a losangle object and a line marker a polygon line connecting losangles. The script would figure out to translate it into a text file.
See these pictures for an idea:
http://www.elderscrolls.com/images/code ... n01_lg.jpg
http://www.elderscrolls.com/images/code ... n02_lg.jpg
"Yes, this is important. pathnet->loadNetFromFile("net.txt"), but how we can generate these datas."
One way is to use a Blender script. You load your level in Blender and then add marks (marks are just special objects that serve as a marker) to the places where you want nodes to be. A node marker could be a losangle object and a line marker a polygon line connecting losangles. The script would figure out to translate it into a text file.
See these pictures for an idea:
http://www.elderscrolls.com/images/code ... n01_lg.jpg
http://www.elderscrolls.com/images/code ... n02_lg.jpg
WOW, WOW , it is incredible!!!
plz , write a tutorial about how built that "construction level"
it is a great great work. We can leran very much with this.
A question , are there different types of nodes for the network of the pathfinfing, type like bots in counter strike? ( normal node, ladder node, etc etc)
plz , write a tutorial about how built that "construction level"
it is a great great work. We can leran very much with this.
A question , are there different types of nodes for the network of the pathfinfing, type like bots in counter strike? ( normal node, ladder node, etc etc)
@CZestmyr, I just started the demo. Great work man! You are 17 years, right? But suggest that this kind of AI is very hungry for CPU power. One entity slows down my FPS with over 30-40 Hz. When I lost my attention for 2-3 minutes my FPS fall down from 500 to 23 Hz. I'm still not look at the code, but it's very interested for me,
By the way these kind of AI is /A*/ or similar are very applicable for strategy games. In this case for improvement of speed your system can be applied to one from group nodes, and others will be able to use some kind of AI like "follow the leader"
Personally I use rotating and some additional rays in my project and result is similarly, but not need to make any coordinate maps before that, but with this method you can't find exactly whether there is a path to end point.
By the way these kind of AI is /A*/ or similar are very applicable for strategy games. In this case for improvement of speed your system can be applied to one from group nodes, and others will be able to use some kind of AI like "follow the leader"
Personally I use rotating and some additional rays in my project and result is similarly, but not need to make any coordinate maps before that, but with this method you can't find exactly whether there is a path to end point.
Wow! Thanks for your feedback, people. Now to some questions and comments:
press [R] to delete the whole net.
by pressing [A] you toggle the add mode. In this mode, you can add nodes.
Just move your character to a position and click...
[D] - delete mode - delete the nearest node and its connections by clicking
[C] - connect mode - click at the position of the first node and click again at the position of the second node to connect them
[F] - find path mode - click the first and then the second node to find a path between them
[S] - saves the net to a file named "test.txt"
[L] - loads the net from "net.txt"
[G] - adds a guard
Yes, I've changed that even before uploading it, but I must have uploaded the old version. It's corrected now.In main.cpp change map-20kdm2.zip by map-20kdm2.pk3
I will try to remake the counter and then possibly release it here, but now, as I wrote inside the code, it is not very nicely coded.plz put a tutorial like counter , how put a new node, how connect them, doing path, etc, etc thanks
Fortunately, I've coded functions for adding nodes into the pathfinding class and you can call these functions directly from the demo project. Here is how to do it: (but it would be good to comment the code for adding the bots and the camera collision response animator)Yes, this is important. pathnet->loadNetFromFile("net.txt"), but how we can generate these datas.
press [R] to delete the whole net.
by pressing [A] you toggle the add mode. In this mode, you can add nodes.
Just move your character to a position and click...
[D] - delete mode - delete the nearest node and its connections by clicking
[C] - connect mode - click at the position of the first node and click again at the position of the second node to connect them
[F] - find path mode - click the first and then the second node to find a path between them
[S] - saves the net to a file named "test.txt"
[L] - loads the net from "net.txt"
[G] - adds a guard
Ooops, this is a serious drawback to my bot animator, I'll have to recode it, for example to let it change the state (guarding, seeking, following) only once in ten frames or something like that. I didn't even notify the problem myself, thanks.One entity slows down my FPS with over 30-40 Hz
If you don't mind a little remark it's not a very good relying on frames instead of a clock to synchronize things. If you really want to work like the pros (i have read this in some gamasutra article) use one clock variable for rendering and another clock variable for the game, ai, pathfinding and stuff. Some people sugest using a third clock for pooling input devices.CZestmyr wrote:... only once in ten frames or something like that.
The trick is to set a threshold for each clock (presentation or game ai) and when one of the clocks raises above that threshold its time to do something, render the scene or execute one step of your pathfinding algorithm.
For those who wanted the counter tutorial - here it is:
http://czestmyr.wz.cz/other/dvtut/dvtutorial.html
The class itself changed a bit, so it won't function with the FPS demo project, but it's coded in a better way now.
2 elander: Of course I know that timing related to frames is really a bad idea, but I'm no pro, that's the difference (just kidding, I'll have to try your suggestion, when I'm into something more serious)
http://czestmyr.wz.cz/other/dvtut/dvtutorial.html
The class itself changed a bit, so it won't function with the FPS demo project, but it's coded in a better way now.
2 elander: Of course I know that timing related to frames is really a bad idea, but I'm no pro, that's the difference (just kidding, I'll have to try your suggestion, when I'm into something more serious)
very very good.
i am compilate in irrlicht 0.12 and it works very good
I think you must do a tutorial about how it is used. Example of put nodes, joint nodes, in a any level , and the most important , how is the fomat of the data save (net.txt)
And A person must talk it to niko, i think it can be include in irrlicht without problem , and it is very powerfull
A question ... how can i do different types of the nodes? (like bots in counter strike , "normal nodes", "ladder nodes" , etc, ? I think derevating of the base class but , it must paint in differents colours, and the base class must have a method where i can ask the type of node
It is a suggestion
thanks other time
i am compilate in irrlicht 0.12 and it works very good
I think you must do a tutorial about how it is used. Example of put nodes, joint nodes, in a any level , and the most important , how is the fomat of the data save (net.txt)
And A person must talk it to niko, i think it can be include in irrlicht without problem , and it is very powerfull
A question ... how can i do different types of the nodes? (like bots in counter strike , "normal nodes", "ladder nodes" , etc, ? I think derevating of the base class but , it must paint in differents colours, and the base class must have a method where i can ask the type of node
It is a suggestion
thanks other time
I will do a simple tut soon. But I can describe the data format immediately for you. It is not very neat and I should change it to XML, but now it is sufficient:I think you must do a tutorial about how it is used. Example of put nodes, joint nodes, in a any level , and the most important , how is the fomat of the data save (net.txt)
The file begins with the number of nodes.
Then, for every node, it contains its coordinates, number of neighbours and their coordinates afterwards. That's it.
e.g.:
90 - Number of nodes
511.211 - First node's coordinates
-62.9993
2.57089
3 - Number of neighbours of the first node
509.997 - The neighbour 1's coordinates
-191
276.263
320.608 - The neighbour 2's coordinates
-62.9996
-51.7468
674.88 - The neighbour 3's coordinates
-62.9997
-43.6599
509.997 - Second node's coordinates
-191
276.263
2 - Number of its neighbours
506.061 - The neighbour 1's coordinates
-191
446.884
511.211 - The neighbour 2's coordinates
-62.9993
2.57089
etc...
But the class itself can generate the file for you, just read my pre-previous post.
a) - The node is not so powerful, as it may seem. BTW, I think there are more of these among other irrlichters.And A person must talk it to niko, i think it can be include in irrlicht without problem , and it is very powerfull
b) - It wouldn't be such a good idea to include this in irrlicht, because irrlicht is only a graphics engine, you have to code everything other yourself.
The pf class contains just one type of nodes at this time. I think, this is more a problem of the bot animator, the bot itself should decide, what to do. If, for example, it finds that the next node is above it and it is in a climbable area, it should climb automatically. But you would have to code all this yourselfA question ... how can i do different types of the nodes?